본문 바로가기메인 메뉴 바로가기사이드 메뉴 바로가기

kakao developers

Related sites
  • Docs
  • Push Notification
  • REST API

사이드 메뉴

Search

This document describes how to integrate Push Notification APIs into your service with a REST API.

Requirements
  • You can register, retrieve, or revoke push tokens using the Android and iOS SDKs. However, to send push notifications, you must use a REST API.
  • You must register your Apple Push Notification service (APNs) or Firebase Cloud Messaging (FCM) authentication information on the app management page in advance. To see how to get and register authentication information, refer to Prerequisites.
  • You must receive a push token from APNs or FCM beforehand by referring to documentation that APNs and FCM provides.
Push notification API upgrade from v1 to v2
  • Effective date: December 2, 2020

  • Changes: As Google Cloud Messaging(GCM) has been replaced by Firebase Cloud Messaging (FCM), the value of push_type has been changed.

MethodURLAuthorization
POSThttps://kapi.kakao.com/v2/push/registerService app admin key

Registers push tokens saved on the devices of receiving user, also referred as 'device token', on the Kakao platform before using the Push notification function.

If the same user has multiple devices, register a push token for each device to send push notifications to each one.

Allowed IP Address

To send push notifications securely, you can restrict the IP addresses that call the Kakao APIs. Register the IP addresses in [App] > [Admin key] > [Allowed IP address] on the app management page. For more information, refer to Allowed IP address.

NameDescriptionRequired
AuthorizationAuthorization: KakaoAK ${SERVICE_APP_ADMIN_KEY}
Service app admin key as a type of user authentication.
O
NameTypeDescriptionRequired
uuidStringA user's unique ID.
Only integers in the range of 1 to ((2^63)-1) are allowed.
O
device_idStringDevice's unique ID to identify a user's multiple devices.
Used to register or revoke a specific device's push token if a user has multiple devices.
For APNs, you can use the push token received from APNs because each iOS device has different push tokens.
For FCM, you need an algorithm to generate a device's unique ID.
O
push_typeStringPush server type.
apns or fcm.
O
push_tokenStringPush token issued from APNs (64 characters) or FCM.O
NameTypeDescription
NONEIntegerValidity period until the push token expires (unit: days).
If the token is unlimited, -1 is returned.
The period is not renewed automatically, so re-register the token before it expires.
curl -v -X POST "https://kapi.kakao.com/v2/push/register" \
-H "Content-Type: application/x-www-form-urlencoded;charset=utf-8" \
-H "Authorization: KakaoAK ${SERVICE_APP_ADMIN_KEY}" \
-d "uuid=1234" \
-d "device_id=0f365b39-c33d-39be-bdfc-74aaf5534470" \
-d "push_type=fcm" \
--data-urlencode "push_token=APA91bEZ3fjwrKV2mxAFvZMC960zKBWBVffLErwZgFzsFnzzsxgi5lSQlq3zvzObZBe4OnbwkTZfMqV7_a6fF0AJNgUjt5Scpo2BTaHyLVlK54QmwIQBahUwJprKjj0YvF_rh8l7CTvl6TRxqlqO_NIwaoAcI0MssA"
// HTTP/1.1 200 OK
// Content-Length: 2
// Content-Type: application/json;charset=UTF-8
-1
MethodURLAuthorization
GET/POSThttps://kapi.kakao.com/v2/push/tokensService app admin key

Returns users' push tokens (device tokens) registered in the Kakao Push service.

  • Either uuid or uuids is required
    • uuid: Retrieves push tokens for one user
    • uuids: Retrieves push tokens for up to 100 users
  • Because multiple devices are supported, a user can have multiple registered push tokens
