All Products
Search
Document Center

Data Management:CreateCustomAgent

Last Updated:Mar 31, 2026

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 Action element of a RAM policy statement.

  • Access level: The predefined access level for the API (create, list, get, update, or delete).

  • 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 the Resource element. For APIs without resource-level permissions, use * in the Resource element.

  • 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.

ActionAccess levelResource typeCondition keyDependent action
dms:CreateCustomAgentcreate*All Resource *NoneNone

Request syntax

POST HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample
WorkspaceIdstringNoThe ID of the workspace.56kv1pvl9uvt9\*\*\*\*\*\*\*\*\*\*bb
NamestringNoThe name of the custom agent.my-agent
DescriptionstringNoThe description of the custom agent.Data analysis agent
DataJsonstringNoThe data range for the agent, in JSON string format. See the DataJson structure section below.
InstructionstringNoThe instruction for the agent. Maximum length: 10,000 characters.
KnowledgestringNoThe background knowledge for the agent. Maximum length: 10,000 characters.
KnowledgeConfigListarray\<object\>NoThe external knowledge base configuration.
AccessTypestringNoThe access type for the knowledge base entry. Valid value: mcp (access through MCP).mcp
McpServerIdstringNoThe ID of the MCP server.nhdpt9adf6ac\*\*\*\*\*\*\*\*\*\*ca
ExecutionConfigobjectNoThe execution configuration.
SkipPlanbooleanNoWhether to skip the plan confirmation step.true
SkipSqlConfirmbooleanNoWhether to skip all SQL confirmations.true
SkipWebReportConfirmbooleanNoWhether to skip the web report generation confirmation.true
SkipAskHumanbooleanNoWhether to prohibit user inquiries during the process.true
ScheduleTaskConfigobjectNoThe configuration for the auto triggered task.
RelatedSessionIdstringNoThe ID of the historical session to use as reference.4m24\*\*\*\*\*mg7j2v
CronExpressionstringNoThe cron expression for the recurring schedule.0 0 0 ? \* 1-7
QuerystringNoThe query for the auto triggered task.
TextReportConfigstringNoThe format requirements for the text report.
WebReportConfigstringNoThe format requirements for the web report.
DMSUnitstringNoThe 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:

ParameterTypeDescription
tableFlagbooleanSet to true to restrict the agent to the specified data range.
scopestringFixed to personal.
DataSourceTypestringThe data source type. Valid values: remote_data_center (file), database.

File type (DataSourceType: "remote_data_center")

Pass the following parameters inside the personal object:

ParameterDescription
FileIdThe file ID.
DatabaseThe database name returned by the ListDataCenterTable operation (usually the file name).
TablesThe table name returned by the ListDataCenterTable operation.
TableIdsThe table ID returned by the ListDataCenterTable operation.
RegionIdThe 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:

ParameterDescription
DmsInstanceIdThe DMS instance ID returned by the data center API.
DmsDatabaseIdThe DMS database ID returned by the data center API.
FileIdThe instance name. This parameter is deprecated.
DbNameThe database name returned by the data center API.
DatabaseThe database name returned by the data center API.
TablesThe table name returned by the data center API.
TableIdsThe table ID returned by the data center API.
EngineThe database engine type, such as mysql or postgresql.
RegionIdThe 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

ElementTypeDescriptionExample
RequestIdstringThe ID of the request.67E910F2-4B62-5B0C-ACA3-7547695C\*\*\*\*
SuccessbooleanWhether the request was successful. Valid values: true, false.true
ErrorCodestringThe error code.success
ErrorMessagestringThe error message returned when the request fails.Specified parameter Tid is not valid.
DataobjectThe returned data.
CustomAgentIdstringThe ID of the custom agent.ca-4y3ca4khkcu\*\*\*\*\*\*\*\*\*\*ysf
NamestringThe name of the custom agent.my-agent
DescriptionstringThe description of the custom agent.Data analysis agent
DataJsonstringThe data range, in JSON string format.
InstructionstringThe instruction for the agent.
KnowledgestringThe background knowledge for the agent.
StatusstringThe status of the custom agent. Valid values: NEW (created, not published), RELEASED (published), DRAFT (draft, not published), OFFLINE (unpublished).NEW
ReleaseTimestringThe time when the agent was published, in ISO 8601 format.2025-12-11T14:04:32.000+00:00
OfflineTimestringThe time when the agent was unpublished, in ISO 8601 format.2025-12-11T14:04:32.000+00:00
GmtCreatedstringThe time when the agent was created, in ISO 8601 format.2025-12-11T14:04:32.000+00:00
GmtModifiedstringThe time when the agent was last modified, in ISO 8601 format.2025-12-11T14:04:32.000+00:00
ModifierstringThe Alibaba Cloud account ID of the user who last modified the agent.20372822\*\*\*\*\*\*\*\*
WorkspaceIdstringThe ID of the workspace.20923\*\*\*\*\*7291
RegionstringThe region where the agent resides.cn-hangzhou
AliyunUidstringThe Alibaba Cloud account ID of the agent owner.20372822\*\*\*\*\*\*\*\*
AliyunParentUidstringThe Alibaba Cloud account ID of the parent account.16738266\*\*\*\*\*\*\*\*
DmsUnitstringThe current DMS unit.cn-hangzhou
CreatorUserNamestringThe username of the user who created the agent.HaoY\*\*\*\*\*
ModifierUserNamestringThe username of the user who last modified the agent.HaoY\*\*\*\*\*
DMSUnitstringThe current DMS unit.cn-hangzhou
KnowledgeConfigListarray\<object\>The external knowledge base configuration.
AccessTypestringThe access type. Valid value: mcp (access through MCP).mcp
McpServerIdstringThe ID of the MCP server.nhdpt9adf6ac\*\*\*\*\*\*\*\*\*\*ca
ExecutionConfigobjectThe execution configuration.
SkipPlanbooleanWhether the plan confirmation step is skipped.true
SkipSqlConfirmbooleanWhether all SQL confirmations are skipped.true
SkipWebReportConfirmbooleanWhether the web report generation confirmation is skipped.true
SkipAskHumanbooleanWhether user inquiries are prohibited during the process.true
TextReportConfigstringThe format requirements for the text report.
WebReportConfigstringThe format requirements for the web report.
IsScheduleTaskbooleanWhether an auto triggered task is configured.false
NextRuntimeintegerThe next run time of the auto triggered task, in UNIX timestamp format.1767715200
ScheduleTaskConfigobjectThe configuration of the auto triggered task.
RelatedSessionIdstringThe ID of the historical session used as reference.4m24\*\*\*\*\*mg7j2v
CronExpressionstringThe cron expression for the recurring schedule.0 0 0 ? \* 1-7
QuerystringThe query for the auto triggered task.
CallbackConfigobjectThe callback configuration.
TypestringThe callback type.
ToolIdstringThe callback tool ID.
CallbackPromptstringThe callback prompt.
CallbackArgsstringThe callback arguments.
CallbackTimeintegerThe 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.