Documentation

Badges API

You can manage badges via API

Required Headers for all API endpoints

ParameterDescription
x-api-keyYour public API key used for the project
AuthorizationBearer token what you can get from the back office (Admin panel / Settings / Bearer tokens) for back-to-back integrations

Create new badge

POST Endpoint https://chatbackend.watchers.io/external/badge

Request payload

Parameter

Type

Required

Description

text

string

Yes

Text on badge. Better use not more than 10-12 characters, and also use emoji. (Not limited)

backgroundColor

string

Yes

HEX Color of badge

textColor

string

Yes

HEX Color of text

tooltip

string

Yes

Short description for badge.
Limited to 140 characters.

communicationPic

string

Yes

The message image that the user will see when entering the chat when he has been assigned this badge.

  • File size: No more than 10 MB
  • Dimensions: At least 190×190 px

communicationTitle

string

Yes

The message title that the user will see when entering the chat when he has been assigned this badge.
Limited to 140 characters.

communicationText

string

Yes

The message text that the user will see when entering the chat when he has been assigned this badge.
Limited to 180 characters.


CURL example

curl --location -X POST 'https://chatbackend.watchers.io/external/badge' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${Bearer token from admin panel}' \
--header 'x-api-key: ${API KEY}' \
--data '{
    "text": "best",
    "backgroundColor": "#ea00fc",
    "textColor": "#000000",
    "tooltip": "5555",
    "communicationPic": null,
    "communicationText": "11111",
    "communicationTitle": "11111"
}'

Example response

{
  "id": 3,
  "text": "best",
  "backgroundColor": "#ea00fc",
  "textColor": "#000000",
  "tooltip": "5555",
  "communicationPic": null,
  "communicationText": "11111",
  "communicationTitle": "11111"
}

Update badge by id

PATCH Endpoint https://chatbackend.watchers.io/external/badge/:id

Request payload

Parameter

Type

Required

Description

text

string

Yes

Text on badge. Better use not more than 10-12 characters, and also use emoji. (Not limited)

backgroundColor

string

Yes

HEX Color of badge

textColor

string

Yes

HEX Color of text

tooltip

string

Yes

Short description for badge.
Limited to 140 characters.

communicationPic

string

Yes

The message image that the user will see when entering the chat when he has been assigned this badge.

  • File size: No more than 10 MB
  • Dimensions: At least 190×190 px

communicationTitle

string

Yes

The message title that the user will see when entering the chat when he has been assigned this badge.
Limited to 140 characters.

communicationText

string

Yes

The message text that the user will see when entering the chat when he has been assigned this badge.
Limited to 180 characters.


CURL example

curl --location -X PATCH 'https://chatbackend.watchers.io/external/badge/:id' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${Bearer token from admin panel}' \
--header 'x-api-key: ${API KEY}' \
--data '{
    "text": "best100",
    "backgroundColor": "#ea00fc",
    "textColor": "#000000",
    "tooltip": "5555",
    "communicationPic": null,
    "communicationText": "11111",
    "communicationTitle": "11111"
}'

Example response

true

Get list of all badges

CURL example

curl --location 'https://chatbackend.watchers.io/external/badge' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${Bearer token from admin panel}' \
--header 'x-api-key: ${API KEY}'

Example response

[
  {
    "id": 1,
    "text": "cool",
    "backgroundColor": "#ea00fc",
    "textColor": "",
    "tooltip": "5555",
    "communicationPic": null,
    "communicationText": "11111",
    "communicationTitle": "11111",
    "userCount": 1
  }
]

Get badge by id

CURL example

curl --location 'https://chatbackend.watchers.io/external/badge/:id' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${Bearer token from admin panel}' \
--header 'x-api-key: ${API KEY}'

Example response

{
  "id": 1,
  "text": "cool",
  "backgroundColor": "#ea00fc",
  "textColor": "",
  "tooltip": "5555",
  "communicationPic": null,
  "communicationText": "11111",
  "communicationTitle": "11111"
}

Delete badge by id

CURL example

curl --location -X DELETE 'https://chatbackend.watchers.io/external/badge/:id' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${Bearer token from admin panel}' \
--header 'x-api-key: ${API KEY}'

Example response

true

Assign badge to user by userid

Request payload

ParameterTypeRequiredDescription
userIdsarray of stringsYesExample { "userIds": ["123","321"] }

CURL example

curl --location -X POST 'https://chatbackend.watchers.io/external/badge/4/users' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${Bearer token from admin panel}' \
--header 'x-api-key: ${API KEY}' \
--data ' { "userIds": ["123","321"] }'