NameDescriptionRequired
AuthorizationAuthorization: KakaoAK ${SERVICE_APP_ADMIN_KEY}
Service app admin key as a type of user authentication.
O
NameTypeDescriptionRequired
uuidStringA user's unique ID.
Only integers in the range of 1 to ((2^63)-1) are allowed.
O*
uuidsString[]List of uuids.
Up to 100 uuids are allowed.
O*
* To retrieve the push tokens of a specific user, pass 'uuid' as a required parameter. To retrieve push tokens of multiple users, pass 'uuids' as a required parameter.
NameTypeDescription
uuidStringA user's unique ID.
Only integers in the range of 1 to ((2^63)-1) are allowed.

Note: user_id has been deprecated and replaced with uuid.
device_idStringDevice's unique ID to identify a user's multiple devices.
push_typeStringPush server type.
apns or fcm.
push_tokenStringPush token issued from APNs (64 characters) or FCM.
created_atDatetimeThe time when the push token was registered.
updated_atDatetimeThe time when the push token was updated.
Parameter name change

user_id, one of the request parameters for the Retrieve push token API, has been replaced with uuid to have the same name as the parameter of other Push APIs. user_id will be deprecated after a certain period of time.

curl -v -G GET "https://kapi.kakao.com/v2/push/tokens?uuid=1234" \
-H "Authorization: KakaoAK ${SERVICE_APP_ADMIN_KEY}"
curl -v -X POST "https://kapi.kakao.com/v2/push/tokens" \
-H "Content-Type: application/x-www-form-urlencoded;charset=utf-8" \
-H "Authorization: KakaoAK ${SERVICE_APP_ADMIN_KEY}" \
--data-urlencode 'uuids=["1234", "5678"]'
// HTTP/1.1 200 OK
// Content-Type: application/json;charset=UTF-8
[
{
"uuid": "9876543211234",
"device_id": "0f365b39-c33d-39be-bdfc-74aaf5534470",
"push_type": "fcm",
"push_token": "APA91bEZ3fjwrKV2mxAFvZMC960zKBWBVffLErwZgFzsFnzzsxgi5lSQlq3zvzObZBe4OnbwkTZfMqV7_a6fF0AJNgUjt5Scpo2BTaHyLVlK54QmwIQBahUwJprKjj0YvF_rh8l7CTvl6TRxqlqO_NIwaoAcI0MssA",
"created_at": "2014-07-29T06:24:12Z",
"updated_at": "2014-07-29T06:24:12Z"
}
]
MethodURLAuthorization
POSThttps://kapi.kakao.com/v2/push/deregisterService app admin key

Revokes a push token of a specific user or device.

You can call this API when a user wants to disable the push notification function or when a user logs out from a specific device. If a user has multiple devices, you can delete a specific device's push token by specifying the device ID.

NameDescriptionRequired
AuthorizationAuthorization: KakaoAK ${SERVICE_APP_ADMIN_KEY}
Service app admin key as a type of user authentication.
O
NameTypeDescriptionRequired
uuidLongA user's unique ID.
Only integers in the range of 1 to ((2^63)-1) are allowed.
If device_id and push_type are omitted, revokes all push tokens for the user.
O
device_idStringDevice's unique ID to identify a user's multiple devices.
Used to revoke a specific device's push token if a user has multiple devices.
For APNs, you can use the push token received from APNs because each iOS device has different push tokens.
For FCM, you need an algorithm to generate a device's unique ID.
X
push_typeStringPush server type of the token to revoke.
apns or fcm.
X
curl -v -X POST "https://kapi.kakao.com/v2/push/deregister" \
-H "Content-Type: application/x-www-form-urlencoded;charset=utf-8" \
-H "Authorization: KakaoAK ${SERVICE_APP_ADMIN_KEY}" \
-d "uuid=1234" \
-d "device_id=0f365b39-c33d-39be-bdfc-74aaf5534470" \
-d "push_type=fcm"
HTTP/1.1 200 OK
Content-Length: 0
Content-Type: application/json;charset=UTF-8
MethodURLAuthorization
POSThttps://kapi.kakao.com/v2/push/sendService app admin key

