Webhooks
Switch sends outbound HTTP callbacks for transaction lifecycle events. A single transaction can produce up to two webhook deliveries:- a receiver webhook to the receiving application’s
transactionWebhookUrl - a sender callback to the sender’s
callbackUrl(or sender apptransactionWebhookUrlfallback)
1) Receiver webhook
Sent when a transaction is initiated and addressed to a tag owned by the receiving application.- Target:
transactionWebhookUrlon the receiving app - Event name:
TRANSACTION_INITIATED - Purpose: notify the receiver that a payment request needs acceptance or rejection
2) Sender callback
Sent after the transaction reaches a terminal outcome.- Target: sender’s
callbackUrl, or if not supplied, the sender app’stransactionWebhookUrl - Event names:
TRANSACTION_COMPLETEDTRANSACTION_REJECTEDTRANSACTION_EXPIRED
- Purpose: inform the sender of the final result
event value and the same transaction metadata.
Example:
Payload rules
All delivery payloads include:event: one ofTRANSACTION_INITIATED,TRANSACTION_COMPLETED,TRANSACTION_REJECTED,TRANSACTION_EXPIREDtransaction: the transaction snapshot with:reference- sender and receiver tag names
- sender and receiver app IDs/names
amount,currency,narrationcreatedAtandexpiresAt
Encryption
If the target application has JWE encryption enabled, the body may be sent as a JWE compact string rather than raw JSON.- Header:
Content-Encryption: JWE - Decrypt using the application’s own private key after validating the webhook signature
- The signature is still computed over the raw HTTP body that was delivered
Signature verification
Every outbound webhook includes:X-Switch-TimestampX-Switch-Signature
Verification flow
- Read the raw request body exactly as received.
- Reject stale timestamps.
- Recompute the HMAC with your
webhookSecret. - Compare signatures in constant time.
- If encryption is enabled, decrypt the payload next.
- Return a
2xxresponse promptly.
Delivery expectations
- Switch retries failed webhook deliveries up to 3 times.
- Retry backoff is exponential.
- Failed deliveries can be inspected later through webhook-related endpoints.
Operational recommendations
- Treat webhook handling as idempotent.
- Persist delivery attempts by transaction/reference.
- Verify the signature before parsing business data.
- Decrypt only after signature validation when encryption is enabled.