# Webhook subscription logs

Webhook logs regarding failures are available for our customers for seven days. You can check information such as how many attempts were executed, the request/response body, the final execution status and more. The following endpoints are available to interact with the logs.

1. [List all logs for a webhook subscription](#organizations-organizationid-workspaces-workspaceid-webhook-subscriptions-webhooksubscriptionid-logs)
2. [Get webhook log details by request ID](#organizations-organizationid-workspaces-workspaceid-webhook-subscriptions-webhooksubscriptionid-logs-1)

**Note**: if you have more than 10 webhook logs, the results may be paginated. To know more about how to use the nextPageToken to get the following results, refer to this [pagination documentation](https://docs.bird.com/api/api-access/common-api-usage#pagination).

## List all logs for a webhook subscription.

> This endpoint allows you to list all logs for a webhook subscription. You can filter the logs by execution status.<br>

```json
{"openapi":"3.0.3","info":{"title":"Notifications","version":"1.0.0"},"servers":[{"url":"https://api.bird.com","description":"Production API"}],"security":[{"accessKey":[]}],"components":{"securitySchemes":{"accessKey":{"description":"Uses the Authorization header: 'AccessKey ' followed by your access key token (e.g., 'Authorization: AccessKey AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIj')","scheme":"AccessKey","type":"http"}},"parameters":{"queryLimit":{"name":"limit","description":"Limits the number of results to return. The default value is 10, the minimum is one and the maximum is 100.","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":10}},"queryCursor":{"name":"pageToken","description":"Pagination token that keeps of track of the current position in the list. Use it to get remaining results that were paginated. To learn more, please refer to Common API Usage Pagination section.\n","in":"query","schema":{"type":"string","maxLength":8000}},"executionStatus":{"name":"executionStatus","description":"The execution status of a webhook.","in":"query","required":false,"schema":{"$ref":"#/components/schemas/ExecutionStatus"}}},"schemas":{"ExecutionStatus":{"type":"string","enum":["succeeded","failed"]},"WebhookLogsList":{"type":"object","additionalProperties":false,"properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/WebhookLog"}}}},"WebhookLog":{"type":"object","required":["requestID","attemptCount","httpStatusCode","executionStatus","createdAt"],"additionalProperties":false,"properties":{"requestId":{"type":"string","format":"uuid","description":"The requestId associated with the webhook log.\n"},"attemptCount":{"type":"integer","description":"The number of times the webhook has been attempted.\nexample: 1, 2, 3\n"},"httpStatusCode":{"type":"integer","description":"The HTTP status code returned by the webhook.\nexample: 200, 400, 500\n"},"executionStatus":{"$ref":"#/components/schemas/ExecutionStatus"},"createdAt":{"type":"string","format":"date-time"}}},"paginationResponse":{"type":"object","properties":{"nextPageToken":{"type":"string","description":"The token that can be passed as pageToken in URL to retrieve the next set of results. If missing, no more results to display."}}}}},"paths":{"/workspaces/{workspaceId}/webhook-subscriptions/{webhookSubscriptionId}/logs":{"get":{"summary":"List all logs for a webhook subscription.","description":"This endpoint allows you to list all logs for a webhook subscription. You can filter the logs by execution status.\n","operationId":"listWebhookLogs","parameters":[{"$ref":"#/components/parameters/queryLimit"},{"$ref":"#/components/parameters/queryCursor"},{"$ref":"#/components/parameters/executionStatus"}],"responses":{"200":{"description":"A list of webhook logs is returned successfully. If no logs exists, an empty list is returned.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WebhookLogsList"},{"$ref":"#/components/schemas/paginationResponse"}]}}}}}}}}}
```

## Get webhook log details by request ID

> This endpoint allows you to get the details of a webhook log using the request ID.<br>

```json
{"openapi":"3.0.3","info":{"title":"Notifications","version":"1.0.0"},"servers":[{"url":"https://api.bird.com","description":"Production API"}],"security":[{"accessKey":[]}],"components":{"securitySchemes":{"accessKey":{"description":"Uses the Authorization header: 'AccessKey ' followed by your access key token (e.g., 'Authorization: AccessKey AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIj')","scheme":"AccessKey","type":"http"}},"parameters":{"requestId":{"name":"requestId","description":"The ID of the webhook event delivery request. This can be found on the header of the notification event delivery attempt with the key `messagebird-request-id`.","in":"query","required":true,"schema":{"$ref":"#/components/schemas/requestId"}}},"schemas":{"requestId":{"title":"Request ID","description":"The ID for the request.","type":"string","format":"uuid"},"WebhookLogWithDetailsList":{"type":"object","additionalProperties":false,"properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/WebhookLogWithDetails"},"description":"The list of webhook logs with details, such as the body and the response, for each delivery attempt.\n"}}},"WebhookLogWithDetails":{"type":"object","additionalProperties":false,"allOf":[{"$ref":"#/components/schemas/WebhookLog"},{"type":"object","properties":{"payloadDetails":{"type":"object","properties":{"response":{"type":"string","description":"The response body of the webhook delivery attempt request.\n"},"request":{"type":"string","description":"The request body of the webhook delivery attempt webhook request.\n"}}}}}]},"WebhookLog":{"type":"object","required":["requestID","attemptCount","httpStatusCode","executionStatus","createdAt"],"additionalProperties":false,"properties":{"requestId":{"type":"string","format":"uuid","description":"The requestId associated with the webhook log.\n"},"attemptCount":{"type":"integer","description":"The number of times the webhook has been attempted.\nexample: 1, 2, 3\n"},"httpStatusCode":{"type":"integer","description":"The HTTP status code returned by the webhook.\nexample: 200, 400, 500\n"},"executionStatus":{"$ref":"#/components/schemas/ExecutionStatus"},"createdAt":{"type":"string","format":"date-time"}}},"ExecutionStatus":{"type":"string","enum":["succeeded","failed"]}}},"paths":{"/workspaces/{workspaceId}/webhook-subscriptions/{webhookSubscriptionId}/logs/details":{"get":{"summary":"Get webhook log details by request ID","description":"This endpoint allows you to get the details of a webhook log using the request ID.\n","operationId":"getWebhookLogDetailsByRequestID","parameters":[{"$ref":"#/components/parameters/requestId"}],"responses":{"200":{"description":"Webhook log details are returned successfully. If no details exists, an empty list is returned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookLogWithDetailsList"}}}}}}}}}
```

### Examples

Let's establish some of our data that will be used in the following examples:

* **Workspace ID**: a1405560-c8d3-4b1a-877d-3f449ad95352
* Webhook subscription ID: 0edf722b-93b4-4451-8a5d-4fafba5cdf8b
* **AccessKey:** abcd

**Retrieving logs for debugging**

In this example, we retrieve all logs for a subscription. It will show information such as the request ID and how many attempts were executed to try to deliver the event succesfully. With that information, you can get more details, such as the request body and response and more. We show how to do that in our next example.

{% tabs %}
{% tab title="Request" %}

```bash
curl -X GET "https://api.bird.com/workspaces/a1405560-c8d3-4b1a-877d-3f449ad95352/webhook-subscriptions/0edf722b-93b4-4451-8a5d-4fafba5cdf8b
-H "Content-Type: application/json" \
-H "Authorization: AccessKey abcd"
```

{% endtab %}

{% tab title="Response (200 - OK)" %}

```json
{
  "nextPageToken": "WzE3MzI1NTk1MTk2ODYsIjk3ZDdmOGY2LTc3N2EtNGY3ZC04NTYxLWFmMDJiZjFjN2I2MSJd",
  "results": [
    {
      "organizationId": "823fbfaf-f14e-4693-b55a-8ec1c17d649e",
      "workspaceId": "a1405560-c8d3-4b1a-877d-3f449ad95352",
      "subscriptionId": "0edf722b-93b4-4451-8a5d-4fafba5cdf8b",
      "requestId": "56878366-5417-414d-b1d9-5f250354f8d1",
      "attemptCount": 7,
      "httpStatusCode": 429,
      "executionStatus": "failed",
      "createdAt": "2024-11-26T10:05:07.083Z",
      "updatedAt": "2024-11-26T10:05:07.083Z"
    },
    {
      "organizationId": "823fbfaf-f14e-4693-b55a-8ec1c17d649e",
      "workspaceId": "a1405560-c8d3-4b1a-877d-3f449ad95352",
      "subscriptionId": "0edf722b-93b4-4451-8a5d-4fafba5cdf8b",
      "requestId": "97d7f8f6-777a-4f7d-8561-af02bf1c7b61",
      "attemptCount": 36,
      "httpStatusCode": 429,
      "executionStatus": "failed",
      "createdAt": "2024-11-25T18:31:59.686Z",
      "updatedAt": "2024-11-25T18:31:59.686Z"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

**Retrieving details about logged requests**

Using the details route, you can get more information about the failures to deliver events. When querying a request ID (which can be found on the header of a request), you can obtain information about all delivery attempts. In the response example below, if there were 36 attempts, you would see 36 log details about each attempt.&#x20;

<figure><img src="https://3210271997-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2Fbq2URw6xgZEkmI0el11g%2FScreenshot%202024-11-26%20at%2011.33.31.png?alt=media&#x26;token=934b89c7-078b-43ee-9543-9473acd8839d" alt=""><figcaption><p><strong>Example of a delivery attempt. You can obtain the request ID on the headers through the key 'messagebird-request-id'</strong></p></figcaption></figure>

{% tabs %}
{% tab title="Request" %}

```bash
curl -X GET "https://api.bird.com/workspaces/a1405560-c8d3-4b1a-877d-3f449ad95352/webhook-subscriptions/0edf722b-93b4-4451-8a5d/logs/details?requestId=56878366-5417-414d-b1d9-5f250354f8d1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {{token}}"
```

{% endtab %}

{% tab title="Response (200 - OK)" %}

```json
{
  "results": [
    {
      "organizationId": "823fbfaf-f14e-4693-b55a-8ec1c17d649e",
      "workspaceId": "a1405560-c8d3-4b1a-877d-3f449ad95352",
      "subscriptionId": "0edf722b-93b4-4451-8a5d-4fafba5cdf8b",
      "requestId": "56878366-5417-414d-b1d9-5f250354f8d1",
      "attemptCount": 36,
      "httpStatusCode": 429,
      "executionStatus": "failed",
      "createdAt": "2024-11-25T18:32:46.962Z",
      "updatedAt": "2024-11-25T18:32:46.962Z",
      "payloadDetails": {
        "response": "<!DOCTYPE html>\n<html>\n<head>\n    <title>Error: Request limit exceeded. Sign up to unlock more requests.</title>\n    <link href=\"https://cdn.example.com/css/app.css\" rel=\"stylesheet\">\n</head>\n<body>\n<div class=\"container\" style=\"padding: 50px\">\n    <div class=\"row\">\n        <div class=\"col-sm-12 text-center\">\n            <h1><img src=\"https://cdn.webhook.site/icon.png\" alt=\"Logo\" style=\"width:40px; margin-top: -5px\">\X</h1>\n\n            <p class=\"lead\">Request limit exceeded. Sign up .</p>\n        </div>\n    </div>\n    <div class=\"row\">\n        <div class=\"col-sm-4 col-sm-offset-4 text-center\">\n                            <p>\n                        You have been rate limited due to too many requests to this URL.\n    This is either because you have not purchased\n, or the endpoint has a rate limit.<br>\n    <br>\n    To remove the request limit limit.\n    <br><br>\n    If you are already subscribed and getting this error, please <a href=\"https://</a>.\n    <br><br>\n            <a class=\"btn btn-lg btn-success\"  href=\"/register\">Sign Up Now</a>\n                    </p>\n                    </div>\n    </div>\n    <div class=\"row\" style=\"margin-top: 40px\">\n        <div class=\"col-sm-12 text-center\">\n            <p class=\"small\"><a href=\"/\">\n                    <i class=\"bi-house-fill\"></i> Home</a>\n                &emsp;\n                <a href=\"/control-panel\">\n                    <i class=\"bi-gear-fill\"></i> Control Panel</a>\n                &emsp;\n                <a href=\"/register\">\n                    <i class=\"bi-person-add\"></i> Create Account</a>\n                &emsp;\n\n                <a href=\"/login\">\n                    <i class=\"bi-door-open-fill\"></i> Login</a></p\u003e\n            <br>\n        </div>\n    </div>\n</div>\n</body>\n</html>\n",
        "request": "{\"service\":\"channels\",\"event\":\"sms.outbound\",\"payload\":{\"id\":\"cb66df55-a060-4f37-be91-c8b8b4c4221e\",\"channelId\":\"8652c8f7-11e2-5f63-a03f-f2998f8bc6f5\",\"sender\":{\"connector\":{\"id\":\"e60a0e31-bb8f-4d56-97e7-3e50b157512d\",\"identifierValue\":\"+12345678\"}},\"receiver\":{\"contacts\":[{\"id\":\"34f282bf-7e19-4224-a1a7-05a63e4cfac9\",\"identifierKey\":\"phonenumber\",\"identifierValue\":\"+123456789\",\"countryCode\":\"NL\"}]},\"body\":{\"type\":\"text\",\"text\":{\"text\":\"help\"}},\"meta\":{},\"reference\":\"\",\"parts\":[{\"platformReference\":\"cb66df55-a060-4f37-be91-c8b8b4c4221e:b2d7a013-86df-4aa7-8245-8f3715c87ae2\"}],\"status\":\"sent\",\"validity\":129600,\"reason\":\"\",\"direction\":\"outgoing\",\"chargeableUnits\":1,\"lastStatusAt\":\"2024-11-25T10:30:00.39Z\",\"createdAt\":\"2024-11-25T10:29:59.757Z\",\"updatedAt\":\"2024-11-25T10:30:00.39Z\",\"batchId\":null}}"
      }
    },
    {
      "organizationId": "823fbfaf-f14e-4693-b55a-8ec1c17d649e",
      "workspaceId": "a1405560-c8d3-4b1a-877d-3f449ad95352",
      "subscriptionId": "0edf722b-93b4-4451-8a5d-4fafba5cdf8b",
      "requestId": "56878366-5417-414d-b1d9-5f250354f8d1",
      "attemptCount": 1,
      "httpStatusCode": 429,
      "executionStatus": "failed",
      "createdAt": "2024-11-25T10:30:00.777Z",
      "updatedAt": "2024-11-25T10:30:00.777Z",
      "payloadDetails": {
        "response": "<!DOCTYPE html>\n<html>\n<head>\n    <title>Error: Request limit exceeded. Sign up to unlock more requests.</title>\n    <link href=\"https://cdn.example.com/css/app.css\" rel=\"stylesheet\">\n</head>\n<body>\n<div class=\"container\" style=\"padding: 50px\">\n    <div class=\"row\">\n        <div class=\"col-sm-12 text-center\">\n            <h1><img src=\"https://cdn.webhook.site/icon.png\" alt=\"Logo\" style=\"width:40px; margin-top: -5px\">\X</h1>\n\n            <p class=\"lead\">Request limit exceeded. Sign up .</p>\n        </div>\n    </div>\n    <div class=\"row\">\n        <div class=\"col-sm-4 col-sm-offset-4 text-center\">\n                            <p>\n                        You have been rate limited due to too many requests to this URL.\n    This is either because you have not purchased\n, or the endpoint has a rate limit.<br>\n    <br>\n    To remove the request limit limit.\n    <br><br>\n    If you are already subscribed and getting this error, please <a href=\"https://</a>.\n    <br><br>\n            <a class=\"btn btn-lg btn-success\"  href=\"/register\">Sign Up Now</a>\n                    </p>\n                    </div>\n    </div>\n    <div class=\"row\" style=\"margin-top: 40px\">\n        <div class=\"col-sm-12 text-center\">\n            <p class=\"small\"><a href=\"/\">\n                    <i class=\"bi-house-fill\"></i> Home</a>\n                &emsp;\n                <a href=\"/control-panel\">\n                    <i class=\"bi-gear-fill\"></i> Control Panel</a>\n                &emsp;\n                <a href=\"/register\">\n                    <i class=\"bi-person-add\"></i> Create Account</a>\n                &emsp;\n\n                <a href=\"/login\">\n                    <i class=\"bi-door-open-fill\"></i> Login</a></p\u003e\n            <br>\n        </div>\n    </div>\n</div>\n</body>\n</html>\n",
        "request": "{\"service\":\"channels\",\"event\":\"sms.outbound\",\"payload\":{\"id\":\"cb66df55-a060-4f37-be91-c8b8b4c4221e\",\"channelId\":\"8652c8f7-11e2-5f63-a03f-f2998f8bc6f5\",\"sender\":{\"connector\":{\"id\":\"e60a0e31-bb8f-4d56-97e7-3e50b157512d\",\"identifierValue\":\"+12345678\"}},\"receiver\":{\"contacts\":[{\"id\":\"34f282bf-7e19-4224-a1a7-05a63e4cfac9\",\"identifierKey\":\"phonenumber\",\"identifierValue\":\"+123456789\",\"countryCode\":\"NL\"}]},\"body\":{\"type\":\"text\",\"text\":{\"text\":\"help\"}},\"meta\":{},\"reference\":\"\",\"parts\":[{\"platformReference\":\"cb66df55-a060-4f37-be91-c8b8b4c4221e:b2d7a013-86df-4aa7-8245-8f3715c87ae2\"}],\"status\":\"sent\",\"validity\":129600,\"reason\":\"\",\"direction\":\"outgoing\",\"chargeableUnits\":1,\"lastStatusAt\":\"2024-11-25T10:30:00.39Z\",\"createdAt\":\"2024-11-25T10:29:59.757Z\",\"updatedAt\":\"2024-11-25T10:30:00.39Z\",\"batchId\":null}}"
      }
    }
  ]
}
```

{% endtab %}
{% endtabs %}
