Skip to main content

Pub/Sub API

info

The creation and deletion of topics and subscriptions can only be done through the KakaoCloud Console.

Common error codes

Response error syntax
{
"error": {
"code": int,
"message": string
}
}

// Example
{
"error": {
"code": 3,
"message": "you have passed an invalid ack ID to the service (ack_id=MTZBRklHTVZTREZTJEpTLkFQSQ==)"
}
}

Error messages and troubleshooting

Error CodeHTTP CodeResponse and Solution
3 (INVALID_ARGUMENT)400Invalid request
The request is invalid; a required argument may be missing, exceeds limits, or has an invalid value.

Solution: Check the error message and retry the request.
9 (FAILED_PRECONDITION)400Failed precondition
Something must be done in the system to allow this operation.

Solution: Recheck the request.
7 (PERMISSION_DENIED)403Permission denied
The certification is invalid.

Solution: Obtain permission and retry.
5 (NOT_FOUND)404Topic or subscription not found
The topic or subscription referenced has not been found. In the case of JSON requests, it may also happen if the URL path is not a correct REST path.
For publish and pull operations, the propagation of an object creation may take a few seconds.

Solution: If the resource was just created, retry the request or create the topic or subscription and try again.
13 (INTERNAL)500Internal server error
This error indicates an internal server error; it should not occur. If this error occurs, please report to cloud support. The error should be transient.

Solution: Retry the request.

Topic

The following APIs are related to topics.

Retrieve topic list

Retrieves the list of topics created in the project.

