Message Webhook API¶
Overview¶
The Rex Nutribot App webhook allows you to send messages directly from your custom WhatsApp-like widget into our system. Instead of working through third-party services (e.g., Twilio or WABA), you will directly post message data in JSON format to our message-webhook. Our backend will process each message, store necessary metadata, and respond accordingly.
Endpoint Details¶
URLs:
-
Development:
https://api.rex.fit/[org-id]/dev/v1/message-webhook -
Production:
https://api.rex.fit/[org-id]/prod/v1/message-webhook
Method: POST
Content-Type: application/json
Authentication¶
Required Fields¶
| Field | Type | Description | Example |
|---|---|---|---|
from_id |
string | A unique identifier representing the end user in your system |
"user_12345" |
message_sid |
string | A unique identifier for the message (ensures idempotency) |
"msg_abc987" |
timestamp |
string/integer | The time the message was sent by the user (UNIX timestamp or ISO8601) |
"1672531200" or "2024-12-18T12:00:00Z" |
Optional Fields¶
| Field | Type | Description | Example |
|---|---|---|---|
message_body |
string | The text of the user's message | "Hello, can I get some help?" |
image_urls |
array | Single-element array with one publicly accessible image URL |
["https://.../food.jpg"] |
audio_urls |
array | Single-element array with one publicly accessible audio URL |
[".../voice_note.ogg"] |
Note: Only provide one media item at a time per message. For multiple images or audios, send separate messages each with a unique message_sid.
Example Request¶
{
"from_id": "user_abc123",
"message_sid": "msg_xyz789",
"timestamp": "1672531200",
"message_body": "Here is my meal, this is gruyere cheese btw.",
"image_urls": ["https://example.com/images/food.jpg"],
"audio_urls": []
}
Response Codes¶
| Code | Description |
|---|---|
| 200 OK | Message received and processed |
| 200 OK | Already processed (duplicate message_sid) |
| 400 Bad Request | Missing required fields or invalid data |
| 405 Method Not Allowed | Unsupported HTTP method |
| 500 Internal Server Error | Internal server error |
Duplicate Message Handling¶
If message_sid was previously processed, the webhook will return 200 OK with "Already processed" and will not reprocess the message.
Media Requirements¶
- Ensure provided URLs are accessible (no authentication required, or use tokenized/signed URLs)
- Images:
.jpg,.jpeg,.pngformats - Audio:
.ogg,.mp3,.wavformats