- [HTTP request](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#body.aspect)
- [GitSource](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#GitSource)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#GitSource.SCHEMA_REPRESENTATION)
- [RestoreOption](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#RestoreOption)
- [Try it!](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#try-it)

Restores the specified agent from a binary file.

Replaces the current agent with a new one. Note that all existing resources in agent (e.g. intents, entity types, flows) will be removed.

This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields:

- `metadata`: An empty [Struct message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct)
- `response`: An [Empty message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty)

Note: You should always train flows prior to sending them queries. See the [training documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training).

### HTTP request

Choose an endpoint:
global   
`POST https://dialogflow.googleapis.com/v3/{name=projects/*/locations/*/agents/*}:restore`

<br />

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

**OR**

`POST https://{endpoint}/v3/{name=projects/*/locations/*/agents/*}:restore`

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 ||
|---|---|
| `name` | `string` Required. The name of the agent to restore into. Format: `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `name`: - `dialogflow.agents.restore` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "restoreOption": enum (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#RestoreOption`), // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "agentUri": string, "agentContent": string, "gitSource": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#GitSource`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `restoreOption` | ``enum (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#RestoreOption`)`` Agent restore mode. If not specified, `KEEP` is assumed. |
| Required. The agent to restore. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `agentUri` | `string` The [Google Cloud Storage](https://cloud.google.com/storage/docs/) URI to restore agent from. The format of this URI must be `gs://<bucket-name>/<object-name>`. Dialogflow performs a read operation for the Cloud Storage object on the caller's behalf, so your request authentication must have read permissions for the object. For more information, see [Dialogflow access control](https://cloud.google.com/dialogflow/cx/docs/concept/access-control#storage). |
| `agentContent` | `string (https://developers.google.com/discovery/v1/type-format format)` Uncompressed raw byte content for agent. A base64-encoded string. |
| `gitSource` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore#GitSource`)`` Setting for restoring from a git branch |
| End of mutually exclusive fields. ||

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.operations#Operation`.

### 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).

## GitSource

Settings for restoring from a git branch

| JSON representation |
|---|
| ``` { "trackingBranch": string } ``` |

| Fields ||
|---|---|
| `trackingBranch` | `string` tracking branch for the git pull |

## RestoreOption

Restore option.

| Enums ||
|---|---|
| `RESTORE_OPTION_UNSPECIFIED` | Unspecified. Treated as KEEP. |
| `KEEP` | Always respect the settings from the exported agent file. It may cause a restoration failure if some settings (e.g. model type) are not supported in the target agent. |
| `FALLBACK` | Fallback to default settings if some settings are not supported in the target agent. |