Method
MethodURI
GET{endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/topics
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs.
project-idStringRequiredProject ID of KakaoCloud.
Request header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Query parameters
RequestTypeDescription
pageSizeIntegerNumber of items to retrieve in a single request.
pageTokenStringToken to fetch the next list.
Response syntax
Response Syntax
{
"topics": [
{
object (Topic)
}
],
"nextPageToken": string
}

//object (Topic) Example
{
"id": string,
"name": string,
"description": string,
"domain": string,
"project": string,
"messageRetentionDuration": string,
"subscriptionCount": integer,
"creator": string,
"createdAt": string
}
Response Elements
ResponseTypeDescription
topicsObject Array (Topic)List of topics and information
nextPageTokenStringToken to retrieve the next set of topics
Object Array (Topic)
ResponseTypeDescriptionOutput Only
idStringTopic IDo
nameStringTopic name
descriptionStringTopic description
domainStringID of the organization that includes the topic
projectStringProject ID that includes the topic
messageRetentionDurationStringMessage retention duration of the topic
subscriptionCountIntegerNumber of subscriptions connected to the topico
creatorStringCreator of the topico
createdAttimestampCreation timeo

Retrieve topic details

Retrieves detailed information on a specific topic.

Method
MethodRequest URL
GET  {endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/topics/{topic-name}
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs
project-idStringRequiredProject ID of KakaoCloud
topic-nameStringRequiredTopic name
Request Header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Response Syntax
Response Syntax
{
"id": string,
"name": string,
"description": string,
"domain": string,
"project": string,
"messageRetentionDuration": string,
"subscriptionCount": integer,
"creator": string,
"createdAt": string
}
Response Elements
FieldTypeDescriptionOutput Only
idStringTopic IDo
nameStringTopic name
descriptionStringTopic description
domainStringID of the organization that includes the topic
projectStringProject ID that includes the topic
messageRetentionDurationStringMessage retention duration of the topic
subscriptionCountIntegerNumber of subscriptions connected to the topico
creatorStringCreator of the topico
createdAttimestampCreation timeo

Publish message

Sends one or more messages to the topic.

Request Syntax
Request Syntax
{
"messages": [
{
"data": "message-1",
"attributes": {
"key1": "value1",
"key2": "value2"
}
},
{
"data": "message-2"
}
]
}
Method
MethodRequest URL
POST{endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/topics/{topic-name}/publish
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs
project-idStringRequiredProject ID of KakaoCloud
topic-nameStringRequiredTopic name
Request header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Request elements
RequestTypeRequiredDescription
messagesObject ArrayRequiredList of messages to send to the topic
- Max: 100
message.dataStringRequiredMessage content
- Max size: 1 MiB
- Either data or attributes must be included
⚠️ Note: Must be Base64 encoded
message.attributesmap
[string : string]
RequiredMessage attributes
- Max: 100 items
- Key: 1~256 characters
- Value: 1~1024 characters
- The total size of Key and Value must not exceed 60KiB
⚠️ Note: Keys starting with kakaoc are not allowed
Response Syntax
Response Syntax
{
"messageIds": [
string,
string
]
}
Response Elements
ResponseTypeDescription
messageIdsstring ArrayUnique ID issued for each message

Modify topic

You can modify the description, message retention duration, etc., of a topic. The message retention duration can only be extended beyond the originally set time. User-created topics can be modified up to 7 days, while default topics can be modified up to 31 days.

Request syntax
Request Syntax
{
"topic": {
"description": "topic description",
"messageRetentionDuration": "604800s"
},
"updateMask": "messageRetentionDuration,description"
}
Method
MethodRequest URL
PATCH{endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/topics/{topic-name}
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs
project-idStringRequiredProject ID of KakaoCloud
topic-nameStringRequiredTopic name
Request header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Request elements
RequestTypeRequiredDescription
topic.descriptionStringRequiredDescription of the topic
topic.messageRetentionDurationStringOptionalMessage retention duration
- Can only be extended beyond the originally set time (in seconds)
updateMaskStringRequiredList of fields to update
- Separated by commas (,)
Response syntax
Update Topic Response Syntax
{
object (Topic) // Topic details
}


// object (Topic) Example
{
"id": string,
"name": string,
"description": string,
"domain": string,
"project": string,
"messageRetentionDuration": string,
"subscriptionCount": int,
"creator": string,
"createdAt": string
}
Response Elements
FieldTypeDescriptionOutput Only
idStringTopic IDo
nameString (required)Topic name
descriptionStringTopic description
domainStringID of the organization that includes the topic
projectStringProject ID that includes the topic
messageRetentionDurationStringMessage retention duration of the topic
subscriptionCountintNumber of subscriptions connected to the topico
creatorStringCreator of the topico
createdAttimestampCreation timeo

Retrieve subscriptions of topic

Retrieves the list of subscriptions connected to the topic.

Method
MethodURI
GET{endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/topics/{topic-name}/subscriptions
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs
project-idStringRequiredProject ID of KakaoCloud
topic-nameStringRequiredTopic name
Request header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Query parameters
RequestTypeDescription
pageSizeIntegerNumber of items to retrieve in a single request
pageTokenStringToken to fetch the next list
Response syntax
Response Syntax
{
"subscriptions": [
string
],
"nextPageToken": string
}
Response Elements
FieldTypeDescription
subscriptionsstring ArrayList of subscription names connected to the topic
nextPageTokenStringToken to fetch the next set of subscriptions

Subscription

The following APIs are related to subscriptions.

Retrieve subscription list

Retrieves the list of subscriptions created in the project.

Method
MethodURI
GET{endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/subscriptions
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs
project-idStringRequiredProject ID of KakaoCloud
Request header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Query parameters
RequestTypeDescription
pageSizeIntegerNumber of items to retrieve in a single request
pageTokenStringToken to fetch the next list
Response syntax
Response Syntax
{
"subscriptions": [
{
Object (Subscription)
}
],
"nextPageToken": string
}

//Object (Subscription) Example
{
"id": string,
"name": string,
"domain": string,
"project": string,
"topicId": string,
"topic": string,
"ackDeadlineSeconds": string,
"messageRetentionDuration": string,
"maxDeliveryAttempt": int,
"status": string,
"pushConfig": {
object (PushConfig)
},
"unprocessedMessageCount": int,
"creator": string,
"createdAt": string
}
Response Elements
FieldTypeDescription
subscriptionsObject Array (Subscription)List of subscriptions created in the project
nextPageTokenStringToken to fetch the next set of subscriptions
Object Array (Subscription)
FieldTypeDescriptionOutput Only
idStringSubscription IDo
nameStringSubscription name
domainStringDomain name to which the subscription is connected
projectStringProject name to which the subscription is connected
topicIdStringID of the topic to which the subscription is connectedo
topicStringName of the topic to which the subscription is connected
ackDeadlineSecondsintTime that Pub/Sub waits before resending a message to the subscriber
messageRetentionDurationStringMessage retention duration of the subscription
maxDeliveryAttemptintNumber of message resend attempts
- -1 (default): Unlimited
- Can be set from 1 to 100
statusStringSubscription statuso
pushConfigObject (PushConfig)Endpoint settings for a push-type subscription
creatorStringCreator of the subscriptiono
createdAttimestampCreation time of the subscriptiono
PushConfig
{
"pushEndpoint": string
"pushBatchSize": int
}
ResponseTypeDescription
pushEndpointStringEndpoint URL (for Push Subscription)
pushBatchSizeintBatch size of messages for the Push subscription
- Default: 1
- Max: 100

Retrieve subscription details

Retrieves information on a specific subscription.

Method
MethodRequest URL
GET{endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/subscriptions/{sub-name}
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs
project-idStringRequiredProject ID of KakaoCloud
sub-nameStringRequiredSubscription name
Request header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Response syntax
Response Syntax
{
"id": string,
"name": string,
"domain": string,
"project": string,
"topicId": string,
"topic": string,
"ackDeadlineSeconds": string,
"messageRetentionDuration": string,
"maxDeliveryAttempt": int,
"status": string,
"pushConfig": {
object (PushConfig)
},
"unprocessedMessageCount": int,
"creator": string,
"createdAt": string
}
Response Elements
FieldTypeDescriptionOutput Only
idStringSubscription IDo
nameStringSubscription name
domainStringDomain name to which the subscription is connected
projectStringProject name to which the subscription is connected
topicIdStringID of the topic to which the subscription is connectedo
topicStringName of the topic to which the subscription is connected
ackDeadlineSecondsintTime that Pub/Sub waits before resending a message to the subscriber
messageRetentionDurationStringMessage retention duration of the subscription
maxDeliveryAttemptintNumber of message resend attempts
- -1 (default): Unlimited
- Can be set from 1 to 100
statusStringSubscription statuso
pushConfigObject (PushConfig)Endpoint settings for a push-type subscription
unprocessedMessageCountintNumber of unprocessed messages in the subscriptiono
creatorStringCreator of the subscriptiono
createdAttimestampCreation time of the subscriptiono
pushConfig
PushConfig
{
"pushEndpoint": string
"pushBatchSize": int
}
ResponseTypeDescription
pushEndpointStringEndpoint URL (for Push Subscription)
pushBatchSizeintBatch size of messages for the Push subscription
- Default: 1
- Max: 100

Update subscription (Patch)

Modifies the settings of a subscription.

Method
MethodURI
PATCH{endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/subscriptions/{sub-name}
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs
project-idStringRequiredProject ID of KakaoCloud
sub-nameStringRequiredSubscription name
Request header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Request syntax
Request Syntax
{
"subscription": {
"pushConfig": {
"pushEndpoint": "{Endpoint URL}"
},
"ackDeadlineSeconds": 30,
"messageRetentionDuration": "604800s",
"maxDeliveryAttempt": 5
},
"updateMask": "ackDeadlineSeconds,messageRetentionDuration,pushConfig.pushEndpoint,maxDeliveryAttempt"
}
FieldTypeRequiredDescription
subscription.pushConfigObject (PushConfig)OptionalEndpoint URL (for Push Subscription)
subscription.ackDeadlineSecondsintOptionalTime that Pub/Sub waits before resending a message to the subscriber
- Default: 30
subscription.messageRetentionDurationStringOptionalMessage retention duration
- Default: 7d
subscription.maxDeliveryAttemptintOptionalNumber of message resend attempts
- Default: Unlimited
updateMaskStringRequiredList of fields to update
- Separated by commas (,)
Response syntax
Response Syntax
{
"id": string,
"name": string,
"domain": string,
"project": string,
"topicId": string,
"topic": string,
"ackDeadlineSeconds": string,
"messageRetentionDuration": string,
"maxDeliveryAttempt": int,
"status": string,
"pushConfig": {
object (PushConfig)
},
"unprocessedMessageCount": int,
"creator": string,
"createdAt": string
}
Response Elements
FieldTypeDescriptionOutput Only
idStringSubscription IDo
nameStringSubscription name
domainStringDomain name to which the subscription is connected
projectStringProject name to which the subscription is connected
topicIdStringID of the topic to which the subscription is connectedo
topicStringName of the topic to which the subscription is connected
ackDeadlineSecondsintTime that Pub/Sub waits before resending a message to the subscriber
messageRetentionDurationStringMessage retention duration of the subscription
maxDeliveryAttemptintNumber of message resend attempts
- -1 (default): Unlimited
- Can be set from 1 to 100
statusStringSubscription statuso
pushConfigObject (PushConfig)Endpoint settings for a push-type subscription
unprocessedMessageCountintNumber of unprocessed messages in the subscriptiono
creatorStringCreator of the subscriptiono
createdAttimestampCreation time of the subscriptiono
PushConfig
{
"pushEndpoint": string
"pushBatchSize": int
}
FieldTypeDescription
pushEndpointStringEndpoint URL (for Push Subscription)
pushBatchSizeintBatch size of messages for the Push subscription
- Default: 1
- Max: 100

Pull messages

Retrieves messages.

Method
MethodURI
POST   {endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/subscriptions/{sub-name}/pull
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs
project-idStringRequiredProject ID of KakaoCloud
sub-nameStringRequiredSubscription name
Request header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Request syntax
Request Syntax
{
"maxMessages": 1,
"waitTime": "100ms"
}
RequestTypeRequiredDescription
maxMessagesintRequiredNumber of messages to retrieve
- Max: 100
⚠️ If the message size is large, fewer messages than the set amount may be received due to waitTime.
waitTimestringOptionalMessage fetch wait-time
- Default: 100ms
- Max: 30s (input in seconds)
Response syntax
Response Syntax
{
"receivedMessages": [
{
object (ReceivedMessage)
}
]
}

//object (ReceivedMessage) Example
{
"ackId": string,
"message": {
object (PubsubMessage)
},
"deliveryAttempt": int
}

//// object (PubsubMessage) Example
{
"data": string,
"attributes": {
string: string
...
},
"messageId": string,
"publishTime": string
}
Response Elements
ResponseType
receivedMessagesObject Array (ReceivedMessage)
ReceivedMessage
FieldsTypeDescription
ackIdStringID used to perform specific actions (acknowledge, modifyAckDeadline) on the message
messageObject (PubsubMessage)
deliveryAttemptintNumber of times the message has been resent
Pubsub Message
FieldsTypeDescription
dataString (required)Message content, up to 1 MiB
attributesmap (key: string, value: string) (optional)Message attributes, up to 100 items
messageIdStringUnique message ID, identical to the ID issued for each message in the Publish request response
publishTimeStringTime when the message was published

Acknowledge message

Acknowledges a message using its ackId.

Method
MethodURI
POST {endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/subscriptions/{sub-name}/acknowledge
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs
project-idStringRequiredProject ID of KakaoCloud
sub-nameStringRequiredSubscription name
Request header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Request syntax
Request Syntax
{
"ackIds": ["ack-id-1"]
}
RequestTypeRequiredDescription
ackIdsString ArrayRequiredList of ackIds for the messages to be acknowledged
Response syntax
Response Syntax
{
"failure": [
{
object (FailedAckID)
}
]
}

//object (FailedAckID) Example
{
"ackID": string,
"error": object (Error)
}
Response Elements
FieldType
failureobject (FailedAckID)
object (FailedAckID)
FieldsTypeDescription
ackIDStringOriginal ack ID
errorStringObject(Error), error code and description

Modify message acknowledgement deadline

You can extend or shorten the message acknowledgement deadline (Ack Deadline). A new Ack ID is issued upon success.

Method
MethodURI
POST  {endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/subscriptions/{sub-name}/modifyAckDeadline
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs
project-idStringRequiredProject ID of KakaoCloud
sub-nameStringRequiredSubscription name
Request Header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Request Syntax
Request Syntax
{
"ackIds": ["ack-id-1"],
"action": "extend"
}
RequestTypeRequiredDescription
ackIdsString ArrayRequiredList of ackIds for the messages
actionStringRequiredAction to take: either extend or skip
Response syntax
Response Syntax
{
"success": [
{
object (AckID)
}
],
"failure": [
{
object (FailedAckID)
}
]
}

//object (AckID) Example
{
"ackID": string,
"reissuedAckID": string
}

//object (FailedAckID) Example
{
"ackID": string,
"error": object (Error)
}
Response Elements
FieldTypeDescription
successobject (AckID)List of successful Ack IDs
failureobject (FailedAckID)List of failed Ack IDs
object (AckID)
FieldsTypeDescription
ackIDStringOriginal Ack ID
reissuedAckIDStringNew Ack ID
object (FailedAckID)
FieldsTypeDescription
ackIDStringOriginal ack ID
errorStringObject(Error), error code and description

Seek messages

The seek function allows you to roll back a subscription to a specific time, enabling you to receive all messages from that point onward.

Method
MethodURI
POST{endpoint-url}/v1/domains/{domain-id}/projects/{project-id}/subscriptions/{sub-name}/seek
PathTypeRequiredDescription
domain-idStringRequiredID of the organization to which the project belongs
project-idStringRequiredProject ID of KakaoCloud
sub-nameStringRequiredSubscription name
Request header
RequestTypeRequiredDescription
Credential-IDStringRequiredAccess key ID
Credential-SecretStringRequiredSecret access key
Request syntax
Request Syntax
{
"time": string
}
RequestTypeRequiredDescription
timeStringRequiredTime to roll back to
- Format: "2006-01-02T15:04:05+09:00", KST
Response body

No response value.