Creates a custom agent in your personal space or a workspace.
RAM authorization
To call this API, grant the required permissions in a Resource Access Management (RAM) policy.
Action: The value to use in the
Actionelement of a RAM policy statement.Access level: The predefined access level for the API (
create,list,get,update, ordelete).Resource type: The resource type that supports authorization. Required resource types are marked with an asterisk (
*); use the corresponding Alibaba Cloud Resource Name (ARN) in theResourceelement. For APIs without resource-level permissions, use*in theResourceelement.Condition key: Service-specific condition keys for granular access control. Alibaba Cloud also provides common condition keys applicable to all RAM-supported services.
Dependent action: Additional actions the RAM user or role must be authorized to perform.
| Action | Access level | Resource type | Condition key | Dependent action |
|---|---|---|---|---|
| dms:CreateCustomAgent | create | *All Resource * | None | None |
Request syntax
POST HTTP/1.1Request parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| WorkspaceId | string | No | The ID of the workspace. | 56kv1pvl9uvt9\*\*\*\*\*\*\*\*\*\*bb |
| Name | string | No | The name of the custom agent. | my-agent |
| Description | string | No | The description of the custom agent. | Data analysis agent |
| DataJson | string | No | The data range for the agent, in JSON string format. See the DataJson structure section below. | — |
| Instruction | string | No | The instruction for the agent. Maximum length: 10,000 characters. | — |
| Knowledge | string | No | The background knowledge for the agent. Maximum length: 10,000 characters. | — |
| KnowledgeConfigList | array\<object\> | No | The external knowledge base configuration. | — |
| AccessType | string | No | The access type for the knowledge base entry. Valid value: mcp (access through MCP). | mcp |
| McpServerId | string | No | The ID of the MCP server. | nhdpt9adf6ac\*\*\*\*\*\*\*\*\*\*ca |
| ExecutionConfig | object | No | The execution configuration. | — |
| SkipPlan | boolean | No | Whether to skip the plan confirmation step. | true |
| SkipSqlConfirm | boolean | No | Whether to skip all SQL confirmations. | true |
| SkipWebReportConfirm | boolean | No | Whether to skip the web report generation confirmation. | true |
| SkipAskHuman | boolean | No | Whether to prohibit user inquiries during the process. | true |
| ScheduleTaskConfig | object | No | The configuration for the auto triggered task. | — |
| RelatedSessionId | string | No | The ID of the historical session to use as reference. | 4m24\*\*\*\*\*mg7j2v |
| CronExpression | string | No | The cron expression for the recurring schedule. | 0 0 0 ? \* 1-7 |
| Query | string | No | The query for the auto triggered task. | — |
| TextReportConfig | string | No | The format requirements for the text report. | — |
| WebReportConfig | string | No | The format requirements for the web report. | — |
| DMSUnit | string | No | The current DMS unit. | cn-hangzhou |
DataJson structure
DataJson is a JSON string that defines the agent's data range. All data source configurations use the following common parameters:
| Parameter | Type | Description |
|---|---|---|
| tableFlag | boolean | Set to true to restrict the agent to the specified data range. |
| scope | string | Fixed to personal. |
| DataSourceType | string | The data source type. Valid values: remote_data_center (file), database. |
File type (DataSourceType: "remote_data_center")
Pass the following parameters inside the personal object:
| Parameter | Description |
|---|---|
| FileId | The file ID. |
| Database | The database name returned by the ListDataCenterTable operation (usually the file name). |
| Tables | The table name returned by the ListDataCenterTable operation. |
| TableIds | The table ID returned by the ListDataCenterTable operation. |
| RegionId | The current region. |
{
"tableFlag": true,
"scope": "personal",
"personal": {
"DataSourceType": "remote_data_center",
"FileId": "f-f0jksn001ibmkoo********6v2zn6",
"Database": "diamonds.csv",
"Tables": [
"diamonds"
],
"TableIds": [
"35hfn94pxl********50pi"
],
"RegionId": "cn-hangzhou"
}
}Database type (DataSourceType: "database")
Pass the following parameters inside the personal object:
| Parameter | Description |
|---|---|
| DmsInstanceId | The DMS instance ID returned by the data center API. |
| DmsDatabaseId | The DMS database ID returned by the data center API. |
| FileId | The instance name. This parameter is deprecated. |
| DbName | The database name returned by the data center API. |
| Database | The database name returned by the data center API. |
| Tables | The table name returned by the data center API. |
| TableIds | The table ID returned by the data center API. |
| Engine | The database engine type, such as mysql or postgresql. |
| RegionId | The current region. |
{
"tableFlag": true,
"scope": "personal",
"personal": {
"DataSourceType": "database",
"DmsInstanceId": "284***8",
"DmsDatabaseId": "769***45",
"FileId": "pgm-bp15095e*******6t",
"DbName": "pg_catalog",
"Database": "pg_catalog",
"Tables": [
"pg_aggregate"
],
"TableIds": [
"5263****31"
],
"Engine": "postgresql",
"RegionId": "cn-hangzhou"
}
}Response elements
| Element | Type | Description | Example |
|---|---|---|---|
| RequestId | string | The ID of the request. | 67E910F2-4B62-5B0C-ACA3-7547695C\*\*\*\* |
| Success | boolean | Whether the request was successful. Valid values: true, false. | true |
| ErrorCode | string | The error code. | success |
| ErrorMessage | string | The error message returned when the request fails. | Specified parameter Tid is not valid. |
| Data | object | The returned data. | — |
| CustomAgentId | string | The ID of the custom agent. | ca-4y3ca4khkcu\*\*\*\*\*\*\*\*\*\*ysf |
| Name | string | The name of the custom agent. | my-agent |
| Description | string | The description of the custom agent. | Data analysis agent |
| DataJson | string | The data range, in JSON string format. | — |
| Instruction | string | The instruction for the agent. | — |
| Knowledge | string | The background knowledge for the agent. | — |
| Status | string | The status of the custom agent. Valid values: NEW (created, not published), RELEASED (published), DRAFT (draft, not published), OFFLINE (unpublished). | NEW |
| ReleaseTime | string | The time when the agent was published, in ISO 8601 format. | 2025-12-11T14:04:32.000+00:00 |
| OfflineTime | string | The time when the agent was unpublished, in ISO 8601 format. | 2025-12-11T14:04:32.000+00:00 |
| GmtCreated | string | The time when the agent was created, in ISO 8601 format. | 2025-12-11T14:04:32.000+00:00 |
| GmtModified | string | The time when the agent was last modified, in ISO 8601 format. | 2025-12-11T14:04:32.000+00:00 |
| Modifier | string | The Alibaba Cloud account ID of the user who last modified the agent. | 20372822\*\*\*\*\*\*\*\* |
| WorkspaceId | string | The ID of the workspace. | 20923\*\*\*\*\*7291 |
| Region | string | The region where the agent resides. | cn-hangzhou |
| AliyunUid | string | The Alibaba Cloud account ID of the agent owner. | 20372822\*\*\*\*\*\*\*\* |
| AliyunParentUid | string | The Alibaba Cloud account ID of the parent account. | 16738266\*\*\*\*\*\*\*\* |
| DmsUnit | string | The current DMS unit. | cn-hangzhou |
| CreatorUserName | string | The username of the user who created the agent. | HaoY\*\*\*\*\* |
| ModifierUserName | string | The username of the user who last modified the agent. | HaoY\*\*\*\*\* |
| DMSUnit | string | The current DMS unit. | cn-hangzhou |
| KnowledgeConfigList | array\<object\> | The external knowledge base configuration. | — |
| AccessType | string | The access type. Valid value: mcp (access through MCP). | mcp |
| McpServerId | string | The ID of the MCP server. | nhdpt9adf6ac\*\*\*\*\*\*\*\*\*\*ca |
| ExecutionConfig | object | The execution configuration. | — |
| SkipPlan | boolean | Whether the plan confirmation step is skipped. | true |
| SkipSqlConfirm | boolean | Whether all SQL confirmations are skipped. | true |
| SkipWebReportConfirm | boolean | Whether the web report generation confirmation is skipped. | true |
| SkipAskHuman | boolean | Whether user inquiries are prohibited during the process. | true |
| TextReportConfig | string | The format requirements for the text report. | — |
| WebReportConfig | string | The format requirements for the web report. | — |
| IsScheduleTask | boolean | Whether an auto triggered task is configured. | false |
| NextRuntime | integer | The next run time of the auto triggered task, in UNIX timestamp format. | 1767715200 |
| ScheduleTaskConfig | object | The configuration of the auto triggered task. | — |
| RelatedSessionId | string | The ID of the historical session used as reference. | 4m24\*\*\*\*\*mg7j2v |
| CronExpression | string | The cron expression for the recurring schedule. | 0 0 0 ? \* 1-7 |
| Query | string | The query for the auto triggered task. | — |
| CallbackConfig | object | The callback configuration. | — |
| Type | string | The callback type. | — |
| ToolId | string | The callback tool ID. | — |
| CallbackPrompt | string | The callback prompt. | — |
| CallbackArgs | string | The callback arguments. | — |
| CallbackTime | integer | The callback time. | — |
Examples
Success response
{
"RequestId": "67E910F2-4B62-5B0C-ACA3-7547695C****",
"Success": true,
"ErrorCode": "success",
"ErrorMessage": "Specified parameter Tid is not valid.",
"Data": {
"CustomAgentId": "ca-4y3ca4khkcu**********ysf",
"Name": "my-agent",
"Description": "Data analysis agent",
"DataJson": "{\n \"tableFlag\" : true,\n \"scope\" : \"personal\",\n \"personal\" : {\n \"DataSourceType\" : \"remote_data_center\",\n \"FileId\" : \"f-5qlrwaw10********s3gpw1z\",\n \"Database\" : \"sales-data.xlsx\",\n \"Tables\" : [ \"Sheet1\" ],\n \"TableIds\" : [ \"******\" ],\n \"RegionId\" : \"cn-hangzhou\"\n }\n}",
"Instruction": "Analyze key metrics across daily, weekly, and monthly dimensions.",
"Knowledge": "GMV = total order value, including paid and unpaid orders.",
"Status": "NEW",
"ReleaseTime": "2025-12-11T14:04:32.000+00:00",
"OfflineTime": "2025-12-11T14:04:32.000+00:00",
"Modifier": "20372822********",
"WorkspaceId": "20923*****7291",
"Region": "cn-hangzhou",
"AliyunUid": "20372822********",
"AliyunParentUid": "16738266********",
"DmsUnit": "cn-hangzhou",
"GmtCreated": "2025-12-11T14:04:32.000+00:00",
"GmtModified": "2025-12-11T14:04:32.000+00:00",
"KnowledgeConfigList": [
{
"AccessType": "mcp",
"McpServerId": "nhdpt9adf6ac**********ca"
}
],
"ExecutionConfig": {
"SkipPlan": true,
"SkipSqlConfirm": true,
"SkipWebReportConfirm": true,
"SkipAskHuman": true
},
"TextReportConfig": "Do not use Arabic numerals in the text report; convert all numbers to Chinese numerals.",
"WebReportConfig": "Do not use Arabic numerals in the web report; convert all numbers to Chinese numerals.",
"CreatorUserName": "HaoY*****",
"ModifierUserName": "HaoY*****",
"DMSUnit": "cn-hangzhou",
"IsScheduleTask": false,
"NextRuntime": 1767715200,
"ScheduleTaskConfig": {
"RelatedSessionId": "4m24*****mg7j2v",
"CronExpression": "0 0 0 ? * 1-7",
"Query": "Analyze this dataset and produce a summary report."
},
"CallbackConfig": {
"Type": "",
"ToolId": "",
"CallbackPrompt": "",
"CallbackArgs": "",
"CallbackTime": 0
}
}
}Error codes
See Error codes for a complete list.
Release notes
See Release notes for a complete list.