CreateDataAgent

Updated at:

Creates a DataAgent and binds a RAM role for accessing resources in your account and the context models to be associated.

Operation description

A DataAgent is an agent resource in Simple Log Service. It accesses data in your account by assuming the specified RAM role (roleArn) and uses the associated context models to understand your business metrics. It is used to answer natural language questions, perform analysis, and generate outputs.

Before you call this operation, make sure that:

  • The RAM role specified by roleArn is authorized to be assumed by Simple Log Service. If you call this operation as a RAM user or by assuming a role, the caller must also have the ram:PassRole permission for the role.

  • The context models to be associated have been created in the same account.

When you create a DataAgent in an account for the first time, Simple Log Service automatically creates the service-linked role AliyunServiceRoleForSLSSemantic for the account and activates the DataAgent service. No additional operations are required. If the caller lacks the permission to create the service-linked role, the operation returns a 401 error. In this case, the Alibaba Cloud account must grant the ram:CreateServiceLinkedRole permission before you retry.

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

log:CreateDataAgent

create

*DataAgent

acs:log:{#regionId}:{#accountId}:dataagent/{#name}

None None

Request syntax

POST /dataagents HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The request body. The configurations required to create a DataAgent.

description

string

No

The description of the DataAgent. It is used to describe its scope of responsibilities and applicable scenarios. It is only for display and search purposes and does not affect runtime behavior. The keyword parameter in the list operation performs fuzzy matching with this description.

Responsible for analyzing order and revenue-related logs and outputting daily summary reports

displayName

string

No

The display name. A short title for UI display. It can contain Chinese characters, spaces, and punctuation marks, with a maximum length of 256 characters (calculated by character count, not byte count). If this parameter is not passed or an empty string is passed, it indicates that it is not set. In this case, the operation returns an empty string "" (it is not backfilled with name). For display, you can fall back to displayName || name.

Order Analysis Assistant

name

string

Yes

The name of the DataAgent. It must be unique within the same account. It can contain only uppercase and lowercase letters, digits, underscores (_), and hyphens (-), and must be 4 to 128 characters in length. It cannot be modified after creation. Subsequent queries, updates, and deletions of the DataAgent and its sessions use this name to locate the resource.

order-analysis-agent

roleArn

string

Yes

The ARN of the RAM role that the DataAgent assumes to access resources in your account. The format is acs:ram:::role/. The role must allow Simple Log Service to assume it so that the DataAgent can read your data with its permissions. If you call this operation as a RAM user or by assuming a role, the caller must also have the ram:PassRole permission for the role. Otherwise, a 401 error is returned.

acs:ram::123456789012****:role/sls-dataagent-role

contextModels

array

Yes

The list of context model names associated with the DataAgent. Context models provide business semantics (data sources, metrics, dimensions, and terms) for the DataAgent. After association, the DataAgent can locate your log data when answering questions.

string

No

The name of a single context model. It must be a context model that has been created in the current account.

order-context

systemPrompt

string

No

The system prompt of the DataAgent. It is used to set its role positioning, capability boundaries, and response style.

You are a data analytics assistant in the order domain. Only answer questions related to orders and revenue. If you are unsure, explain the reason instead of guessing

Response elements

Element

Type

Description

Example

object

The response body. Returns the configurations of the created DataAgent. The fields are the same as those in the request body.

description

string

The description of the DataAgent. An empty string is returned if it is not set.

Responsible for analyzing order and revenue-related logs and outputting daily summary reports

displayName

string

The display name. An empty string "" is returned if it is not set (it is not backfilled with name). For display, fall back to displayName || name.

Order Analysis Assistant

userId

string

The ID of the Alibaba Cloud account to which the DataAgent belongs.

123456789012****

createdAt

string

The creation time. The time is in ISO 8601 format in the UTC time zone and accurate to seconds.

2026-08-14T10:00:03Z

contextModels

array

The list of context model names associated with the DataAgent.

string

The name of a single context model.

order-context

updatedAt

string

The time of the last update. The format is the same as that of createdAt.

2026-08-15T09:20:31Z

systemPrompt

string

The system prompt of the DataAgent. An empty string is returned if it is not set.

You are a data analytics assistant in the order domain. Only answer questions related to orders and revenue. If you are unsure, explain the reason instead of guessing

roleArn

string

The ARN of the RAM role assumed by the DataAgent.

acs:ram::123456789012****:role/sls-dataagent-role

name

string

The name of the DataAgent.

order-analysis-agent

Examples

Success response

JSON format

{
  "description": "Analyzes order and revenue-related logs and generates daily summary reports",
  "displayName": "Order Analysis Assistant",
  "userId": "123456789012****",
  "createdAt": "2026-08-14T10:00:03Z",
  "contextModels": [
    "order-context"
  ],
  "updatedAt": "2026-08-15T09:20:31Z",
  "systemPrompt": "You are a data analytics assistant for the order domain. Only answer questions related to orders and revenue. If you are unsure, explain the reason instead of guessing",
  "roleArn": "acs:ram::123456789012****:role/sls-dataagent-role",
  "name": "order-analysis-agent"
}

Error codes

HTTP status code

Error code

Error message

Description

403 ExceedQuota The number of DataAgents has reached the upper limit for this account. Delete unused DataAgents or contact the administrator to raise the quota.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.