Add Message As-User
Before you can interact with this API, you need to generate your token by following API Integration : Initialization.
Purpose
Use this endpoint to automatically send a message from a User. The message is delivered instantly to the recipient.
Request
Endpoint:
POST https://main.ginalne.com/raven/xapi/v1/message:send
Header:
Authorization: Bearer <YOUR_API_TOKEN>
Content-Type: application/json
Body:
{
"username" : UserName,
"topic": {
"type" : TopicType,
"name": string(255)
},
"recipient": [
{
"name": string(255),
"contact": [
{
"type" : ContactKey,
"name" : string(255),
"key" : PhoneNumber,
} , ...
]
} , ...
],
"message": string(4096)
}
Here is a list of data types used in this payload:
Response
Succeed
{
"data": number // chat_id
"notification": "Chat Sent Successfully"
}
Error:
| Code | Message | Solution |
|---|---|---|
| 401 | Unauthorized | Verify the token. Ensure it is valid and not expired. |
| Pro is not active! | Ensure the current Pro subscription is active | |
| 400 | Persona Topic-type recipients are only allowed one. | Check the payload. If the topic type is 'persona', only one Persona can be specified as recipient. |
| Group as recipients are only allowed one. | Check the payload. If the topic type is 'group', only one Group can be specified as recipient. | |
| The Recipient index %A must have at least one contact. | Check the payload. Recipient at index %A must include at least one contact. | |
| Invalid ContactType at recipient index %A and contact index %B. | Check the payload. The contact type at recipient index %A and contact index %B must be a valid ContactType value. | |
| ** | Dynamic error. Please read the message carefully for troubleshooting guidance. | |
| 404 | User is not found! | Check the 'username' field. Make sure the user exists and is linked to an active Pro. |
| Recipients must have at least one. | Check the 'recipient' field. It must not be empty. | |
| Topic Type is invalid! | Check the 'topic.type' value. It must match one of the supported TopicType values: 'persona', 'group', or 'mass'. |
Example
Sending to Whatsapp Contact (cURL):
curl -X POST https://main.ginalne.com/raven/xapi/v1/message:send -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_API_TOKEN" -d '{
"username": "your_username",
"topic": {
"type": "persona",
"name": "Test Message Bot"
},
"recipient": [
{
"name": "Ginalne Official",
"contact": [
{
"type": "whatsapp",
"name": "Main Contact",
"key": "+6285174314159"
}
]
}
],
"message": "Hello! This is a message from Raven 🚀"
}'
Security Tip
Never expose your API Token key in frontend code or client-facing apps. For those, generate and use temporary tokens via your backend.