# Best Practices This guide covers best practices for integrating with the Xenia Connect API. ## Webhook Handling - Always process webhooks asynchronously to ensure quick response times and prevent timeouts: - Use the `eventId` field to prevent duplicate processing: - Webhooks can be fired out of order; although highly unlikely, we expect you to retrieve the latest data from the API and handle it instead of relying on the event data itself. - To tell us you have processed the webhook successfully and prevent retries, your HTTP Response code should be 204. - Send a 4xx or a 5xx in order to have Xenia retry the webhook. Webhooks have an exponential backoff retry mechanism, retrying up to 5 times over a period of 24 hours. ## Webhook Configuration - **Maximum webhooks**: 5 per environment - **Event filtering**: Subscribe only to events you need to reduce noise - **Unique URLs**: Each webhook must have a unique URL ## Common Pitfalls to Avoid 1. **Don't ignore webhook retries**: Xenia retries failed webhooks up to 5 times - ensure your endpoint can handle retries 2. **Don't assume state order**: States can skip (e.g. `ENQUIRY.CREATED` directly to `ENQUIRY.CLOSED`) 3. **Don't ignore pagination**: Large result sets require handling pagination