All Products
Search
Document Center

DataHub:CreateTopic

Last Updated:Sep 10, 2026

A topic is the smallest unit for subscription and publishing in DataHub. You can use a topic to represent a type or category of streaming data.

Operation description

Creates a topic resource.

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

dhs:CreateTopic

create

*Topic

acs:dhs:{#regionId}:{#accountId}:projects/{#ProjectName}/topics/{#TopicName}

None None

Request parameters

Parameter

Type

Required

Description

Example

ProjectName

string

Yes

The name of the project.

xiaowutest

TopicName

string

Yes

The name of the topic.

adsb_cat021

ShardCount

integer

Yes

The number of shards.

10

Lifecycle

integer

Yes

The lifecycle of the topic. Unit: days.

1

RecordType

string

Yes

The type of the topic. Valid values:

  1. Blob: supports writing a block of binary data as a single record.

  2. Tuple: supports database-like records where each record contains multiple columns. You must specify a RecordSchema because data is transmitted over the network as strings and requires a schema to convert values to the corresponding types.

TUPLE

RecordSchema

string

No

The schema table structure.

"{\"fields\":[{\"name\":\"field_init\",\"type\":\"STRING\",\"notnull\":\"false\"}]}"

Comment

string

Yes

The description of the topic.

Test

ExpandMode

boolean

No

The expansion mode of the topic. After the expansion mode is enabled, shards support horizontal scaling and no longer support merge or split operations. The number of shards can only increase and cannot decrease. After this mode is enabled, you can use the Kafka method to consume the current topic.

true

EnableSchemaRegistry

boolean

No

Specifies whether to enable multi-version schema. After this feature is enabled, a topic can have multiple schemas simultaneously. You can select one schema for writing. The consumer automatically parses each record based on the version marked on the data. If the schema of the corresponding version is deleted, parsing fails.

Note

Enabling multi-version schema has the following impacts:

  1. You can no longer use the appendFields operation.

  2. You can create, delete, modify, and query schemas.

  3. Creating a connector uses the schema of the latest version.

false

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

2026020210000022c53d0b06900170

Success

boolean

Indicates whether the request was successful.

True

TopicName

string

The name of the topic.

test01

Examples

Success response

JSON format

{
  "RequestId": "2026020210000022c53d0b06900170",
  "Success": true,
  "TopicName": "test01"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter Error:%s. The parameter entered is illegal
400 MissingParameter Error:%s. Missing required parameters
400 ResourceAlreadyExist Error:%s. Resource already exists
500 InternalServerError Error:%s. Server error, server unavailable or unexpected error occurred
403 NoPermission Error:%s. You are not authorized to perform this operation.
403 OperationDenied Error:%s. Operation denied
404 ResourceNotFound Error:%s. Resource does not exist

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.