Producing Messages to Kafka

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

Function

This API is used to send specified messages on the console to Kafka instances.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{project_id}/instances/{instance_id}/messages/action

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.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

action_id

Yes

String

Action ID, which is send for production.

Request Parameters

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

topic

Yes

String

Kafka topic.

body

Yes

String

Message content.

property_list

Yes

Array of property_list objects

Topic partition information.

Table 4 property_list

Parameter

Mandatory

Type

Description

name

No

String

Feature name.

value

No

String

Feature value.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

topic

String

Kafka topic.

body

String

Message content.

property_list

Array of objects

Topic partition information.

Example Requests

Sending messages on the Kafka console

POST https://{endpoint}/v2/{project_id}/instances/{instance_id}/messages/action?action_id={action_id}

{
  "topic" : "XXXX",
  "body" : "hello world",
  "property_list" : [ {
    "name" : "KEY",
    "value" : "testKey"
  }, {
    "name" : "PARTITION",
    "value" : "0"
  } ]
}

Example Responses

Status code: 200

Message produced.

{
  "topic" : "XXXX",
  "body" : "XXXX",
  "property_list" : [ ]
}

Status Codes

Status Code

Description

200

Message produced.

Error Codes

See Error Codes.

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback