Webhooks
Webhooks are a notification mechanism that allows platforms to listen for events that can occur asynchronously.
Before starting, you need to setup an endpoint at your server that accepts: post, put or patch.
If you need something for testing, you can use https://webhook.site/.
All webhooks are managed through the webhook endpoint:
/v1/webhooks
The receiver is determined based on the key that is used, either platform or entity.
Registering Webhooks
To register a webhook, please checkout the attached Postman collection.
Every webhook in the API response includes verified and verified_at.
Verifying Webhooks
A webhook may need to be verified before it receives events. If it does, the response to POST /v1/webhooks has "verified": false, and Moyasar sends a webhook_verification event to the webhook's URL with a 6-digit code in data.verification_code:
{
"id": "7a1f0e3c-5d2b-4c8e-9f61-2b8d4f0a9c13",
"type": "webhook_verification",
"created_at": "2026-01-01T00:00:00Z",
"secret_token": "<shared_secret>",
"account_name": "<receiver account name>",
"data": {
"webhook_id": "c4bc247d-5288-4673-9b40-39c082ac7fbb",
"verification_code": "482913"
}
}
This event is sent once and isn't retried. If your server didn't receive it, request a new code (see below).
Send the code back with the same key you used to create the webhook. Until the webhook is verified, it receives no events, and they aren't delivered later either.
curl -X POST https://api.moyasar.com/v1/webhooks/:id/verify \
-u YOUR_PLATFORM_KEY: \
-H 'Content-Type: application/json' \
-d '{ "code": "482913" }'
The code is valid for 30 minutes. After 5 wrong codes, request a new one. To get a new code, call POST /v1/webhooks/:id/resend_verification. You can request a new code once a minute, and the previous code stops working.
For the full request, response and error details, see Verify Webhook.
Payload
Every webhook request includes the same envelope:
{
"id": "<event-uuid>",
"type": "<event-type>",
"created_at": "2026-01-01T00:00:00Z",
"secret_token": "<shared_secret>",
"account_name": "<receiver account name>",
"live": true,
"data": {}
}
The event metadata is also sent as HTTP headers:
X-Event-IDX-Event-TypeX-Event-Attempt-NumberX-Event-Secret
Platform Webhook Events
These events are available when registering webhooks using a Platform API key.
| Event | When It Fires | Purpose | data |
|---|---|---|---|
merchant_created | After a merchant is created via POST /v1/merchants | Sync new merchant onboarding into your platform systems | Merchant |
merchant_updated | After a merchant is updated via PUT /v1/merchants/:id | Keep merchant profile/settings in sync | Merchant |
merchant_semi_activated | When Moyasar changes merchant status to semi_active | Merchant is activated, but settlements are held (entity is put on hold) | Merchant |
merchant_activated | When Moyasar changes merchant status to active | Merchant is fully activated (hold removed), settlements can proceed | Merchant |
merchant_un_hold | When a previously-held merchant becomes active (fired after merchant_activated) | Explicit signal that a hold was removed and settlements can resume | Merchant |
merchant_review_failed | When Moyasar changes merchant status to missing_docs | Review failed due to missing/invalid documents; prompt you to update/resubmit docs | Merchant |
merchant_disabled | When Moyasar changes merchant status to disabled (also when moving to dormant) | Merchant is deactivated; payment processing/settlements are stopped | Merchant |
merchant_hold | When Moyasar changes merchant status to hold | Settlements are paused (e.g. investigation/chargebacks) | Merchant |
merchant_rejected | When Moyasar changes merchant status to rejected | Merchant was rejected; payment processing/settlements are stopped | Merchant |
balance_transferred | When a settlement transfer is completed and the recipient is notified | Notify the recipient (Entity or Platform) that a transfer settled | Transfer |
merchant_balance_transferred | When a settlement transfer is completed for an Entity that belongs to a Platform | Notify the Platform that one of its merchants received a transfer | Transfer |
merchant_contract_generated | Once the merchant is approved, Moyasar generates the Nafath contract. | Notifies the platform that the merchant's Nafath contract is ready for signing | Merchant |
Merchant Payment, Payout and Invoice Events
These events are about your merchants' payments, payouts and invoices, not about your platform. They let one platform webhook receive the payment, payout and invoice events of all your merchants, so you don't need to register a webhook on each merchant.
Merchant events are opt-in. A platform webhook only receives them when you list them in events when registering it. A webhook registered without events receives the platform events above, but not these, and they aren't listed in its events in GET /v1/webhooks.
curl -X POST https://api.moyasar.com/v1/webhooks \
-u YOUR_PLATFORM_KEY: \
-H 'Content-Type: application/json' \
-d '{
"http_method": "post",
"url": "https://example.com/moyasar/merchant-events",
"shared_secret": "<shared_secret>",
"events": ["merchant_payment_paid", "merchant_payment_failed", "merchant_payout_paid"]
}'
The payload has the same envelope, with top-level merchant_id and entity_id identifying the merchant the event belongs to. merchant_id is the ID from POST /v1/merchants, and entity_id is the merchant's entity (the one used as a split recipient). data is the same payment, payout or invoice object the merchant's own webhook receives. account_name and secret_token are your platform's, as in every platform event.
{
"id": "<event-uuid>",
"type": "merchant_payment_paid",
"created_at": "2026-01-01T00:00:00Z",
"secret_token": "<shared_secret>",
"account_name": "<platform name>",
"live": true,
"merchant_id": "<merchant-id>",
"entity_id": "<entity-id>",
"data": {}
}
Events from your merchants' test payments, payouts and invoices are delivered too, with "live": false.
Each event matches the merchant event without the merchant_ prefix. Webhooks the merchant registered on its own account keep receiving their events as usual.
| Event | When It Fires | data |
|---|---|---|
merchant_payment_paid | A merchant's payment is paid | Payment |
merchant_payment_failed | A merchant's payment fails | Payment |
merchant_payment_authorized | A merchant's payment is authorized | Payment |
merchant_payment_captured | A merchant's authorized payment is captured | Payment |
merchant_payment_voided | A merchant's payment is voided | Payment |
merchant_payment_refunded | A merchant's payment is refunded | Payment |
merchant_payment_verified | A merchant's card verification payment succeeds | Payment |
merchant_payment_abandoned | A merchant's payment is abandoned | Payment |
merchant_payment_canceled | A merchant's payment is canceled | Payment |
merchant_payment_expired | A merchant's payment expires | Payment |
merchant_payout_initiated | A merchant's payout is initiated | Payout |
merchant_payout_paid | A merchant's payout is paid | Payout |
merchant_payout_failed | A merchant's payout fails | Payout |
merchant_payout_canceled | A merchant's payout is canceled | Payout |
merchant_payout_returned | A merchant's payout is returned | Payout |
merchant_invoice_canceled | A merchant's invoice is canceled | Invoice |
merchant_invoice_expired | A merchant's invoice expires | Invoice |
Timeouts
The webhook client will timeout whenever one of the following durations are exceeded:
- Connect: 10 seconds
- Write: 5 seconds
- Read: 10 seconds
If your server takes more that 10 seconds to finish its job, please put the job on a queue and respond to the webhook client as soon as possible.
Webhook Lifecycle
When a webhook succeeds, an attempt will be logged and the Webhook Attempts log and it is done.
If a webhook fails, then Moyasar will retry the webhook event four more times, making it five attempts including the first one.
Here is the timing for the retries:
| Attempt Number | Delay Time |
|---|---|
| 1 | 60 seconds |
| 2 | 600 seconds = 10 minutes |
| 3 | 1800 seconds = 30 minutes |
| 4 | 3600 seconds = 1 hour |
Webhook Attempts Log
Moyasar servers will keep track of all webhook attempts for an arbitrary amount of time (they will be cleaned without any notice, they are used for development purposes and not for production).
To view webhook attempts (in descending order), make a get request to the following using the receiver key (platform or entity):
/v1/webhooks/attempts
Each attempts will have a result data field that indicates whether it succeeded or failed:
- success: the webhook was delivered successfully
- dns_error: cannot resolve hostname because of a DNS error
- connection_error: cannot establish a connection to the server
- connection_timeout: Connection timed out
- malformed_response: invalid response was returned
- tls_error: cannot establish a TLS connection
- response_timeout: request was sent but read (response) timed out
- response_error: the server did not return a
2xxresponse - invalid_url: invalid webhook URL