Creating a Topic

This page explains how to create a topic for each scope.

Creating an application-scope topic

Only an application admin can create an application-scope topic. All authenticated users can subscribe the topic, but only the topic creator (i.e. the application admin) can send push messages to the topic by default.

Follow these steps:

  1. Follow the steps described in "REST guides - Admin Features" and get an app admin token.
  2. Create an app-scope topic as follows (in this example, we are creating a topic named "SendingAlert"):
curl -v -X PUT \
  -H "Authorization: Bearer {ACCESS_TOKEN}" \
  "https://api-jp.kii.com/api/apps/{APP_ID}/topics/SendingAlert" \
  -d ""

Make sure to replace {APP_ID} with your application's AppID. Also make sure to replace {ACCESS_TOKEN} with the token obtained in the previous step.

The topic name should be composed of up to 64 characters (alphanumeric, "-" and "_").

If the topic is successfully created, Kii Cloud will return a 204 response. If the topic creation failed because there already exists the topic with the same name, Kii Cloud will return a 409 response with the error code TOPIC_ALREADY_EXISTS.

Creating a group-scope topic

Any group members can create a group-scope topic. All group members can subscribe to the topic, and all of them can send push messages to the topic by default.

Unlike an app-scope topic, a group-scope topic is usually created dynamically by an application. See the following sample code to see how to do this:

See the following curl execution sample to see how to create a group-scope topic named "GroupTopic".

curl -v -X PUT \
  -H "Authorization: Bearer {ACCESS_TOKEN}" \
  "https://api-jp.kii.com/api/apps/{APP_ID}/groups/{GROUP_ID}/topics/GroupTopic" \
  -d ""

Make sure to replace {APP_ID} with your application's AppID. Also make sure to set the appropriate {GROUP_ID}.

The topic name should be composed of up to 64 characters (alphanumeric, "-" and "_").

If the topic is successfully created, Kii Cloud will return a 204 response. If the topic creation failed because there already exists the topic with the same name, Kii Cloud will return a 409 response with the error code TOPIC_ALREADY_EXISTS.

Creating a user-scope topic

Any authenticated users can create a user-scope topic. Only this user can subscribe to the topic and send push messages to it by default.

Like a group-scope topic, a user-scope topic is usually created dynamically by an application. See the following sample code to learn how to create a user-scope topic.

See the following curl execution sample to see how to create a user-scope topic named "MyTODO".

curl -v -X PUT \
  -H "Authorization: Bearer {ACCESS_TOKEN}" \
  "https://api-jp.kii.com/api/apps/{APP_ID}/users/{USER_ID}/topics/MyTODO" \
  -d ""

Make sure to replace {APP_ID} with your application's AppID. Also make sure to set the appropriate {USER_ID}.

The topic name should be composed of up to 64 characters (alphanumeric, "-" and "_").

If the topic is successfully created, Kii Cloud will return a 204 response. If the topic creation failed because there already exists the topic with the same name, Kii Cloud will return a 409 response with the error code TOPIC_ALREADY_EXISTS.