Basic API
Introduction
This page describes /basic API endpoints. These endpoints are protected by
Basic auth and can only be used by a valid JSON API Token.
You need an API Token which can be requested from support@kero.chat.
The examples in this page use variables that you'd want configure on a terminal session:
API_URL=https://api.kero.chat/rbm
AGENT_ID='<your agent ID>'
BASIC_AUTH="Authorization: Basic $API_TOKEN_BASE_64"
Batch create
Create a new batch.
Note that after you created a new batch, you must submit the batch to send messages.
You should consider using the agent submit endpoint to send transactional messages. The batch feature on this API is for use by brand agents that are approved to send messages in bulk. That being said, when those transactional messages are not time critical and are queued on your side, batching could be the best fit for your case.
Endpoint: POST /basic/batch
Request schema
{
agentId: string,
smsSenderId: string|null,
content: MessageContent|null,
template: TemplateContent|null,
userRef: string|null,
recipients: {
msisdn: string,
userRef: string|null,
values: string[]|null,
}[],
campaignName: string|null
}
- The
agentIdidentifies the Brand Agent that will be used to send the messages in the batch. - Either the
contentof thetemplateproperty must have a value, but not both. - The
contentproperty contains a Message Content object. - The
templateproperty contains a Template Content object - When the
templateis constrained to a specific brand agent theagentIdprovided here must match the one specified by the template. - The
contentor thetemplatemust contain message content for theproviderTypeassociated with theagentId. - The
recipientsproperty recipient is identified by amsisdnand an array ofvalues. - In the
content, or in thetemplate.modelyou can use one or more place-holders. - A
place-holderhas the format{{k}}werekis the zero based index. For example, the snippetHello {{0}} {{1}}contains two place-holders. - When you use place-holders, the
valuesarray must have enough items to transform all place-holders. For the example snippet,values=["Bobby", "Smith"]will be transformed to send the message textHello Bobby Smith. - The
userRefproperty can be specified for the batch or on the recipient level, not both. - Specify
"userRef": "auto"if you'd like to use the generatedbatchIdin theuserRef. The reference of each message will be the prefixed by thebatchId, followed by a sequence number. - The
userRefvalue is optional. When it is supplied, it cannot be an empty string, and must have a length of36or less. - The total size of the request must be less than 6 MB. If you have no
place-holder, you can send around
80 000messages per batch. However, if you use batchuserReffor lookup purposes it is best to limit the size of a batch to10 000messages. - If you supply a
smsvalue with thecontentand fallback is activated for your account, an SMS will be sent when the recipient cannot receive RCS messages. - When you specify a
campaignName, a campaign instance will be created when you submit the batch. A batch with a campaign name cannot have anyuserRefvalues. - If the
smsSenderIdis notnullthis value takes precedence over the sender ID provided on the template.
Response schema
{
batchId: string;
}
- Use this
batchIdto submit the batch for processing.
Example 1 - content based
Create a file called batch-001.json with this content.
{
"agentId": your-agent-id
"content": {
"rcs": {
"contentMessage":{
"text": "Welcome {{0}}, your color is {{1}}"
}
}
},
"recipients": [
{"msisdn": "+000723111", "values": ["Bobby","Red"]},
{"msisdn": "+000723121", "values": ["Sue","Blue"]}
]
}
Now you can create a batch from this file:
JSON_H="Content-Type: application/json"
curl -s -H $BASIC_AUTH -H $JSON_H $API_URL/basic/batch -d @batch-001.json | jq
You can use jq to get the batch ID:
BATCH_ID=`curl -s -H $BASIC_AUTH -H $JSON_H $API_URL/basic/batch -d @batch-001.json | jq -r '.batchId'`
echo "Your batch ID is $BATCH_ID"
Example 2 - template based
Here we use the template from the template create
example. Here we have two template parameters: firstName and color.
Create a file called batch-002.json with this content:
{
"agentId": your-agent-id,
"template": {
"id": "my-example",
"model": {
"firstName" : "{{0}}",
"color": "{{1}}"
}
},
"recipients": [
{"msisdn": "+000723111", "values": ["Bobby","Red"]},
{"msisdn": "+000723121", "values": ["Sue","Blue"]}
]
}
Notice that the model maps the template parameters to indexes in the values
array.
JSON_H="Content-Type: application/json"
curl -s -H $BASIC_AUTH -H $JSON_H $API_URL/basic/batch -d @batch-001.json | jq
Brand agent list
Returns the array of brand agents configured for your account.
Endpoint: GET /basic/agents
Response schema
{
id: string,
name: string,
providerType: "RCS"|"WhatsUp",
}[]
Example
curl -H $BASIC_AUTH -X GET $API_URL/basic/agents | jq
Batch submit
Submits a previously created batch to send a message to every recipient.
Endpoint: GET /basic/batch/:batch_id/submit
Response schema
{
message: string;
}
- The message is
okwhen the submission was successful. - This endpoint is idempotent: an appropriate
messageis returned when a duplicate submit is made.
Example
curl -s -H $BASIC_AUTH $API_URL/basic/batch/$BATCH_ID/submit
Brand agent token
Endpoint: GET /basic/agent-token/:agent_id
Returns a token that is used for authentication on the Agent API.
Response schema
{
agentToken: string,
expiry: timestamp,
expiryEpoch: number
}
- The
agentTokenis the token you use to construct the bearer auth header, e.g.AGENT_AUTH="Authorization: Bearer $AGENT_TOKEN - The two
expiryproperties represent the same date value. The value forexpiryEpochisexpiryexpressed in epoch seconds.
Example
curl -s -H $BASIC_AUTH $API_URL/basic/agent-token/$AGENT_ID
Campaign query
List the most recent campaigns that match the criteria.
Endpoint: POST /basic/campaign/query
Request schema
{
time: {
from: timestamp|null,
until: timestamp|null
} | null,
limit: number|null
}
- The value for
timeis optional - if not supplied the response contains the most recent campaigns. - When provided, the resolution of
fromanduntilmust be minutes or finer. Example:2023-09-01T12:44:00Z - The
frommust be less thanuntil. - The
limitspecifies the maximum amount of objects to return. The default is10, and it must be less than or equal to10000.
Response schema
{
id: string,
name: string,
agentId: string,
created: timestamp,
messageCount: number,
}[]
Example
Fetch the 10 most recent campaigns:
JSON_H="Content-Type: application/json"
curl -s -H $BASIC_AUTH -H $JSON_H $API_URL/basic/campaign/query -d '{}' | jq
Campaign detail
Fetch details of a specific campaign.
Endpoint: GET /basic/campaign/:msg-id
Response schema
{
id: string,
name: string,
agentId: string,
created: timestamp,
messageCount: number,
}[]
Example
curl -H $BASIC_AUTH $API_URL/basic/campaign/62238a49dcf6c | jq
Campaign delete
Delete a campaign.
Endpoint: DELETE /basic/campaign/:id
- This endpoint is idempotent: if a campaign with this
iddoes not exist, the endpoint does not return an error.
curl -X DELETE -H $BASIC_AUTH $API_URL/basic/campaign/62238a49dcf6c
Fallback config read
Read the fallback settings associated with your account.
Endpoint: GET /basic/config/fallback
Response schema
{
autoUnicode: bool,
maxLongParts: number,
enabled: bool
}
- If you have not configured fallback, the default configuration is shown.
- The default configuration will always have
enabledset tofalse.
Example
curl -s -H $BASIC_AUTH $API_URL/basic/config/fallback
Message template create
Create a message template.
Endpoint: POST /basic/template
Request Schema
{
id: string,
name: string,
content: MessageContent,
agentId: string|null,
smsSenderId: string|null,
}
- The
idwill be used when sending messages. Its value is limited to lower case letters (atoz), numbers (0to9) and may contain dashes (-). The value must start with a letter. - The value for
namemust be supplied and cannot be an empty string. - The
contentproperty contains a Message Content. - The
contentmay containparameter-references. - A
parameter-referencehas the format{{p}}wherepis may have upper or lower case letters (atozorAtoZ) and underscore (_). An example parameter value is{{home_address}}. - The
agent_idoptionally associates the template with a brand agent. - When a template is associated with a brand agent you cannot use it to send messages from any other brand agent.
- When the
agent_idis not null or empty, it should identify a Brand Agent from the brand agent list. However, it is possible to provide the ID of a brand agent that is not yet registered. - This
smsSenderIdwill be used to send SMS fallback messages.
Response Schema
The response is a Template object. It is the same as the request, with one
additional property.
{
id: string,
name: string,
content: {
rcs: object,
sms: string|null
},
agentId: string|null,
parameters: string[]
}
- The
parametersare the values that must be supplied when using the templates. These are collected from theparameter-referencesused in the content.
Example
Create a file called template-001.json with this content.
{
"id": "my-example",
"name": "Just an example",
"content": {
"rcs": {
"contentMessage": {
"text": "Welcome {{firstName}}, your color is {{color}}"
}
}
}
}
Now you can create a template from this file:
JSON_H="Content-Type: application/json"
curl -s -H $BASIC_AUTH -H $JSON_H $API_URL/basic/template -d @template-001.json
Message template update
Update a message template.
Endpoint: PUT /basic/template
Request Schema
The same object as the create endpoint with this additional rule:
- The
ididentifies an existing template.
Response Schema
Same response as the create endpoint.
Message template details
Get the details of a message template.
Endpoint: GET /basic/template/:id
Response Schema
Same response as the create endpoint.
Message template list
Endpoint: GET /basic/templates
Returns the array of your message templates.
Response Schema
Template[]
The Template object is defined in the
create endpoint.
Message template delete
Delete a template.
Endpoint: DELETE /basic/template/:id
- This endpoint is idempotent: if a template with this
iddoes not exist, the endpoint does not return an error.
Message queries
Get the list of the most recent messages that match the criteria.
Endpoint: POST /basic/message/query
Request schema
{
filter: {time: TimeFilter} | {userRef: ReferenceFilter} | null
limit: number|null
}
- You can filter by
timeor byuserRef, not both. - If you do not supply a filter, the most recent messages will be returned.
- A maximum count contained in the result is the value of
limit. The default is10. - The
limitmust be less than or equal to10000.
The TimeFilter schema looks like this:
{
from: string|timestamp,
until: string|timestamp,
}
- You can truncate the
fromanduntilvalues. The system uses the string comparison operator on the input. - A value for
fromoruntilmust be supplied. The defaults are2000and9999respectively. - Ensure that
fromis always strictly less thanuntil.
Reference filter:
{
value: string;
method: "Exact" | "BeginsWith" | null;
}
- The
valuecannot be an empty string. - This filter matches
valueagainst the messagerefproperty. - The
methodspecifies the kind of match. The default isExact.
Response schema
{
id: string,
agentId: string,
created: timestamp,
msisdn: string,
userRef: string | null,
sendStatus: null | string,
sendStatusReason: null | string
}[]
- The
sendStatusandsendStatusReasonproperties are filled in during the message transmission process. For test messages these values are not available. - The
sendStatusReasonhas a value when thesendStatusis such that additional information is required. For example, whensendStatusisfailedsendStatusReasonwill give more information. - Messages older than
62days are not available to this endpoint.
Example
Here we fetch all messages created during the first quarter of 2025. Take note
that the untilTime value excludes April, but includes March 2024.
JSON_H="Content-Type: application/json"
CRIT='{"filter":{"time": {"from": "2024-01", "until": "2025-04"}}}'
curl -s -H $BASIC_AUTH -H $JSON_H $API_URL/basic/message/query -d $CRIT | jq
Message detail
Fetch details of a specific message.
Endpoint: GET /basic/message/:msg-id
Response schema
{
id: string,
agentId: string,
content: object,
created: timestamp,
msisdn: string
sendStatus: string | null
sendStatusReason: string | null
sendStatusTime: timestamp | null
userId: string | null
}
Example
curl -H $BASIC_AUTH $API_URL/basic/message/174a9eca-51d1-48e9-8999-73bfa2d35008
Reply query
Get the list of the most recent replies that match the criteria.
Endpoint: POST /basic/reply/query
Request schema
{
time: TimeFilter | null;
msidn: string | null;
limit: number | null;
}
- If you do not supply a time, the most recent messages will be returned.
- The
TimeFilteris described the message query endpoint. - A maximum count contained in the result is the value of
limit. The default is10. - The
limitmust be less than or equal to10000.
Time filter:
{
from: string|timestamp,
until: string|timestamp,
}
- You can truncate the
fromanduntilvalues. The system uses the string comparison operator on the input. - If you specify a
time, a value forfromoruntilmust be supplied. The defaults are2000and9999respectively. - Ensure that
fromis always strictly less thanuntil.
Response schema
{
agentId: string,
created: timestamp,
msisdn: string,
replyType: `Text`|`Item`,
replyValue: string
}[]
Example
Here we fetch all replies created during the first quarter of 2025. Take note
that the untilTime value excludes April, but includes March 2024.
JSON_H="Content-Type: application/json"
CRIT='{"time": {"from": "2024-01", "until": "2025-04"}}'
curl -s -H $BASIC_AUTH -H $JSON_H $API_URL/basic/reply/query -d $CRIT | jq