CreateCustomAgent

Updated at:

Create a custom agent in your personal space or a workspace.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dms:CreateCustomAgent

create

*All Resource

*

None None

Request syntax

POST  HTTP/1.1

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

Agent测试名称

Description

string

No

The description of the custom agent.

Agent测试描述

DataJson

string

No

The data range, specified as a JSON string.

  • General parameters
    • tableFlag: Set to true to specify a data range.

    • scope: The value must be personal.

    • personal: Contains the parameters for a file or database.

File type: Use the following parameters.

  • DataSourceType: The value must be remote_data_center.

  • FileId: The ID of the file.

  • Database: The name of the database returned by the ListDataCenterTable operation. This is typically the file name.

  • Tables: The names of the tables returned by the ListDataCenterTable operation.

  • TableIds: The table IDs 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: Use the following parameters.

  • DataSourceType: The value must be database.

  • DmsInstanceId: The ID of the DMS instance returned by the data center API.

  • DmsDatabaseId: The ID of the DMS database returned by the data center API.

  • FileId: The instance name. This parameter is deprecated.

  • DbName: The name of the database returned by the data center API.

  • Database: The name of the database returned by the data center API.

  • Tables: The names of the tables returned by the data center API.

  • TableIds: The table IDs returned by the data center API.

  • Engine: The database engine. Valid values: mysql and 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"
  }
}

{ "tableFlag" : true, "scope" : "personal", "personal" : { "DataSourceType" : "remote_data_center", "FileId" : "f-5qlrwaw10********s3gpw1z", "Database" : "测试表格******.xlsx", "Tables" : [ "Sheet1" ], "TableIds" : [ "******" ], "RegionId" : "cn-hangzhou" } }

Instruction

string

No

The instruction for the custom agent.

  • Maximum length: 10,000 characters.

核心指标定义: 1、GMV(成交总额)指订单金额总和,含已支付及未支付成功订单; 2、订单量为每日有效下单笔数; 3、UV(独立访客)指访问网站或APP的去重用户数; 4、转化率=支付订单数 / UV,反映流量转化效率;

Knowledge

string

No

The knowledge for the custom agent.

  • Maximum length: 10,000 characters.

核心指标定义: 1、GMV(成交总额)指订单金额总和,含已支付及未支付成功订单; 2、订单量为每日有效下单笔数; 3、UV(独立访客)指访问网站或APP的去重用户数; 4、转化率=支付订单数 / UV,反映流量转化效率;

KnowledgeConfigList

array<object>

No

A list of external knowledge bases.

object

No

The structure of an external knowledge base.

AccessType

string

No

The access type.

  • mcp: Access via an MCP server.

Valid values:

  • mcp :

    Access via an MCP server.

mcp

McpServerId

string

No

The ID of the MCP server.

nhdpt9adf6ac**********ca

KbUuid

string

No

ExecutionConfig

object

No

The execution configuration.

SkipPlan

boolean

No

Specifies whether to skip the plan confirmation step.

true

SkipSqlConfirm

boolean

No

Specifies whether to skip all SQL confirmation steps.

true

SkipWebReportConfirm

boolean

No

Specifies whether to skip the web report confirmation step.

true

SkipAskHuman

boolean

No

Specifies whether to skip asking the user for input during execution.

true

ScheduleTaskConfig

object

No

The configuration for the scheduled task.

RelatedSessionId

string

No

The ID of a previous session to use for reference.

4m24*****mg7j2v

CronExpression

string

No

The cron expression for the scheduled task.

0 0 0 ? * 1-7

Query

string

No

The query for the scheduled task.

分析一下这份数据,给出简报

TextReportConfig

string

No

The formatting requirements for the text report.

文字报告要求所有数字不使用阿拉伯数字,全部转为中文数字

WebReportConfig

string

No

The formatting requirements for the web report.

网页报告要求所有数字不使用阿拉伯数字,全部转为中文数字

DMSUnit

string

No

The ID of the DMS unit.

cn-hangzhou

CallbackConfig

object

No

Type

string

No

ToolId

string

No

CallbackPrompt

string

No

CallbackArgs

string

No

CallbackTime

integer

No

Response elements

Element

Type

Description

Example

object

The response schema.

RequestId

string

The request ID.

67E910F2-4B62-5B0C-ACA3-7547695C****

Success

boolean

Indicates whether the request was successful. Valid values:

  • true: The request was successful.

  • false: The request failed.

true

ErrorCode

string

The error code.

success

ErrorMessage

string

The error message returned if the request fails.

Specified parameter Tid is not valid.

Data

object

The response data.

CustomAgentId

string

The custom agent ID.

ca-4y3ca4khkcu**********ysf

Name

string

The name of the custom agent.

Agent测试名称

Description

string

The description of the custom agent.

Agent测试描述

DataJson

string

The specified data scope, in a JSON string format.

{ "tableFlag" : true, "scope" : "personal", "personal" : { "DataSourceType" : "remote_data_center", "FileId" : "f-5qlrwaw10********s3gpw1z", "Database" : "测试表格******.xlsx", "Tables" : [ "Sheet1" ], "TableIds" : [ "******" ], "RegionId" : "cn-hangzhou" } }

Instruction

string

The instruction for the agent.

分析框架: 1、需按日、周、月维度监控核心指标(GMV、订单量、UV、转化率),分析趋势变化及同比/环比波动; 2、划分新老客、渠道、地域进行拆解,识别增长来源与短板; 3、结合用户行为路径(浏览→加购→支付)开展漏斗分析,定位流失环节;

Knowledge

string

The knowledge for the agent.

核心指标定义: 1、GMV(成交总额)指订单金额总和,含已支付及未支付成功订单; 2、订单量为每日有效下单笔数; 3、UV(独立访客)指访问网站或APP的去重用户数; 4、转化率=支付订单数 / UV,反映流量转化效率;

