# Webhook History (GET)

Retrieve the history of incoming requests to a specific webhook — what was sent, what was rendered, and whether an alert was delivered.

## Endpoint

```
GET https://api.pocketalert.app/v1/webhooks/{tid}/history
```

## Authentication

> **Info: Required**
>
> Include one of these headers in your request:
> - `Token: <your-api-key>` — Get it from [API Keys](https://pocketalert.app/account/apikeys)
> - `Authorization: Bearer <jwt-token>` — From [Login](https://info.pocketalert.app/api/user/login.md)

## Request

### Path Parameters

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `tid` | string | ✅ | Webhook unique identifier |

### Query Parameters

| Parameter | Type | Default | Description |
|-----------|------|:-------:|-------------|
| `page` | integer | `1` | Page number |
| `per` | integer | `50` | Items per page (max `200`) |
| `status` | string | — | Filter by outcome: `success` or `error` |

### Example Request

**cURL**

```bash
curl -X GET "https://api.pocketalert.app/v1/webhooks/kblf7mh9j8jjyeh4fx/history?per=25&status=error" \
  -H "Token: your-api-key"
```

**JavaScript**

```javascript
const tid = 'kblf7mh9j8jjyeh4fx';
const response = await fetch(`https://api.pocketalert.app/v1/webhooks/${tid}/history?per=25`, {
  headers: { 'Token': 'your-api-key' }
});
const history = await response.json();
```

**Python**

```python
import requests

tid = 'kblf7mh9j8jjyeh4fx'
response = requests.get(
    f'https://api.pocketalert.app/v1/webhooks/{tid}/history',
    headers={'Token': 'your-api-key'},
    params={'per': 25, 'status': 'error'}
)
print(response.json())
```

## Response

### Success Response

> **Tip: 200 OK**
>
> Returns a paginated list of requests, newest first

| Field | Type | Description |
|-------|------|-------------|
| `requests` | array | Recorded requests |
| `total` | integer | Total requests within the retention window |
| `page` | integer | Current page |
| `per` | integer | Items per page |
| `retention_days` | integer | How many days of history your plan keeps (`0` = unlimited) |
| `webhook` | object | `tid`, `name`, `url`, `is_active` |

Each item in `requests`:

| Field | Type | Description |
|-------|------|-------------|
| `id` | integer | Request identifier |
| `method` | string | HTTP method used by the sender |
| `source_ip` | string | Caller IP address |
| `content_type` | string | Request content type |
| `query` | string | Raw query string |
| `headers` | object | Request headers (sensitive ones are redacted) |
| `body` | string | Request payload |
| `size` | integer | Payload size in bytes |
| `status` | string | `success` or `error` |
| `error_code` | string | Failure reason, empty on success |
| `rendered_message` | string | Message produced from your template |
| `message_tid` | string | Identifier of the created message, empty on failure |
| `priority` | integer | Resolved alert level |
| `duration_ms` | integer | Processing time |
| `created_at` | string | When the request arrived |

```json
{
  "requests": [
    {
      "id": 412,
      "method": "POST",
      "source_ip": "140.82.115.16",
      "content_type": "application/json",
      "query": "",
      "headers": { "User-Agent": "GitHub-Hookshot", "Authorization": "[redacted]" },
      "body": "{\"repository\":{\"name\":\"pocketalert\"}}",
      "size": 38,
      "status": "success",
      "error_code": "",
      "rendered_message": "Push to pocketalert",
      "message_tid": "yrst1db64dbbe7euurpmanhdy",
      "priority": 1,
      "duration_ms": 24,
      "created_at": "18.07.2026 16:45:06"
    }
  ],
  "total": 1,
  "page": 1,
  "per": 50,
  "retention_days": 90,
  "webhook": {
    "tid": "kblf7mh9j8jjyeh4fx",
    "name": "GitHub Push",
    "url": "cs994rqfkk8ljngt",
    "is_active": true
  }
}
```

### Error Codes

When `status` is `error`, `error_code` explains what happened:

| Code | Meaning |
|------|---------|
| `inactive` | The webhook is disabled, so no alert was sent |
| `invalid_json` | The payload could not be parsed as JSON |
| `empty_message` | The template resolved to an empty string — usually a `%path%` that does not exist in the payload |
| `encryption_failed` | The message could not be encrypted |
| `save_failed` | The message could not be stored |
| `daily_limit` | The account's [daily message limit](https://info.pocketalert.app/features/daily-limits.md) was reached. The call got `429` and no alert was sent; the payload and the rendered message are kept here |

### Error Responses

| Status | Description |
|:------:|-------------|
| `401` | Unauthorized — Invalid or missing token |
| `404` | Not Found — Webhook does not exist |

## Notes

> **Warning: Retention**
>
> History is kept for a limited number of days depending on your plan (see `retention_days`): 7 days on Free, 30 on Starter, 90 on Medium, and 365 on Large. Older requests are removed automatically, as are the oldest entries once a single webhook exceeds 1,000 recorded calls.

> **Info: Privacy**
>
> Payloads are encrypted at rest with your personal key, the same way message content is. Authorization, cookie and API-key headers are replaced with `[redacted]` before storage.
