Granting User Permissions

Updated on 2025-05-21 GMT+08:00

Function

This API is used to grant user permissions.

User management is supported only when SASL is enabled for the Kafka instance.

Calling Method

For details, see Calling APIs.

URI

POST /v1/{project_id}/instances/{instance_id}/topics/accesspolicy

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

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

instance_id

Yes

String

Instance ID.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

topics

Yes

Array of AccessPolicyTopicEntity objects

Topic list.

Table 3 AccessPolicyTopicEntity

Parameter

Mandatory

Type

Description

name

Yes

String

Topic name.

policies

Yes

Array of AccessPolicyEntity objects

Permission list.

Table 4 AccessPolicyEntity

Parameter

Mandatory

Type

Description

user_name

No

String

Username.

This parameter is mandatory when you set user permissions.

access_policy

No

String

Permission type.

  • all: publish and subscribe permissions.

  • pub: publish permissions.

  • sub: subscribe permissions.

This parameter is mandatory when you set user permissions.

Response Parameters

Status code: 204

The update is successful.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 403

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Example Requests

Granting the root user the permission to publish and subscribe to topic-test

POST https://{endpoint}/v1/{project_id}/instances/{instance_id}/topics/accesspolicy

{
  "topics" : [ {
    "name" : "topic-test",
    "policies" : [ {
      "user_name" : "root",
      "access_policy" : "all"
    } ]
  } ]
}

Example Responses

None

Status Codes

Status Code

Description

204

The update is successful.

400

Invalid parameters.

403

Authentication failed.

Error Codes

See Error Codes.

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback