# Webhook AidboxTopicDestination {% hint style="info" %} This functionality is available starting from version 2410 and requires [FHIR Schema](../../modules/profiling-and-validation/fhir-schema-validator/) validation engine to be [enabled](../../modules/profiling-and-validation/fhir-schema-validator/). {% endhint %} This page describes an AidboxTopicDestination, which allows sending events described by an AidboxSubscriptionTopic to a specific HTTP endpoint. The webhook AidboxTopicDestination works in the following way: * Aidbox stores events in the database within the same transaction as the CRUD operation. * After the CRUD operation, Aidbox collects unsent messages (refer to the `maxEventNumberInBatch` parameter) from the database and sends them to the specified endpoint via a POST request. * If an error occurs during sending, Aidbox will continue retrying until the message is successfully delivered. {% content-ref url="./" %} [.](./) {% endcontent-ref %} ## Configuration To use Webhook with [#aidboxsubscriptiontopic](webhook-aidboxtopicdestination.md#aidboxsubscriptiontopic) you have to create [#aidboxtopicdestination](webhook-aidboxtopicdestination.md#aidboxtopicdestination) resource. You need to specify the following profile: ``` http://aidbox.app/StructureDefinition/aidboxtopicdestination-webhook-at-least-once ``` ### Available Parameters
Parameter nameValue typeDescription
endpoint *valueUrlWebhook URL.
timeoutvalueUnsignedIntTimeout in seconds to attempt notification delivery (default: 30).
keepAlivevalueIntegerThe time in seconds that the host will allow an idle connection to remain open before it is closed (default: 120, -1 - disable).
maxMessagesInBatchvalueUnsignedIntMaximum number of events that can be combined in a single notification (default: 20).
headervalueStringHTTP header for webhook request in the following format: <Name>: <Value>. Zero or many.
\* required parameter. ## Examples
POST /fhir/AidboxTopicDestination
content-type: application/json
accept: application/json

{
  "resourceType": "AidboxTopicDestination",
  "meta": {
    "profile": [
      "http://aidbox.app/StructureDefinition/aidboxtopicdestination-webhook-at-least-once"
    ]
  },
  "kind": "webhook-at-least-once",
  "id": "webhook-destination",
  "topic": "http://example.org/FHIR/R5/SubscriptionTopic/QuestionnaireResponse-topic",
  "parameter": [
    {
      "name": "endpoint",
      "valueUrl": "https://aidbox.requestcatcher.com/test"
    },
    {
      "name": "timeout",
      "valueUnsignedInt": 30
    },
    {
      "name": "maxMessagesInBatch",
      "valueUnsignedInt": 20
    },
    {
      "name": "header",
      "valueString": "User-Agent: Aidbox Server"
    }
  ]
}
## **Status Introspection** Aidbox provides `$status` operation which provides short status information of the integration status: {% tabs %} {% tab title="Request" %} ```yaml GET /fhir/AidboxTopicDestination//$status content-type: application/json accept: application/json ``` {% endtab %} {% tab title="Response" %} {% code title="200 OK" %} ```json { "resourceType": "Parameters", "parameter": [ { "valueDecimal": 2, "name": "messageBatchesDelivered" }, { "valueDecimal": 0, "name": "messageBatchesDeliveryAttempts" }, { "valueDecimal": 2, "name": "messagesDelivered" }, { "valueDecimal": 0, "name": "messagesDeliveryAttempts" }, { "valueDecimal": 0, "name": "messagesInProcess" }, { "valueDecimal": 0, "name": "messagesQueued" }, { "valueDateTime": "2024-10-03T07:23:00Z", "name": "startTimestamp" }, { "valueString": "active", "name": "status" }, { "name": "lastErrorDetail", "part": [ { "valueString": "Connection refused", "name": "message" }, { "valueDateTime": "2024-10-03T08:44:09Z", "name": "timestamp" } ] } ] } ``` {% endcode %} {% endtab %} {% endtabs %} Response format:
PropertyTypeDescription
messageBatchesDeliveredvalueDecimalTotal number of batches that have been successfully delivered.
messageBatchesDeliveryAttemptsvalueDecimal

Number of batch delivery attempts that failed.

It represents the overall failed delivery attempts.

messagesDeliveredvalueDecimalTotal number of events that have been successfully delivered.
messagesDeliveryAttemptsvalueDecimal

Number of delivery attempts that failed.

It represents the overall failed delivery attempts.

messagesInProcessvalueDecimalCurrent number of events in the buffer being processed for delivery.
messagesQueuedvalueDecimalNumber of events pending in the queue for send.
startTimestampvalueDateTimeAidboxTopicDestination start time in UTC.
statusvalueStringAidboxTopicDestination status is always active, which means that AidboxTopicDestination will try to send all received notifications.
lastErrorDetailpartInformation about errors of the latest failed attempt to send an event. This parameter can be repeated up to 5 times. Includes the following parameters.

lastErrorDetail

.message

valueStringError message of the given error.

lastErrorDetail

.timestamp

valueDateTimeTimestamp of the given error.