---
title: "POST /v1/{+parent}/agents"
method: POST
path: "/v1/{+parent}/agents"
tags: ["projects"]
---

# POST /v1/{+parent}/agents

`POST /v1/{+parent}/agents`

Creates a new agent in the given app.

## Path parameters

- `parent` string, required

## Query parameters

- `agentId` string

## Request body

- Agent — An agent acts as the fundamental building block that provides instructions to the Large Language Model (LLM) for executing specific tasks.
  - `beforeToolCallbacks` Callback[] — Optional. The callbacks to execute before the tool is invoked. If there are multiple tool invocations, the callback will be executed multiple times. The provided callbacks are executed sequentially in the exact order they are given in the list. If a callback returns an overridden response, execution stops and any remaining callbacks are skipped.
    - `pythonCode` string — Required. The python code to execute for the callback.
    - `description` string — Optional. Human-readable description of the callback.
    - `disabled` boolean — Optional. Whether the callback is disabled. Disabled callbacks are ignored by the agent.
    - `proactiveExecutionEnabled` boolean — Optional. If enabled, the callback will also be executed on intermediate model outputs. This setting only affects after model callback. **ENABLE WITH CAUTION**. Typically after model callback only needs to be executed after receiving all model responses. Enabling proactive execution may have negative implication on the execution cost and latency, and should only be enabled in rare situations.
  - `tools` string[] — Optional. List of available tools for the agent. Format: `projects/{project}/locations/{location}/apps/{app}/tools/{tool}`
  - `afterModelCallbacks` Callback[] — Optional. The callbacks to execute after the model is called. If there are multiple calls to the model, the callback will be executed multiple times. The provided callbacks are executed sequentially in the exact order they are given in the list. If a callback returns an overridden response, execution stops and any remaining callbacks are skipped.
    - `pythonCode` string — Required. The python code to execute for the callback.
    - `description` string — Optional. Human-readable description of the callback.
    - `disabled` boolean — Optional. Whether the callback is disabled. Disabled callbacks are ignored by the agent.
    - `proactiveExecutionEnabled` boolean — Optional. If enabled, the callback will also be executed on intermediate model outputs. This setting only affects after model callback. **ENABLE WITH CAUTION**. Typically after model callback only needs to be executed after receiving all model responses. Enabling proactive execution may have negative implication on the execution cost and latency, and should only be enabled in rare situations.
  - `etag` string — Etag used to ensure the object hasn't changed during a read-modify-write operation. If the etag is empty, the update will overwrite any concurrent changes.
  - `generatedSummary` string — Output only. If the agent is generated by the LLM assistant, this field contains a descriptive summary of the generation.
  - `childAgents` string[] — Optional. List of child agents in the agent tree. Format: `projects/{project}/locations/{location}/apps/{app}/agents/{agent}`
  - `afterAgentCallbacks` Callback[] — Optional. The callbacks to execute after the agent is called. The provided callbacks are executed sequentially in the exact order they are given in the list. If a callback returns an overridden response, execution stops and any remaining callbacks are skipped.
    - `pythonCode` string — Required. The python code to execute for the callback.
    - `description` string — Optional. Human-readable description of the callback.
    - `disabled` boolean — Optional. Whether the callback is disabled. Disabled callbacks are ignored by the agent.
    - `proactiveExecutionEnabled` boolean — Optional. If enabled, the callback will also be executed on intermediate model outputs. This setting only affects after model callback. **ENABLE WITH CAUTION**. Typically after model callback only needs to be executed after receiving all model responses. Enabling proactive execution may have negative implication on the execution cost and latency, and should only be enabled in rare situations.
  - `beforeModelCallbacks` Callback[] — Optional. The callbacks to execute before the model is called. If there are multiple calls to the model, the callback will be executed multiple times. The provided callbacks are executed sequentially in the exact order they are given in the list. If a callback returns an overridden response, execution stops and any remaining callbacks are skipped.
    - `pythonCode` string — Required. The python code to execute for the callback.
    - `description` string — Optional. Human-readable description of the callback.
    - `disabled` boolean — Optional. Whether the callback is disabled. Disabled callbacks are ignored by the agent.
    - `proactiveExecutionEnabled` boolean — Optional. If enabled, the callback will also be executed on intermediate model outputs. This setting only affects after model callback. **ENABLE WITH CAUTION**. Typically after model callback only needs to be executed after receiving all model responses. Enabling proactive execution may have negative implication on the execution cost and latency, and should only be enabled in rare situations.
  - `validationErrors` string[] — Output only. Misconfigurations or errors in the agent that may affect agent quality.
  - `llmAgent` AgentLlmAgent — Default agent type. The agent uses instructions and callbacks specified in the agent to perform the task using a large language model.
  - `displayName` string — Required. Display name of the agent.
  - `guardrails` string[] — Optional. List of guardrails for the agent. Format: `projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail}`
  - `transferRules` TransferRule[] — Optional. Agent transfer rules. If multiple rules match, the first one in the list will be used.
    - `childAgent` string — Required. The resource name of the child agent the rule applies to. Format: `projects/{project}/locations/{location}/apps/{app}/agents/{agent}`
    - `direction` 'DIRECTION_UNSPECIFIED' | 'PARENT_TO_CHILD' | 'CHILD_TO_PARENT' — Required. The direction of the transfer.
    - `deterministicTransfer` TransferRuleDeterministicTransfer — Deterministic transfer rule. When the condition evaluates to true, the transfer occurs.
      - `pythonCodeCondition` PythonCodeCondition — Python code block to evaluate the condition.
        - `pythonCode` string — Required. The python code to execute.
      - `expressionCondition` ExpressionCondition — Expression condition based on session state.
        - `expression` string — Required. The string representation of cloud.api.Expression condition.
    - `disablePlannerTransfer` TransferRuleDisablePlannerTransfer — A rule that prevents the planner from transferring to the target agent.
      - `expressionCondition` ExpressionCondition — Expression condition based on session state.
        - `expression` string — Required. The string representation of cloud.api.Expression condition.
  - `instruction` string — Optional. Instructions for the LLM model to guide the agent's behavior.
  - `beforeAgentCallbacks` Callback[] — Optional. The callbacks to execute before the agent is called. The provided callbacks are executed sequentially in the exact order they are given in the list. If a callback returns an overridden response, execution stops and any remaining callbacks are skipped.
    - `pythonCode` string — Required. The python code to execute for the callback.
    - `description` string — Optional. Human-readable description of the callback.
    - `disabled` boolean — Optional. Whether the callback is disabled. Disabled callbacks are ignored by the agent.
    - `proactiveExecutionEnabled` boolean — Optional. If enabled, the callback will also be executed on intermediate model outputs. This setting only affects after model callback. **ENABLE WITH CAUTION**. Typically after model callback only needs to be executed after receiving all model responses. Enabling proactive execution may have negative implication on the execution cost and latency, and should only be enabled in rare situations.
  - `toolsets` AgentAgentToolset[] — Optional. List of toolsets for the agent.
    - `toolIds` string[] — Optional. The tools IDs to filter the toolset.
    - `toolset` string — Required. The resource name of the toolset. Format: `projects/{project}/locations/{location}/apps/{app}/toolsets/{toolset}`
  - `modelSettings` ModelSettings — Model settings contains various configurations for the LLM model.
    - `temperature` number, double — Optional. If set, this temperature will be used for the LLM model. Temperature controls the randomness of the model's responses. Lower temperatures produce responses that are more predictable. Higher temperatures produce responses that are more creative.
    - `model` string — Optional. The LLM model that the agent should use. If not set, the agent will inherit the model from its parent agent.
  - `description` string — Optional. Human-readable description of the agent.
  - `remoteDialogflowAgent` AgentRemoteDialogflowAgent — The agent which will transfer execution to a remote [Dialogflow CX](https://docs.cloud.google.com/dialogflow/cx/docs/concept/agent) agent. The Dialogflow agent will process subsequent user queries until the session ends or flow ends, and the control is transferred back to the parent CES agent.
    - `inputVariableMapping` object — Optional. The mapping of the app variables names to the Dialogflow session parameters names to be sent to the Dialogflow agent as input.
    - `agent` string — Required. The [Dialogflow](https://docs.cloud.google.com/dialogflow/cx/docs/concept/agent) agent resource name. Format: `projects/{project}/locations/{location}/agents/{agent}`
    - `flowId` string — Optional. The flow ID of the flow in the Dialogflow agent.
    - `languageCodeVariable` string — Optional. The name of the variable that contains the language code to be used for the Dialogflow session. If unspecified, the default language code of the Dialogflow agent will be used.
    - `respectResponseInterruptionSettings` boolean — Optional. Indicates whether to respect the message-level interruption settings configured in the Dialogflow agent. * If false: all response messages from the Dialogflow agent follow the app-level barge-in settings. * If true: only response messages with [`allow_playback_interruption`](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rpc/google.cloud.dialogflow.cx.v3#text) set to true will be interruptable, all other messages follow the app-level barge-in settings.
    - `environmentId` string — Optional. The environment ID of the Dialogflow agent to be used for the agent execution. If not specified, the draft environment will be used.
    - `outputVariableMapping` object — Optional. The mapping of the Dialogflow session parameters names to the app variables names to be sent back to the CES agent after the Dialogflow agent execution ends.
  - `createTime` string, google-datetime — Output only. Timestamp when the agent was created.
  - `updateTime` string, google-datetime — Output only. Timestamp when the agent was last updated.
  - `name` string — Identifier. The unique identifier of the agent. Format: `projects/{project}/locations/{location}/apps/{app}/agents/{agent}`
  - `afterToolCallbacks` Callback[] — Optional. The callbacks to execute after the tool is invoked. If there are multiple tool invocations, the callback will be executed multiple times. The provided callbacks are executed sequentially in the exact order they are given in the list. If a callback returns an overridden response, execution stops and any remaining callbacks are skipped.
    - `pythonCode` string — Required. The python code to execute for the callback.
    - `description` string — Optional. Human-readable description of the callback.
    - `disabled` boolean — Optional. Whether the callback is disabled. Disabled callbacks are ignored by the agent.
    - `proactiveExecutionEnabled` boolean — Optional. If enabled, the callback will also be executed on intermediate model outputs. This setting only affects after model callback. **ENABLE WITH CAUTION**. Typically after model callback only needs to be executed after receiving all model responses. Enabling proactive execution may have negative implication on the execution cost and latency, and should only be enabled in rare situations.

## Response `200`

Successful response

---

[API](https://skmtc.net/google/apis/ces.md) · [All operations](https://skmtc.net/google/apis/ces/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/ces/versions/429598666166/schema)
