Overview
Webhooks allow your application to receive real-time notifications when events occur in Phoenix. When an order is created or its status changes, Phoenix can automatically send an HTTP POST request to your specified webhook endpoints.Getting Started
1. Obtain Webhook API Key
Before setting up webhooks, you need to obtain a webhook API key from Phoenix:- Contact our support team at main@phoenix.market
- Request webhook access for your integration
2. Define Your Webhook Endpoints
Your webhook endpoints should:- Accept POST requests
- Return a
200
status code to acknowledge receipt - Process the webhook payload within 30 seconds
- Validate the HMAC signature in the
X-Webhook-Signature
header - Handle duplicate events gracefully (use
id
for idempotency)
HMAC Signature
Phoenix provides HMAC signatures to help you verify the authenticity of webhook requests. The signature is calculated using yourclient_secret
and the payload of the request, allowing you to validate that the webhook came from Phoenix.
The signature is sent in the X-Webhook-Signature
header.
The signature’s timestamp is sent in the X-Webhook-Timestamp
header.
The signature is calculated using the HMAC-SHA256 algorithm.
Signature Verification Example
Here’s how to verify the webhook signature in your endpoint:3. Share Your Webhook Endpoint URLs
Once you’ve defined your webhook endpoints, you need to share the exact URLs with Phoenix:- Determine the full URL path where you want to receive webhooks (e.g.,
https://yourdomain.com/webhooks/phoenix-status-updates
) - Contact our support team at main@phoenix.market with your webhook endpoint URL
- Phoenix will configure the system to send webhook events to your specified URL
Webhook Events
Each webhook event contains a uniqueid
field for deduplication. Implement idempotency using this id
as Phoenix may retry events if your endpoint doesn’t return a 200
status code or if the request fails.
Current events:
payment_link_created
payment_link_status_updated
order_created
order_status_updated
Event Payload Structure
This structure may change over time, so do stay up to date with the docs.Payment Link Created Example Event
Payment Link Created Example Event
Payment Link Updated Example Event
Payment Link Updated Example Event
Order Created Example Event
Order Created Example Event
Order Updated Example Event
Order Updated Example Event
Querying Orders
You can query order details at any time using the Phoenix API. This is useful for getting the complete order information or checking the current status.You can use this endpoint to test your connection to the Phoenix service before setting up webhooks.
Endpoint
Example Request
Example Response
View Example Response
View Example Response
Order Status Update Webhook
Endpoint Configuration
Endpoint:/phoenix-order-status-updated
Event Type: order.status.change
Triggered: When an order’s status changes
Common Status Values
fulfilled
- Order has been completed successfullyexpired
- Order expired before completionpending
- Order is awaiting processing
Implementation Example
Payload Structure
View Payload Structure
View Payload Structure
Webhook Response
Your webhook endpoint should return a JSON response with a200
status code. You can optionally include an external_partner_id
field to associate your own order ID with the Phoenix order:
external_partner_id
(string): Your internal order ID or reference that you want to associate with the Phoenix order. This helps you link Phoenix orders to your own system’s order tracking.
Authentication
Phoenix uses Bearer token authentication for webhooks:- Header:
Authorization: Bearer <webhook_secret>
- Webhook Secret: Provided by Phoenix support team
- Validation: Always verify the authorization header exists and contains a valid Bearer token
View Authentication Code Example
View Authentication Code Example
Best Practices
- Validate Authentication: Always check the
Authorization
header - Validate Required Fields: Ensure all required fields are present
- Implement Idempotency: Use
id
to handle duplicate events - Respond Quickly: Process webhooks within 30 seconds
- Log Events: Keep logs for debugging and monitoring
- Use HTTPS: Only accept webhooks over secure HTTPS connections
- Handle Errors Gracefully: Return appropriate HTTP status codes
Support
For webhook-related questions or to request webhook access:- Email: main@phoenix.market