SectionFor developers
Work with the REST API and API token
The REST API gives your CRM, website or script access to chat data: customers, conversations, messages, articles and sending to channels. Every request is a POST to one address with a function name and your API token.
You need account owner access to app.ayweb.chat/account.
Get the token
- Open app.ayweb.chat/account, the “Installation” tab.
- In the “API token” block, click the copy icon next to the token.
Request format
- Address
- https://app.ayweb.chat/script/include/api.php
- Method
- POST: form fields or a JSON body.
- token
- Your API token. Pass it in the request body.
- function
- The function name, e.g. get-user, get-conversations, send-message.
- Other fields
- Function arguments, e.g. user_id or conversation_id.
Example: get a customer by their ID.
curl -X POST https://app.ayweb.chat/script/include/api.php \
-d token=YOUR_TOKEN \
-d function=get-user \
-d user_id=123The same with a JSON body:
curl -X POST https://app.ayweb.chat/script/include/api.php \
-H "Content-Type: application/json" \
-d '{"token":"YOUR_TOKEN","function":"get-user","user_id":123}'Response
A successful response is JSON with the success and response fields:
{ "success": true, "response": { "id": 123, "first_name": "Emma", "email": "[email protected]" } }An error is JSON with status “error”, a code in response and an explanation in message.
What you can do
- Customers
- get-user, get-users, add-user, update-user, delete-user.
- Conversations
- get-conversations, get-conversation, get-user-conversations, search-conversations, new-conversation, update-conversation-status, update-tags.
- Messages
- send-message, get-new-messages, send-email.
- Channels
- whatsapp-send-template, telegram-send-message and other functions for sending to messengers.
- Articles
- get-articles.
If it doesn’t work
- token-not-found
- No token was passed. Add the token field to the request body.
- invalid-token
- The token is wrong. Copy it again from the “Installation” tab.
- function-not-found
- There’s no function with that name. Check the spelling.
- missing-argument
- A required argument is missing. Its name is given in message.
The API token gives full access to the account. Don’t publish it in your site’s code or the browser — call the API only from your server. The API has no OpenCart or order creation functions.
Was this article helpful?