Sends push notifications.

Push notifications are sent to all devices registered under each recipient's uuid.

However, a successful API response does not guarantee delivery to the device. A push notification might not be delivered depending on the APNs or FCM server status.

If delivery fails, feedback is sent to the return_url passed in the request. For FCM, the feedback may include a new push token for renewal.

APNs only allows a push notification with a data length of 4 KB or less, excluding topic, push_alert, return_url, and push_token. For iOS 7 or less, up to 256 bytes are allowed. For VoIP notification, the maximum size is 5 KB.

If the payload size exceeds 4 KB and the message is a string type, cut off the last part of a message, and add ".." to the end of the message content.

To downsize or customize a message, you can store a format for a specific push notification message in the app in advance and pass only the keys and parameters according to the specified format in your request. Refer to Creating the Remote Notification Payload.

You can use the Localized Formatted String function as follows:

  1. Define a format in JSON format in your app.
  2. Set loc-key to COMMENT_ALERT_FORMAT, and pass the values to be actually used in the message when requesting to send a push notification.
{
"message": {
"loc-key": "COMMENT_ALERT_FORMAT",
"loc-args": ["John", "2"]
}
}

When you have defined a format like this,

%@ users including %@ left comments.

The actual push notification is sent as follows.

2 friends including John left comments.
NameDescriptionRequired
AuthorizationAuthorization: KakaoAK ${SERVICE_APP_ADMIN_KEY}
Service app admin key as a type of user authentication.
O
NameTypeDescriptionRequired
uuidsString[]List of user's unique ID(uuid).
Up to 100 uuids are allowed.
O
push_messagePushMsgJsonParameters to configure a message.
Include APNs payload under for_apns and FCM payload under for_fcm. To use both services, include both keys.
If you do not have any parameter to pass, send empty brackets ({}).
Refer to PushMsgJson below.
O
bypassBooleanWhether to bypass when using the push notification function.
Used when managing push tokens manually in the service server, instead of registering the token on the Kakao platform.
(Default: false)
If set to true, you must include payload in PushMsgJson.
X
Bypass parameter

If you want to manage push tokens in the service server on your own, not registering them on the Kakao platform, use the bypass parameter. You must make a request to send a notification by passing the push token as the value of push_message. If any push token information is not passed, the request fails.

