Template
A template is the base of the Campaign feature in Sendbird Chat. It is a pre-defined message structure that frames the notifications users receive through various channels, such as SMS, push notifications, and in-app channel messages. Templates are created and managed in the Sendbird Dashboard, and you can retrieve templates you've created using the APIs below.
Resource representation
The following tables show the lists of properties in a template resource. This section is divided into two tables: the first table lists the general properties of a template, and the second table lists the properties that are specific to certain channels.
General properties
Property | Type | Description |
---|---|---|
key | string | The unique ID of the template. |
template_key | string | The template key. |
name | string | The template name. |
is_archived | boolean | Specifies whether templates are active or archived. |
created_at | int | The timestamp when the template was created, in Unix milliseconds format. |
updated_at | int | The timestamp when the template’s latest version was last updated, in Unix milliseconds format. |
version | int | The version of the template. |
channels[].key | string | The unique key of channel. |
channels[].type | string | The type of channel. Valid values are |
channels[].name | string | The name of channel. |
channels[].content | object | A JSON object that specifies channel’s content. This object is excluded in in-app channels. If title or body doesn’t have value, it returns an empty object. |
variable_schema[].key | string | The key of template variable. |
variable_schema[].type | string | The data type of template variable. |
variable_schema[].name | string | The name of template variable. |
sequence | object | The order of channels within the template that determines to which channel a notification should be sent to first. |
sequence.steps[].channels[].key | string | The unique channel keys of the channels included in the template. |
sequence.steps[].channels[].type | string | The channel types of the channels included in the template, |
Channel-specific properties
The following tables show the properties that are specific to certain channels.
In-app channel | Type | Description |
---|---|---|
channels[].categories[].name | string | The names of categories that are used for the in-app channel. |
channels[].data_type | string | States whether template is data template or ui template. Valid values are |
channels[].data_template.key | string | The key of a data template. |
channels[].data_template.value | string | The value of data template. |
channels[].ui_template.body | object | A JSON object that contains the details of the UI template if |
channels[].message_retention_hours | int | The hours that message is kept in the channel. |
channels[].is_category_filter_enabled | boolean | Specifies whether category filter is enabled or not. |
channels[].is_template_label_enabled | boolean | Specifies whether label filter is enabled or not. |
SMS | Type | Description |
---|---|---|
channels[].category | string | If the channel is sms, valid values are either |
WhatsApp and Kakao Alim Talk | Type | Description |
---|---|---|
channels[].approval_status | string | If the channel type is |
Actions
- API endpoints are relative to the base URL allocated to the application. For example, the
/notifications
endpoint refers tohttps://api-{application_id}.notifications.sendbird.com/v1
.
Note: If you want to know the ID and base URL of your application, sign in to your dashboard, go to Settings > Application > General, and then check the Application ID and API request URL.
- It's recommended that the parameter values in API URLs be urlencoded, such as
{user_id}
and{channel_url}
.
List of actions
Action | HTTP request |
---|---|
| |
|
List templates
This API retrieves a paginated list of templates created within one Sendbird application. It provides a general view to all templates within its database, enabling you to utilize the information in and out of the dashboard. You can filter the results by adding parameters that show templates with certain keys or channels, making it easier to search designated templates.
HTTP request
Parameters
The following table lists the parameters that this action supports.
Optional
Parameter name | Type | Description |
---|---|---|
order | string | Specifies the orders the template list by either |
reverse | boolean | Specifies the sorting order. If set to |
channel_key | string | Filters templates containing the specified channel key. |
is_archived | boolean | Filters templates based on archive status. If not specified, it returns templates of all statuses. |
keys | Comma-separated Strings | Filters templates by specific keys. An example can be |
name_contains | string | Filters templates with the names containing the specified value. |
key_contains | string | Filters templates with the keys containing the specified value. |
category_id | int | Filters templates by the specified category ID. |
limit | int | Limits the number of results per page. Acceptable values range from 1 to 100. (Default: |
token | string | Pagination token from the previous response to fetch the next chunk of results. |
Response
If successful, this action returns a list of template resources in the response body like the following:
Error
In the case of an error, an error object is returned.
Get a template
This API lets you fetch a detailed view of a designated template. This provides you with an in-depth view of a single template, enabling easier usage of templates.
HTTP request
Parameters
The following table lists the parameters that this action supports.
Required | Type | Description |
---|---|---|
template_key | string | Specifies the unique key of the template to retrieve. |
Optional | Type | Description |
---|---|---|
version | int | Narrows the search scope to the templates with the specified version. |
Response
If successful, this action returns a template resource in the response body like the following:
Error
In the case of an error, an error object is returned.