> For the complete documentation index, see [llms.txt](https://docs.terminal.africa/tship/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.terminal.africa/tship/webhooks/simulate-webhook.md).

# Simulate Webhook

## /webhooks

<mark style="color:green;">`POST`</mark> `https://sandbox.terminal.africa/v1/webhooks/simulate`

Queue a webhook notification using the current data for a real resource. Delivery is asynchronous (same path as live webhooks).

#### Headers

{% hint style="info" %}
**Staging only.** This endpoint is not available in production. Use it to fire a webhook event from a live resource you own, without changing that resource’s status.
{% endhint %}

| Name                                            | Type   | Description                      |
| ----------------------------------------------- | ------ | -------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Set value to `Bearer SECRET_KEY` |
| Content-Type                                    | String | Set value to `application/json`  |

#### Request Body

<table data-search="false"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>event</td><td>String</td><td>Webhook event to simulate. Required if <code>events</code> is not provided. Must be one of the supported webhook events.</td></tr><tr><td>events</td><td>Array of String</td><td>List of webhook events to simulate in one request. Required if <code>event</code> is not provided. Each event must include the matching resource ID below.</td></tr><tr><td>shipment_id</td><td>String</td><td>Required for <code>shipment.*</code>, <code>connected_account.weight_discrepancy.detected</code>, <code>reconciliation.*</code>, <code>regulatory_document.*</code> and <code>hub_issue.*</code> events.</td></tr><tr><td>address_id</td><td>String</td><td>Required for <code>address.*</code> events.</td></tr><tr><td>packaging_id</td><td>String</td><td>Required for <code>packaging.*</code> events.</td></tr><tr><td>insurance_id</td><td>String</td><td>Required for <code>insurance.*</code> events.</td></tr><tr><td>claim_id</td><td>String</td><td>Required for <code>claim.*</code> events.</td></tr><tr><td>transaction_id</td><td>String</td><td>Required for <code>transaction.*</code> events. Use the wallet <code>transactionId</code>.</td></tr><tr><td>webhook_id</td><td>String</td><td>ID of a specific webhook endpoint (e.g. <code>WA-1234567890ABCDEF</code>). Optional. If provided, that webhook must exist, be active, and be subscribed to the event being simulated. Otherwise the request fails.</td></tr><tr><td>correction_type</td><td>String</td><td><code>reconciliation.corrected</code> only. <code>voided</code> or <code>replaced</code> — which correction shape to send when the shipment has no real correction to replay. Optional; a shipment that really was corrected replays what actually happened, and anything else defaults to <code>voided</code>.</td></tr></tbody></table>

#### Resource requirements by event

| Event(s)                                                                                                  | Required field                                   |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| `address.created`, `address.updated`, `address.deleted`                                                   | `address_id`                                     |
| `packaging.created`, `packaging.updated`                                                                  | `packaging_id`                                   |
| `shipment.created`, `shipment.updated`, `shipment.in-transit`, `shipment.delivered`, `shipment.cancelled` | `shipment_id`                                    |
| `connected_account.weight_discrepancy.detected`                                                           | `shipment_id` with an already recorded detection |
| `hub_issue.reported`, `hub_issue.updated`, `hub_issue.reminder`                                           | `shipment_id` with hub issues                    |
| `insurance.success`, `insurance.failed`                                                                   | `insurance_id`                                   |
| `claim.success`, `claim.failed`                                                                           | `claim_id`                                       |
| `transaction.success`, `transaction.failed`                                                               | `transaction_id`                                 |
| `reconciliation.flagged`, `reconciliation.billed`, `reconciliation.corrected`                             | `shipment_id`                                    |
| `regulatory_document.pending`, `regulatory_document.uploaded`, `regulatory_document.complete`             | `shipment_id`                                    |

{% hint style="warning" %}
You must own the resource, and you must have at least one active webhook subscribed to the event. Simulation does **not** update the resource (for example, it will not mark a shipment as delivered).
{% endhint %}

#### Example request

```json
{
  "event": "shipment.delivered",
  "shipment_id": "SH-ABC123"
}
```

### Simulate a weight discrepancy alert

For `connected_account.weight_discrepancy.detected`, use a staging shipment you own that **already has a recorded connected-account weight discrepancy detection**. An active webhook must subscribe to this exact event.

```json
{
  "event": "connected_account.weight_discrepancy.detected",
  "shipment_id": "SH-EXAMPLE000001"
}
```

Replace the example shipment ID with an eligible staging shipment. A shipment without a recorded detection cannot produce this event through simulation. Simulation sends the recorded detection summary; it does not create a discrepancy or charge the detection fee again. As with other simulations, the endpoint is unavailable in production.

See the [event payload and field definitions](https://docs.terminal.africa/tship/miscallaneous/sample-webhook-event-payloads/shipment.md#connected-account-weight-discrepancy-detection).

### Simulate a hub issue event

For `hub_issue.reported`, `hub_issue.updated` and `hub_issue.reminder`, use a staging shipment you own that a drop-off hub has **already raised issues about**. Simulation sends the shipment's [`hub_issues`](https://docs.terminal.africa/tship/shipment.md#the-hub-issues-object) as they are now; it does not create an issue, answer one or charge anything.

```json
{
  "events": ["hub_issue.reported", "hub_issue.reminder"],
  "shipment_id": "SH-EXAMPLE000001"
}
```

| Event                | The test delivery names                                               |
| -------------------- | --------------------------------------------------------------------- |
| `hub_issue.reported` | Every issue on the shipment, with `change: "reported"`.               |
| `hub_issue.updated`  | The issue that changed last since it was reported, with its `change`. |
| `hub_issue.reminder` | What one answer covers, with `change: "reminder"`.                    |

The request fails for a shipment with no hub issues, for `hub_issue.updated` when nothing has changed since the issues were reported, and for `hub_issue.reminder` when nothing waits for an answer. See the [payloads](https://docs.terminal.africa/tship/miscallaneous/sample-webhook-event-payloads/hub-issue.md) and the [hub issues workflow](https://docs.terminal.africa/tship/guides/hub-issues-workflow.md#7-test-in-the-sandbox).

#### Example request (multiple events)

```
{
  "events": ["transaction.success", "transaction.failed"],
  "transaction_id": "TXN-9Z8Y7X6W5V4U3T2S"
}
```

{% tabs %}
{% tab title="200: Webhook simulation queued successfully" %}

```
{
  "status": true,
  "message": "Webhook simulation queued successfully",
  "data": {
    "results": [
      {
        "event": "shipment.delivered",
        "resource_type": "shipment",
        "resource_id": "SH-ABC123",
        "queued": true
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.terminal.africa/tship/webhooks/simulate-webhook.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