NameTypeDescriptionSampleRequired
topicStringUsed when using VoIP (Voice over Internet Protocol)."voip"X
mutable-contentIntegerSet mutable-content parameters for APNs.1X
expirationIntegerTime to retry to send a push notification in seconds when a push notification is not available to receive.86400X
collapseStringPush message separator.
If multiple push notifications have the same value, only the last notification is sent to the user's device.
"we345"X
badgeIntegerNumber of badges to be displayed in the app on iOS device.123X
soundStringNotification sound when receiving push notifications."default"X
push_alertBooleanUsed when you want to have the device volume muted, send a push notification that does not appear in the notification center, or change the number of badges without sound or notification.falseX
content-availableIntegerIndicates that new content is available.1X
categoryStringSet an action to be shown in the notification center.INVITE_CATEGORYX
messageString or JSONThe content to be displayed in Notification Center as an alert."2 friends including John left comments."X
custom_fieldDictionaryUsed when you want to pass additional information to the app along with a message.{"article_id" : 111}X
return_urlStringUsed when you need to handle errors, such as "BadDeviceToken", "Unregistered", and "DeviceTokenNotForTopic" that occur when routing push notification.https://example.com/
fcm_push_fail
X
push_tokenStringPush token to be managed manually in the service server, not registering the token on the Kakao platform."AAABBBCCCDDD"X
apns_envStringAPNs server to send a push notification to.
sandbox or production (Default).
"sandbox"X
thread-idStringApp identifier to group notifications by relevance."Group01"X
apns-push-typeStringContents of payload.
Required in watchOS 6 or higher.
"alert"X
apns-priorityIntegerNotification priorities.
(Default: 10)
5X
target-content-idStringIdentifier used to target a window to bring to the front when opening a notification."Target01"X
interruption-levelStringImportance and delivery timing of notifications."time-sensitive"X
relevance-scoreDoubleRelevance score from 0 to 1.
Used to sort app's notifications in a system.
0.34X
NameTypeDescriptionSampleRequired
collapseStringPush message separator.
If multiple push notifications have the same value, only the last notification is sent to the user's device.
"wi10ck48"X
time_to_liveIntegerPeriod to store unsent messages in FCM storage in seconds.17200X
dry_runBooleanUsed for testing.
Not sent to the actual device.
true or falseX
priorityStringIf set to high, a push notification is sent to a user's device even in the Doze mode.
(Default: normal)
high or normalX
custom_fieldJSONUsed when you want to pass additional information to the app along with a message.
Unlike APNs, the total length of the custom_field per push notification is limited to 4 KB.
{"article_id" : 111 }X
notificationJSONKey-value pairs of predefined notification payload displayed to the user.
Refer to Table 2a, 2b or 2c under Notification payload support in Firebase Cloud Messaging HTTP protocol.
{"body":"great match!",
"title":"Portugal vs. Denmark",
"icon":"myicon"}
X
return_urlStringUsed when you need to handle errors that occur when routing push notification.https://example.com/
fcm_push_fail
X
push_tokenStringPush token to be managed manually in the service server, not registering the token on the Kakao platform."AAABBBCCCDDD"X
NameTypeDescription
userIdStringuuid (OLD: user_id) that owns the push token failed to send a push notification.
pushTokenStringPush token failed to send a push notification.
dateLongTime when sending a push notification failed.
In Unix timestamp format (unit: milliseconds).
NameTypeDescription
userIdStringuuid (OLD: user_id) that owns the push token failed to send a push notification.
pushTokenStringPush token failed to send a push notification.
dateLongTime when sending a push notification failed.
In Unix timestamp format (unit: milliseconds).
newPushTokenStringOnly returned when bypassing.
A new push token used to refresh the push token stored under the designated uuid (user_id) when managing push tokens manually in the service server.
curl -v -X POST "https://kapi.kakao.com/v2/push/send" \
-H "Content-Type: application/x-www-form-urlencoded;charset=utf-8" \
-H "Authorization: KakaoAK ${SERVICE_APP_ADMIN_KEY}" \
-d 'uuids=["1234", "5678"]' \
--data-urlencode 'push_message={
"for_apns":{
"badge":3,
"sound":"sound_file",
"push_alert":true,
"message":"2 friends including John left comments..",
"custom_field":{
"article_id":"111",
"comment_id":"222"
}
},
"for_fcm":{
"collapse": "articleId123",
"delay_while_idle":false,
"custom_field": {
"article_id": 111,
"comment_id": 222,
"comment_preview": "How have you been? ...(omitted)"
}
}
}'
{
"for_apns": {
"badge": 3,
"sound": "sound_file",
"push_alert": true,
"content-available": 1,
"category": "INVITE_CATEGORY",
"message": "2 friends including John left comments..",
"custom_field": {
"article_id": "111",
"comment_id": "222"
}
},
"for_fcm": {
"collapse": "articleId123",
"delay_while_idle": false,
"time_to_live": 17200,
"dry_run": false,
"priority": "high",
"custom_field": {
"article_id": 111,
"comment_id": 222,
"comment_preview": "How have you been? ...(omitted)"
}
}
}
HTTP/1.1 200 OK
Content-Length: 0
Content-Type: application/json;charset=UTF-8
POST /fcm_push_fail HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
userId=123&pushToken=abcdefg&date=1396582208000
POST /fcm_push_fail HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
userId=123&pushToken=abcdefg&date=1396582208000&newPushToken=AAbbccddee

Was this helpful?

    Push Notification > REST API - Kakao Developers | Docs