Updated on 2025-12-31 GMT+08:00

Deleting Kafka Messages

Function

This API is used to delete Kafka messages.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{project_id}/kafka/instances/{instance_id}/topics/{topic}/messages/delete

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID.

instance_id

Yes

String

Instance ID.

topic

Yes

String

Topic name.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

partitions

No

Array of PartitionOffsetEntity objects

Partition offset details.

Table 3 PartitionOffsetEntity

Parameter

Mandatory

Type

Description

partition

No

Integer

Partition.

offset

No

Integer

Consumer offset.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

partitions

Array of PartitionResp objects

Partition response information.

Table 5 PartitionResp

Parameter

Type

Description

partition

Integer

Partition.

result

String

Returned result.

error_code

String

Returned error code.

Example Requests

Deleting Kafka messages

POST https://{endpoint}/v2/{project_id}/kafka/instances/{instance_id}/topics/{topic}/messages/delete

{
  "partitions" : [ {
    "partition" : 0,
    "offset" : 1
  } ]
}

Example Responses

Status code: 200

Messages deleted.

{
  "partitions" : [ {
    "partition" : 0,
    "result" : "success",
    "error_code" : 0
  } ]
}

Status Codes

Status Code

Description

200

Messages deleted.

Error Codes

See Error Codes.