Updated on 2025-11-25 GMT+08:00

Adding a Subscription

Function

This API is used to add a subscription.

Calling Method

For details, see Calling APIs.

URI

POST /v1/{project_id}/event-subs

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. For how to obtain it, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain 1 to 64 characters. Only letters and digits are allowed.

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token. You can obtain it by calling the IAM API for obtaining a user token. The user token is the value of X-Subject-Token in the response header. For details, see Token-based Authentication.

Constraints

N/A

Range

The value can contain 1 to 32,768 characters.

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

enable

No

Boolean

Definition

Whether to enable subscription

Constraints

N/A

Range

  • true: Subscription is enabled.

  • false: Subscription is disabled.

Default Value

false

name

No

String

Definition

Subscription name. The system generates a name prefixed with "dis-" followed by four random characters or digits. Example: dis-xxxx. You can also customize a name.

Constraints

This parameter cannot be left blank.

Range

N/A

Default Value

N/A

topic_type

Yes

Integer

Definition

Subscription type

Constraints

N/A

Range

  • 0: SMN topic

  • 1: DIS stream

Default Value

0

topic_name

Yes

String

Definition

SMN topic name or DIS stream name. This parameter cannot be left blank. If the subscription type is SMN, this parameter indicates the name of the selected topic. If the subscription type is DIS, this parameter indicates the name of the selected DIS stream.

Constraints

There must be an SMN topic or DIS stream. Otherwise, you must create one.

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Normal response

None

Example Requests

Add a subscription.

POST https://{Endpoint}/v1/{project_id}/event-subs

{
  "enable" : true,
  "events_ids" : "dis_event.000\ndis_event.001",
  "name" : "dis-test1",
  "topic_name" : "dis-boce-nodelete",
  "topic_type" : 1,
  "topic_urn" : "urn:smn:cn-southwest-2:575ae927fc644f22b5c5af5209b7cf51:test"
}

Example Responses

None

Status Codes

Status Code

Description

200

Normal response

Error Codes

See Error Codes.