Cortex Agents REST API¶
Note
Requests to the Cortex Agent REST API time out after 15 minutes.
You can use the Cortex Agent REST API to create, manage, and interact with Cortex Agent Objects in your Snowflake account.
图表内容
POST /api/v2/databases/{database}/schemas/{schema}/agents
Creates a new Cortex Agent Object with the specified attributes and specification.
请求
路径参数
| Parameter | Description |
|---|---|
database | (Required) Your Snowflake Account URL. |
schema | (Required) Schema identifier. |
参数
| Parameter | Description |
|---|---|
createMode | (Optional) Resource creation mode. Valid values:
|
请求标头
| Header | Description |
|---|---|
Authorization | (Required) Authorization token. For more information, see Authentication. |
Content-Type | (Required) application/json |
请求正文
| Field | Type | Description |
|---|---|---|
name | string | Name of the agent. |
comment | string | Optional comment about the agent. |
profile | `AgentProfile` | Agent profile information (display name, avatar, color, etc.). |
models | `ModelConfig` | Model configuration for the agent. Includes the orchestration model
(e.g., claude-4-sonnet). If not provided, a model is automatically
selected. Currently only available for the |
instructions | `AgentInstructions` | Instructions for the agent’s behavior, including response, orchestration, and sample questions. |
orchestration | `OrchestrationConfig` | Orchestration configuration, including budget constraints (e.g., seconds, tokens). |
tools | array of `Tool` | List of tools available for the agent to use. Each tool includes a tool_spec with type, name, description, and input schema. Tools may have a corresponding configuration in tool_resources. |
tool_resources | map of `ToolResource` | Configuration for each tool referenced in the tools array. Keys must match the name of the respective tool. |
Example
响应
A successful response returns a JSON object with details about the status of Cortex Agent creation.
响应
Describe Cortex Agent¶
GET /api/v2/databases/{database}/schemas/{schema}/agents/{name}
Describes a Cortex Agent.
请求
路径参数
| Parameter | Description |
|---|---|
database | (Required) Identifier for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases. |
schema | (Required) Identifier for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database. |
name | (Required) Identifier for the agent. |
请求标头
| Header | Description |
|---|---|
Authorization | (Required) Authorization token. For more information, see Authentication. |
Content-Type | (Required) application/json |
响应
A successful response returns a JSON object describing the Cortex Agent.
请求标头
| Header | Description |
|---|---|
X-Snowflake-Request-ID | Unique ID of the API request. |
Link | Links to the page of results (e.g. the first page, the last page, etc.). The header can include multiple url entries with different rel attribute values that specify the page to return (first, next, prev, and last). |
响应
The response body contains the details of the Cortex Agent.
Update Cortex Agent¶
PUT /api/v2/databases/{database}/schemas/{schema}/agents/{name}
Updates an existing Cortex Agent with the specified attributes and specification.
请求
路径参数
| Parameter | Description |
|---|---|
database | (Required) Your Snowflake Account URL. You can use the /api/v2/databases GET request to get a list of available databases. |
schema | (Required) Schema identifier. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database. |
name | (Required) Name of the agent. |
请求标头
| Header | Description |
|---|---|
Authorization | (Required) Authorization token. For more information, see Authentication. |
Content-Type | (Required) application/json |
请求正文
| Field | Type | Description |
|---|---|---|
comment | string | Optional comment about the agent. |
profile | `AgentProfile` | Agent profile information (display name, avatar, color, etc.). |
models | `ModelConfig` | Model configuration for the agent. Includes the orchestration model
(e.g., claude-4-sonnet). If not provided, a model is automatically
selected. Currently only available for the |
instructions | `AgentInstructions` | Instructions for the agent’s behavior, including response, orchestration, and sample questions. |
orchestration | `OrchestrationConfig` | Orchestration configuration, including budget constraints (e.g., seconds, tokens). |
tools | array of `Tool` | List of tools available for the agent to use. Each tool includes a tool_spec with type, name, description, and input schema. Tools may have a corresponding configuration in tool_resources. |
tool_resources | map of `ToolResource` | Configuration for each tool referenced in the tools array. Keys must match the name of the respective tool. |
Example
响应
A successful response returns a JSON object with details about the status of Cortex Agent update.
响应
Cortex Agents REST API¶
GET /api/v2/databases/{database}/schemas/{schema}/agents
Lists the Cortex Agents under the specified database and schema.
请求
路径参数
| Parameter | Description |
|---|---|
database | (Required) Identifier for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases. |
schema | (Required) Identifier for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database. |
参数
| Parameter | Description |
|---|---|
like | (Optional) Filter the output by resource name. Uses case-insensitive pattern matching with support for SQL wildcard characters. |
fromName | (Optional) Enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name. |
showLimit | (Optional) Limit the maximum number of rows returned by the command. Minimum: 1. Maximum: 10000. |
请求标头
| Header | Description |
|---|---|
Authorization | (Required) Authorization token. For more information, see Authentication. |
Content-Type | (Required) application/json |
响应
A successful response returns a JSON array of Cortex Agent resources.
请求标头
| Header | Description |
|---|---|
X-Snowflake-Request-ID | Unique ID of the API request. |
Link | Links to the page of results (e.g. the first page, the last page, etc.). The header can include multiple url entries with different rel attribute values that specify the page to return (first, next, prev, and last). |
响应
Delete Cortex Agent¶
DELETE /api/v2/databases/{database}/schemas/{schema}/agents/{name}
Deletes a Cortex Agent with the specified name. If the ifExists parameter is set to true, the operation succeeds even if the agent does not exist. Otherwise, the operation fails if the agent cannot be deleted.
请求
路径参数
| Parameter | Description |
|---|---|
database | (Required) Identifier for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases. |
schema | (Required) Identifier for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database. |
name | (Required) Identifier for the agent. |
参数
| Parameter | Description |
|---|---|
ifExists | (Optional) Specifies how to handle the request if the agent does not exist.
|
请求标头
| Header | Description |
|---|---|
Authorization | (Required) Authorization token. For more information, see Authentication. |
Content-Type | (Required) application/json |
响应
A successful response returns a confirmation message.
响应
Schemas¶
AgentInstructions¶
| Field | Type | Description |
|---|---|---|
response | string | Instructions for response generation. |
orchestration | string | These custom instructions are used when the agent is planning which tools to use. |
Example
AgentProfile¶
The profile information for a Data Cortex agent.
| Field | Type | Description |
|---|---|---|
display_name | string | Display name for the agent. |
Example
BudgetConfig¶
| Field | Type | Description |
|---|---|---|
seconds | integer | Time budget in seconds. |
tokens | integer | Token budget. |
Example
ExecutionEnvironment¶
Configuration for server-executed tools.
| Field | Type | Description |
|---|---|---|
type | string | The type of execution environment, currently only |
warehouse | string | The name of the warehouse. Case-sensitive, if it is an unquoted identifier, provide the name in all-caps. |
query_timeout | integer | The query timeout in seconds |
Example
ModelConfig¶
| Field | Type | Description |
|---|---|---|
orchestration | string | Model to use for orchestration. If not provided, a model is automatically selected. |
Example
OrchestrationConfig¶
| Field | Type | Description |
|---|---|---|
budget | `BudgetConfig` | Budget constraints for the agent. If more than one constraint is specified, whichever is first hit will end the request. |
Example
Tool¶
Defines a tool that can be used by the agent. Tools provide specific capabilities like data analysis, search, or generic functions.
| Field | Type | Description |
|---|---|---|
tool_spec | `ToolSpec` | Specification of the tool’s type, configuration, and input requirements. |
Example
ToolInputSchema¶
| Field | Type | Description |
|---|---|---|
type | string | The type of the input schema object. |
description | string | A description of what the input is. |
properties | map of `ToolInputSchema` | If type is object, definitions of each input parameter. |
items | `ToolInputSchema` | If type is array, the schema for the elements of the array. |
required | array of string | If type is object, list of required input parameter names. |
Example
ToolResource¶
Configuration for text-to-SQL analysis tool. Provides parameters for SQL query generation and execution. Exactly one of semantic_model_file or semantic_view must be provided.
Field Type Description semantic_model_filestring The path to a file stored in a Snowflake Stage holding the semantic model yaml.
semantic_viewstring The name of the Snowflake native semantic model object. execution_environment`ExecutionEnvironment` Configuration for how to execute the generated SQL query. Example
Configuration for search functionality. Defines how document search and retrieval should be performed.
Field Type Description search_servicestring The fully qualified name of the search service. title_columnstring The title column of the document. id_columnstring The ID column of the document. filterobject Filter query for search results. Example
Field Type Description typestring If the tool is server-side executed, whether it is a Stored Procedure or a UDF.
execution_environment`ExecutionEnvironment` identifierstring Fully qualified name of the Stored Procedure or UDF. Example
Configuration for web search functionality.
Field Type Description max_resultsinteger Max web search results returned. Example
ToolSpec¶
Specification of the tool’s type, configuration, and input requirements.
| Field | Type | Description |
|---|---|---|
type | string | The type of tool capability. Can be specialized types like ‘cortex_analyst_text_to_sql’ or ‘generic’ for general-purpose tools. |
name | string | Unique identifier for referencing this tool instance. Used to match with configuration in tool_resources. |
description | string | Description of the tool to be considered for tool use. |
input_schema | `ToolInputSchema` | JSON Schema definition of the expected input parameters for this tool. This will be fed to the agent so it knows the structure it should follow for when generating the input for ToolUses. Required for generic tools to specify their input parameters. |
Example