- [HTTP request](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#body.PATH_PARAMETERS)
- [Query parameters](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#body.QUERY_PARAMETERS)
- [Request body](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#body.request_body)
- [Response body](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#body.response_body)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#body.CalculateCoverageResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#body.aspect)
- [CoverageType](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#CoverageType)
- [IntentCoverage](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#IntentCoverage)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#IntentCoverage.SCHEMA_REPRESENTATION)
- [Intent](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Intent)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Intent.SCHEMA_REPRESENTATION)
- [TransitionCoverage](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionCoverage)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionCoverage.SCHEMA_REPRESENTATION)
- [Transition](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Transition)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Transition.SCHEMA_REPRESENTATION)
- [TransitionNode](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionNode)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionNode.SCHEMA_REPRESENTATION)
- [TransitionRouteGroupCoverage](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionRouteGroupCoverage)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionRouteGroupCoverage.SCHEMA_REPRESENTATION)
- [Coverage](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Coverage)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Coverage.SCHEMA_REPRESENTATION)
- [Transition](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Transition_1)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Transition_1.SCHEMA_REPRESENTATION)
- [Try it!](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#try-it)

Calculates the test coverage for an agent.

### HTTP request

Choose an endpoint:
global   
`GET https://dialogflow.googleapis.com/v3/{agent=projects/*/locations/*/agents/*}/testCases:calculateCoverage`

<br />

The URLs use [gRPC Transcoding](https://google.aip.dev/127) syntax.

**OR**

`GET https://{endpoint}/v3/{agent=projects/*/locations/*/agents/*}/testCases:calculateCoverage`

Where `{endpoint}` is one of the [supported service endpoints](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest#rest_endpoints).

The URLs use [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `agent` | `string` Required. The agent to calculate coverage for. Format: `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `agent`: - `dialogflow.testcases.calculateCoverage` |

### Query parameters

| Parameters ||
|---|---|
| `type` | ``enum (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#CoverageType`)`` Required. The type of coverage requested. |

### Request body

The request body must be empty.

### Response body

The response message for `https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#google.cloud.dialogflow.cx.v3.TestCases.CalculateCoverage`.

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "agent": string, // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "intentCoverage": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#IntentCoverage`) }, "transitionCoverage": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionCoverage`) }, "routeGroupCoverage": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionRouteGroupCoverage`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `agent` | `string` The agent to calculate coverage for. Format: `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. |
| The type of coverage requested. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `intentCoverage` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#IntentCoverage`)`` Intent coverage. |
| `transitionCoverage` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionCoverage`)`` Transition (excluding transition route groups) coverage. |
| `routeGroupCoverage` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionRouteGroupCoverage`)`` Transition route group coverage. |
| End of mutually exclusive fields. ||

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloud-platform`
- `
  https://www.googleapis.com/auth/dialogflow`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).

## CoverageType

The type of coverage score requested.

| Enums ||
|---|---|
| `COVERAGE_TYPE_UNSPECIFIED` | Should never be used. |
| `INTENT` | Intent coverage. |
| `PAGE_TRANSITION` | Page transition coverage. |
| `TRANSITION_ROUTE_GROUP` | Transition route group coverage. |

## IntentCoverage

Intent coverage represents the percentage of all possible intents in the agent that are triggered in any of a parent's test cases.

| JSON representation |
|---|
| ``` { "intents": [ { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Intent`) } ], "coverageScore": number } ``` |

| Fields ||
|---|---|
| `intents[]` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Intent`)`` The list of Intents present in the agent |
| `coverageScore` | `number` The percent of intents in the agent that are covered. |

## Intent

The agent's intent.

| JSON representation |
|---|
| ``` { "intent": string, "covered": boolean } ``` |

| Fields ||
|---|---|
| `intent` | `string` The intent full resource name |
| `covered` | `boolean` Whether the intent is covered by at least one of the agent's test cases. |

## TransitionCoverage

Transition coverage represents the percentage of all possible page transitions (page-level transition routes and event handlers, excluding transition route groups) present within any of a parent's test cases.

| JSON representation |
|---|
| ``` { "transitions": [ { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Transition`) } ], "coverageScore": number } ``` |

| Fields ||
|---|---|
| `transitions[]` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Transition`)`` The list of Transitions present in the agent. |
| `coverageScore` | `number` The percent of transitions in the agent that are covered. |

## Transition

A transition in a page.

| JSON representation |
|---|
| ``` { "source": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionNode`) }, "index": integer, "target": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionNode`) }, "covered": boolean, // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "transitionRoute": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/TransitionRoute`) }, "eventHandler": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/EventHandler`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `source` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionNode`)`` The start node of a transition. |
| `index` | `integer` The index of a transition in the transition list. Starting from 0. |
| `target` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#TransitionNode`)`` The end node of a transition. |
| `covered` | `boolean` Whether the transition is covered by at least one of the agent's test cases. |
| The detailed transition. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `transitionRoute` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/TransitionRoute`)`` Intent route or condition route. |
| `eventHandler` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/EventHandler`)`` Event handler. |
| End of mutually exclusive fields. ||

## TransitionNode

The source or target of a transition.

| JSON representation |
|---|
| ``` { // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "page": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows.pages#Page`) }, "flow": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows#Flow`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| A TransitionNode can be either a page or a flow. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `page` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows.pages#Page`)`` Indicates a transition to a `https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows.pages#Page`. Only some fields such as name and displayname will be set. |
| `flow` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows#Flow`)`` Indicates a transition to a `https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows#Flow`. Only some fields such as name and displayname will be set. |
| End of mutually exclusive fields. ||

## TransitionRouteGroupCoverage

Transition route group coverage represents the percentage of all possible transition routes present within any of a parent's test cases. The results are grouped by the transition route group.

| JSON representation |
|---|
| ``` { "coverages": [ { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Coverage`) } ], "coverageScore": number } ``` |

| Fields ||
|---|---|
| `coverages[]` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Coverage`)`` Transition route group coverages. |
| `coverageScore` | `number` The percent of transition routes in all the transition route groups that are covered. |

## Coverage

Coverage result message for one transition route group.

| JSON representation |
|---|
| ``` { "routeGroup": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows.transitionRouteGroups#TransitionRouteGroup`) }, "transitions": [ { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Transition_1`) } ], "coverageScore": number } ``` |

| Fields ||
|---|---|
| `routeGroup` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows.transitionRouteGroups#TransitionRouteGroup`)`` Transition route group metadata. Only name and displayName will be set. |
| `transitions[]` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases/calculateCoverage#Transition_1`)`` The list of transition routes and coverage in the transition route group. |
| `coverageScore` | `number` The percent of transition routes in the transition route group that are covered. |

## Transition

A transition coverage in a transition route group.

| JSON representation |
|---|
| ``` { "transitionRoute": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/TransitionRoute`) }, "covered": boolean } ``` |

| Fields ||
|---|---|
| `transitionRoute` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/TransitionRoute`)`` Intent route or condition route. |
| `covered` | `boolean` Whether the transition route is covered by at least one of the agent's test cases. |