Status

string

The status of the custom agent.

Valid values:

  • NEW :

    The agent is created but not yet published.

  • RELEASED :

    The agent is published.

  • DRAFT :

    The agent is an unpublished draft.

  • OFFLINE :

    The agent is offline.

NEW

ReleaseTime

string

The release time.

2025-12-11T14:04:32.000+00:00

OfflineTime

string

The offline time.

2025-12-11T14:04:32.000+00:00

Modifier

string

The ID of the user who last modified the agent.

20372822********

WorkspaceId

string

The workspace ID.

20923*****7291

Region

string

The region.

cn-hangzhou

AliyunUid

string

The Alibaba Cloud account ID.

20372822********

AliyunParentUid

string

The primary Alibaba Cloud account ID.

16738266********

DmsUnit

string

The current DMS unit.

cn-hangzhou

GmtCreated

string

The creation time.

2025-12-11T14:04:32.000+00:00

GmtModified

string

The modification time.

2025-12-11T14:04:32.000+00:00

KnowledgeConfigList

array<object>

A list of external knowledge bases.

object

The structure of the external knowledge base.

AccessType

string

The access method.

  • mcp: Connects using MCP.

Valid values:

  • mcp :

    Connect by using MCP.

mcp

McpServerId

string

The ID of the MCP server.

nhdpt9adf6ac**********ca

KbUuid

string

ExecutionConfig

object

The execution configuration.

SkipPlan

boolean

Indicates whether to skip the plan confirmation step.

true

SkipSqlConfirm

boolean

Indicates whether to skip all SQL confirmations.

true

SkipWebReportConfirm

boolean

Indicates whether to skip the web report generation confirmation.

true

SkipAskHuman

boolean

Indicates whether to prevent the agent from asking the user for clarification during execution.

true

TextReportConfig

string

The format of the text report.

文字报告要求所有数字不使用阿拉伯数字,全部转为中文数字

WebReportConfig

string

The format of the web report.

网页报告要求所有数字不使用阿拉伯数字,全部转为中文数字

CreatorUserName

string

The username of the creator.

HaoY*****

ModifierUserName

string

The username of the user who last modified the agent.

HaoY*****

DMSUnit

string

The current DMS unit.

cn-hangzhou

IsScheduleTask

boolean

Indicates whether a scheduled task is configured for the agent.

false

NextRuntime

integer

The next run time of the scheduled task, formatted as a UNIX timestamp.

  • Timestamp format

1767715200

ScheduleTaskConfig

object

The configuration of the scheduled task.

RelatedSessionId

string

The ID of a previous session to be used as a template for the scheduled task.

4m24*****mg7j2v

CronExpression

string

The cron expression for the scheduled task.

0 0 0 ? * 1-7

Query

string

The query for the scheduled task.

分析一下这份数据,给出简报

CallbackConfig

object

Type

string

ToolId

string

CallbackPrompt

string

CallbackArgs

string

CallbackTime

integer

RelatedSessionId

string

Examples

Success response

JSON format

{
  "RequestId": "67E910F2-4B62-5B0C-ACA3-7547695C****",
  "Success": true,
  "ErrorCode": "success",
  "ErrorMessage": "Specified parameter Tid is not valid.",
  "Data": {
    "CustomAgentId": "ca-4y3ca4khkcu**********ysf",
    "Name": "Agent测试名称",
    "Description": "Agent测试描述",
    "DataJson": "{\n  \"tableFlag\" : true,\n  \"scope\" : \"personal\",\n  \"personal\" : {\n    \"DataSourceType\" : \"remote_data_center\",\n    \"FileId\" : \"f-5qlrwaw10********s3gpw1z\",\n    \"Database\" : \"测试表格******.xlsx\",\n    \"Tables\" : [ \"Sheet1\" ],\n    \"TableIds\" : [ \"******\" ],\n    \"RegionId\" : \"cn-hangzhou\"\n  }\n}",
    "Instruction": "分析框架:\n1、需按日、周、月维度监控核心指标(GMV、订单量、UV、转化率),分析趋势变化及同比/环比波动;\n2、划分新老客、渠道、地域进行拆解,识别增长来源与短板;\n3、结合用户行为路径(浏览→加购→支付)开展漏斗分析,定位流失环节;",
    "Knowledge": "核心指标定义:\n1、GMV(成交总额)指订单金额总和,含已支付及未支付成功订单;\n2、订单量为每日有效下单笔数;\n3、UV(独立访客)指访问网站或APP的去重用户数;\n4、转化率=支付订单数 / UV,反映流量转化效率;",
    "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",
        "KbUuid": ""
      }
    ],
    "ExecutionConfig": {
      "SkipPlan": true,
      "SkipSqlConfirm": true,
      "SkipWebReportConfirm": true,
      "SkipAskHuman": true
    },
    "TextReportConfig": "文字报告要求所有数字不使用阿拉伯数字,全部转为中文数字",
    "WebReportConfig": "网页报告要求所有数字不使用阿拉伯数字,全部转为中文数字",
    "CreatorUserName": "HaoY*****",
    "ModifierUserName": "HaoY*****",
    "DMSUnit": "cn-hangzhou",
    "IsScheduleTask": false,
    "NextRuntime": 1767715200,
    "ScheduleTaskConfig": {
      "RelatedSessionId": "4m24*****mg7j2v",
      "CronExpression": "0 0 0 ? * 1-7",
      "Query": "分析一下这份数据,给出简报"
    },
    "CallbackConfig": {
      "Type": "",
      "ToolId": "",
      "CallbackPrompt": "",
      "CallbackArgs": "",
      "CallbackTime": 0
    },
    "RelatedSessionId": ""
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.