# Webhooks

Sarafa can send real-time event notifications to your application via webhooks. This allows you to stay informed about important events, such as successful payments or transaction status updates, without the need for continuous polling of the API. You can include a `callback_url` in your API requests to specify the endpoint where these webhook events should be sent.When a relevant event occurs, Sarafa will send an HTTP POST request to the `callback_url` you provided. The body of this request will contain a JSON object detailing the event.To receive webhooks, you need to:

1. Have a publicly accessible URL (`callback_url`) that can accept HTTP POST requests.
2. Configure this `callback_url` in the relevant API request when initiating an action that might trigger a webhook event (e.g., creating a payment link).
3. Implement logic on your server at the `callback_url` to receive and process the incoming webhook data.

**Example of Including `callback_url` in an API Request (e.g., /charge ):**

```json
{
  "phone": "255712345678",
  "amount": "25.00",
  "currency": "SSP",
  "callback_url": "https://your-application.com/webhooks/sarafa"
}
```

**Sample Webhook Payload (JSON):**&#x54;he structure of the webhook payload will vary depending on the event that triggered it. Here’s an example of a webhook payload for a successful payment on a paylink:

```json
{
  "data": {
    "tx_id": "tx_abcdef1234567890",
  }
}
```

[<br>](https://readme.sarafa.ss/api-reference/errors)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sarafa.live/api-reference/webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
