Webhooks
Sadeem webhooks allow external systems to trigger actions and post messages on Odoo records via a simple HTTP POST. Each webhook has a unique token and is bound to a specific record and action.
The sadeem.saas.webhook Model
| Field | Type | Description |
|---|---|---|
token |
Char (unique) | Auto-generated 64-character hex token. Never changes after creation. |
model_name |
Char | Technical name of the Odoo model (e.g., sadeem.subscription) |
rec_id |
Integer | ID of the target record |
trigger_action |
Char | Method name to call on the record when the webhook fires (optional) |
message_type |
Selection | How the message body is posted: email, comment, notification, whatsapp, sms, auto_comment, tracking, activity |
subtype_xmlid |
Selection | Odoo message subtype: mail.mt_note (internal note), mail.mt_comment (public comment), mail.mt_file, mail.mt_alert, mail.mt_audit |
Note
The token is generated as two concatenated UUIDs with dashes removed, giving a 64-character hex string. It is unique across the database and enforced by a DB constraint.
Webhook URL Format
POST https://your-master.sadeem.cloud/sadeem/webhook/<token>
- No
Authorizationheader required — the token in the URL acts as the secret - Content-Type:
application/json - CSRF exempt (
csrf=False)
Request Body
{
"message": "Optional message text to post in chatter",
"message_type": "comment",
"subtype_xmlid": "mail.mt_comment"
}
All fields are optional. If message_type and subtype_xmlid are omitted, the values stored on the webhook record are used as defaults.
Complete curl Example
curl -X POST https://your-master.sadeem.cloud/sadeem/webhook/abc123def456... \
-H "Content-Type: application/json" \
-d '{
"message": "Deployment completed successfully",
"message_type": "comment",
"subtype_xmlid": "mail.mt_comment"
}'
Response Format
| Status | Body | Meaning |
|---|---|---|
200 |
{} |
Webhook executed successfully |
400 |
(empty or minimal error) | Webhook token not found |
500 |
{"error": "Unknown error SSB C/W42"} |
Exception during execution |
What Happens on Trigger
When Sadeem receives a POST to /sadeem/webhook/<token>, it executes the following steps in order:
- Look up the webhook record by token. Return
400if not found. - Resolve the target record:
env[model_name].browse(rec_id). - If
trigger_actionis set, callrecord.<trigger_action>()on the target record. - If
messageis present in the request body, post it to the record's chatter usingmessage_typeandsubtype_xmlid(body values take precedence over webhook defaults). - Return
200with{}.
Warning
If an exception occurs at any step, the endpoint returns 500 with {"error": "Unknown error SSB C/W42"}. Check the Odoo server log for the full traceback.
Common Use Cases
Backup server callback
After a scheduled backup completes, the Backup Server POSTs to the Master's webhook to trigger _compute_backup_state() on the subscription. This updates the backup state badge in real time without polling.
GitHub push hook
Configure a GitHub repository webhook to POST to Sadeem when a commit is pushed. Set trigger_action to your Git deployment method to automatically pull and deploy the latest code to a subscription or stage.
Payment provider callback
Trigger subscription state transitions when a payment provider confirms success or failure. Set trigger_action to the method that moves the subscription between billing states.
Monitoring alerts Configure an uptime monitor (e.g., UptimeRobot, BetterStack) to POST to a subscription's webhook when a downtime event is detected. Sadeem posts an alert message directly to the subscription's chatter.
Creating a Webhook
- Navigate to SAAS Management → Configuration → Webhooks → New
- Set Model Name (e.g.,
sadeem.subscription) and Record ID - Optionally set Trigger Action (the Python method name, without parentheses)
- Choose a Message Type and Subtype for chatter messages
- Save — the Token is generated automatically
- Copy the full webhook URL from the Token field
Tip
Use the Copy URL button on the webhook form to get the full endpoint URL ready to paste into an external service.
Security Considerations
- The token is a 64-character hex string — treat it like a password. Anyone who has the URL can trigger the webhook.
- Rotate a compromised token by deleting the webhook record and creating a new one.
- For additional security, restrict access to
/sadeem/webhook/*at the Nginx level usingallow/denyIP rules when the calling service has a fixed IP range. - Do not log webhook URLs in external monitoring systems or commit them to source control.