# Webhook subscriptions

## Process

This method involves subscribing one of your endpoints to our webhook. This way, every time there's a change of state within the platform, we'll call that endpoint to inform you of the change. Within this endpoint, you need to interpret the payload sent by us and update the state within your system.

<figure><img src="https://content.gitbook.com/content/3sizVsCVOI8uyboT6DNP/blobs/ayD5VpESbMxql7lbd4CE/image.png" alt=""><figcaption><p>Webhook</p></figcaption></figure>

## Configurations

For this step, you should have your table ready with the equivalent states of Shippify in your platform. If you don't have it yet, access this link to create it. For each state that you need to update in your platform, you'll have to create a separate webhook following the given steps:

### <img src="https://docs.shippify.co/~gitbook/image?url=https:%2F%2F4161681308-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F5jRdo0cXdFHp6c7ZKdof%252Fuploads%252FhWClN6JV7cXBYhVcj1pR%252Fimage.png%3Falt=media%26token=9350f3ef-438f-4f9b-98d7-a5aee121a635&#x26;width=40&#x26;dpr=4&#x26;quality=100&#x26;sign=81abe1a352ece75b5a48782ac8c87cbe6a162f25f58f894d8bd446f069ab2e95" alt="" data-size="line">Create a Webhook <a href="#declarar-un-webhook" id="declarar-un-webhook"></a>

In your Shippify account, go to the left menu, select the Automations section, look for `Send Webhook` in the left sidebar menu, or enter directly through this [link](https://dash.shippify.co/automations/event/7/company) and press the button `CREATE AUTOMATION +`.

<figure><img src="https://content.gitbook.com/content/3sizVsCVOI8uyboT6DNP/blobs/JV35G0UyGBtH4JUNSbYl/image.png" alt=""><figcaption><p>Automatización</p></figcaption></figure>

### <img src="https://docs.shippify.co/~gitbook/image?url=https:%2F%2F4161681308-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F5jRdo0cXdFHp6c7ZKdof%252Fuploads%252FgCi3BsNsKouEfcSbJVuf%252Fimage.png%3Falt=media%26token=fa47692d-7d0a-44fb-bdb4-0d3df3b8cd9b&#x26;width=40&#x26;dpr=4&#x26;quality=100&#x26;sign=82ce46542d7384ac869937c9f28ab968f7d0540f5b358cf5cd02b4e0862be9c7" alt="" data-size="line">Configuring a Trigger

Choose the rules for executing your automation. You need to select the scope in which the automation will work, the event that will trigger the automation, and any additional conditions if needed.&#x20;

For our case, the entity we will choose is `a delivery`, and the event is the state you want the update to be sent. In case your table defines a delivery issue reason or an additional label, you should add this data as conditions.

<figure><img src="https://content.gitbook.com/content/3sizVsCVOI8uyboT6DNP/blobs/fOvLk1D2gCVr55nmpgpg/image.png" alt=""><figcaption><p>Configuración</p></figcaption></figure>

### <img src="https://docs.shippify.co/~gitbook/image?url=https:%2F%2F4161681308-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F5jRdo0cXdFHp6c7ZKdof%252Fuploads%252FPEAUzv8vkHU8gh7zofEU%252Fimage.png%3Falt=media%26token=72874e0e-a741-4087-bf43-67ad7fef7ed5&#x26;width=40&#x26;dpr=4&#x26;quality=100&#x26;sign=6227089c582e7089a98f4281c1da3b6ab1c7f502816c725f7da3e8568c3eebc7" alt="" data-size="line">Configuring a Webhook

In this step, you need to add the information of the endpoint where the notifications will be sent and configure if you want to send extra data.

<figure><img src="https://content.gitbook.com/content/3sizVsCVOI8uyboT6DNP/blobs/tMlWP5G5lYtZyGUUNtiE/image.png" alt=""><figcaption><p>Configuración</p></figcaption></figure>

Define the parameters you need for your Webhook Automation.

<table><thead><tr><th width="211">Parameter</th><th>Description</th><th width="144" data-type="checkbox">Mandatory</th></tr></thead><tbody><tr><td>Webhook</td><td>URL to which the event payload will be sent.</td><td>true</td></tr><tr><td>Method HTTP</td><td>Request method HTTP to send the payload.</td><td>true</td></tr><tr><td>Delivery proof</td><td>In case the event has attached images, choose whether you want to add them to your payload as <code>images.</code> <em><mark style="color:blue;">(Array[])</mark></em>. </td><td>false</td></tr><tr><td>HTTP Headers</td><td>Custom headers for the HTTP request.</td><td>false</td></tr><tr><td>Recipient's signature</td><td>Attach the recipient's signature as a PNG image with a transparent background. Add it to the payload as <code>"signature".</code> <em><mark style="color:blue;">(String)</mark></em></td><td>false</td></tr><tr><td>Base64 format</td><td>The proof of delivery or signature images are sent in base64 format. (If not marked, then it's a URL)</td><td>false</td></tr><tr><td>Tracking URL </td><td>Include private tracking URL of the delivery. You will find it in the payload as <code>trackingUrl.</code> <em><mark style="color:blue;">(String)</mark></em> </td><td>false</td></tr></tbody></table>

After configuring it, click on "create", optionally, you can give it a name. From that moment on, each time the events and conditions are met, we will call your endpoint to notify the event.

### Payload

The payload sent to the webhook is extensive and contains a lot of information. Here's the meaning of each property:

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

<pre class="language-json" data-full-width="true"><code class="lang-json"><strong>{
</strong>    "id": "t-xyz-123",
    "routeId": null,
    "networkId": 25,
    "networkName": "Default-company test",
    "jobId": null,
    "blocked": false,
    "cityId": 2,
    "cityName": "Guayaquil",
    "cityLang": "es",
    "companyId": 1,
    "companyName": "company test",
    "companyPlanType": "postpaid",
    "companyParentId": 1,
    "companyMode": 1,
    "shipperId": null,
    "shipperMobile": null,
    "type": "slot",
    "vehicleCapacity": 3,
    "vehicleId": null,
    "price": 0,
    "insurance": 0,
    "scheduledStartPickingDate": "2024-01-08T17:27:20.000Z",
    "scheduledEndPickingDate": "2024-01-08T17:57:20.000Z",
    "effectivePickupDate": "2024-01-08T16:33:44.000Z",
    "arrivalPickupDate": null,
    "scheduledStartDeliveryDate": "2024-01-08T18:12:20.000Z",
    "scheduledEndDeliveryDate": "2024-01-08T18:42:20.000Z",
    "effectiveDeliveryDate": "2024-01-08T17:27:07.000Z",
    "arrivalDeliveryDate": null,
    "creationDate": "2024-01-08T16:27:21.000Z",
    "pickupDueDate": null,
    "deliveryDueDate": null,
    "pickingPlace":{
      "lat": -2.1594806,
      "lng": -79.895742599,
      "originalAddress": "torres del norte, av. 9, guayaquil 090512, ecuador",
      "address": "torres del norte, av. 9, guayaquil 090512, ecuador"
    },
    "droppingPlace":{
      "lat": -2.1693477,
      "lng": -79.8985397,
      "originalAddress": "san marino shopping, av. francisco de orellana, guayaquil 090512, ecuador",
      "address": "san marino shopping, av. francisco de orellana, guayaquil 090512, ecuador"
    },
    "recipientInfo":{
      "name": "Test recipient",
      "email": "testrecip@test.com"
    },
    "senderInfo":{
      "name": "Test sender",
      "email": "testsender@test.com"
    },
    "senderInfoDecoded": {
        "name": "Test sender",
        "email": "testsender@test.com"
    },
    "receiverInfoDecoded": {
        "name": "Test recipient",
        "email": "testrecip@test.com"
    },
    "state": 7,
    "tags": ["fragile"],
    "items": [
        {
            "id": "Box-12",
            "uuid": "bb3ef06e-647d-412b-92d1-293de6f5ce76",
            "name": "box",
            "size": "S",
            "price": 0,
            "weight": 0,
            "pickedUp": true,
            "delivered": true,
            "sid": "t-shippify2-40254_3",
            "scanned": false,
            "qty": 62
        }
    ],
    "referenceId": "test1234",
    "notes": "{\"comment\":\"test\"}",
    "attempts": 0,
    "countryCode": "EC",
    "countryName": "ECUADOR",
    "currencyCode": "USD",
    "formulaId": "1234",
    "cash": 0,
    "distance": 305.6000061035156,
    "distanceRoute": 0,
    "distanceCharged": 0,
    "totalPackagePrice": 0,
    "eventEntity": "delivery",
    "eventDate": "2024-01-08T17:27:08+00:00",
    "lastEventParams": {
        "author": {
            "type": "client",
            "id": 2534,
            "name": "Denny K. Saas",
            "email": "denny2@shippify.co"
        },
        "method": "UPDATE_ROUTE_STATUS",
        "timestamp": 1704734827
    },
    "colleted": 0,
    "paid": 0,
    "statusUpdateDate": null,
    "partial": 0,
    "notesJson": {
        "reason": "ADDRESS NOT FOUND, NEED CHANGE",
        "reasonId": 11,
        "comment": "test"
    },
    "itemsNumber": 62,
    "itemsWeight": 0,
    "itemsPrice": 0,
    "references": [],
    "incidences": [],
    "cityDepartment": null,
    "metadata": {
        "previousStatus": "processing"
    },
    "previousStatus": "processing",
    "dbId": 948182094,
    "eventType": "DELIVERY_COMPLETED",
    "eventAuthor": {
        "type": "client",
        "id": 2534,
        "name": "Denny K. Saas",
        "email": "denny2@shippify.co"
    },
    "eventCreatedAt": "2024-01-08 17:27:07",
    "eventDescription": "Delivery was completed (previous status was processing)",
    "eventParams": "{\"method\":\"UPDATE_ROUTE_STATUS\"}",
    "status": "completed",
    "eventId": 1704734828038,
    "images": ["https://cdn.dev.shippify.co/delivery-files/77030821377477563003dde3ce5.jpg"],
    "signature": "https://cdn.dev.shippify.co/delivery-files/16839098636794LPh1Zd7S5Goc9BvmQyG7BpT6asb.png",
    "trackingUrl": "https://api.shippify.co/track/t-xyz-123?token={token}"

}
</code></pre>

{% endtab %}

{% tab title="DETAILS" %}

<table><thead><tr><th width="262">Propiedad</th><th>Detalle</th></tr></thead><tbody><tr><td>id</td><td>Delivery ID</td></tr><tr><td>routeId</td><td>Route ID</td></tr><tr><td>networkId</td><td>ID of the drivers network </td></tr><tr><td>networkName</td><td>Name of the drivers network</td></tr><tr><td>cityId</td><td>ID of the pickup city</td></tr><tr><td>cityName</td><td>Name of the pickup city</td></tr><tr><td>cityLang</td><td>Language of the pickup city  </td></tr><tr><td>jobId</td><td>The identifier of the current process, null if it doesn't have a process</td></tr><tr><td>blocked</td><td>Indicates if a task is blocked</td></tr><tr><td>companyId</td><td>Identifier of the delivery company.</td></tr><tr><td>companyName</td><td>Name of the delivery company.</td></tr><tr><td>companyPlanType</td><td>Delivery company plan (pre or post paid)</td></tr><tr><td>companyParentId</td><td>Parent company identifier of the delivery</td></tr><tr><td>companyMode</td><td>Company type: 1 basic, 2 SAAS</td></tr><tr><td>shipperId</td><td>Driver identifier performing the delivery</td></tr><tr><td>shipperMobile</td><td>Driver's phone number </td></tr><tr><td>type</td><td>Delivery type: flex, express or regular</td></tr><tr><td>vehicleCapacity</td><td>Vehicle capacity 1-5 bicycle-truck</td></tr><tr><td>vehicleId</td><td>Vehicle ID</td></tr><tr><td>price</td><td>Delivery price</td></tr><tr><td>insurance</td><td>Delivery insurance</td></tr><tr><td>scheduledStartPickingDate</td><td>Estimated start date of pickup</td></tr><tr><td>scheduledEndPickingDate</td><td>Estimated final date of pickup</td></tr><tr><td>effectivePickupDate</td><td>Acutal pickup date</td></tr><tr><td>arrivalPickupDate</td><td>Date when the driver arrives at the pickup point</td></tr><tr><td>scheduledStartDeliveryDate</td><td>Estimated start date of delivery</td></tr><tr><td>scheduledEndDeliveryDate</td><td>Estimated final date of delivery</td></tr><tr><td>effectiveDeliveryDate</td><td>Actual delivery date</td></tr><tr><td>arrivalDeliveryDate</td><td>Date when the driver arrives at the delivery point</td></tr><tr><td>creationDate</td><td>Date of when the task was created</td></tr><tr><td>pickupDueDate</td><td>Maximum pickup date</td></tr><tr><td>deliveryDueDate</td><td>Maximum delivery date</td></tr><tr><td>pickingPlace</td><td>Pickup information</td></tr><tr><td>pickingPlace.lat</td><td>Pickup point latitude</td></tr><tr><td>pickingPlace.lng</td><td>Pickup point longitude</td></tr><tr><td>pickingPlace.originalAddress</td><td>Pickup address sent by integration</td></tr><tr><td>pickingPlace.address</td><td>Pickup address adjusted by Google</td></tr><tr><td>droppingPlace</td><td>Delivery information</td></tr><tr><td>droppingPlace.lat</td><td>Delivery point latitude</td></tr><tr><td>droppingPlace.lng</td><td>Delivery point longitude </td></tr><tr><td>droppingPlace.originalAddress</td><td>Delivery address sent by integration</td></tr><tr><td>droppingPlace.address</td><td>Delivery address adjusted by Google</td></tr><tr><td>recipientInfo</td><td>Recipient information</td></tr><tr><td>senderInfo</td><td>Sender information</td></tr><tr><td>state</td><td>Delivery status code</td></tr><tr><td>tags</td><td>Delivery digital tags</td></tr><tr><td>items</td><td>Information about the delivery packages</td></tr><tr><td>items.id</td><td>Package ID</td></tr><tr><td>items.name</td><td>Package name</td></tr><tr><td>items.size</td><td>Package size</td></tr><tr><td>items.price</td><td>Package price</td></tr><tr><td>items.weight</td><td>Package weight</td></tr><tr><td>items.pickedUp</td><td>Indicates if a package has been collected</td></tr><tr><td>items.delivered</td><td>Indicates if a package has been delivered</td></tr><tr><td>items.scanned</td><td>Indicates if a package has been scanned</td></tr><tr><td>items.qty</td><td>Quantity of packages</td></tr><tr><td>referenceId</td><td>External identifier of the delivery</td></tr><tr><td>notes</td><td>String with the reason for the state change</td></tr><tr><td>attempts</td><td>Number of delivery attempts</td></tr><tr><td>countryCode</td><td>Country code</td></tr><tr><td>countryName</td><td>Country name</td></tr><tr><td>currencyCode</td><td>Currency symbol of the country</td></tr><tr><td>formulaId</td><td>ID of the quote applied</td></tr><tr><td>distance</td><td>Distance between the pickup point and the delivery point</td></tr><tr><td>distanceRoute</td><td>Distance between the delivery point and the previous point in the route</td></tr><tr><td>distanceCharged</td><td>Distance charged</td></tr><tr><td>totalPackagePrice</td><td>Total of packages prices</td></tr><tr><td>eventEntity</td><td>Entity under which the event was generated</td></tr><tr><td>eventDate</td><td>Date on which the event was executed</td></tr><tr><td>lastEventParams</td><td>Information about the author of the event</td></tr><tr><td>collected</td><td>Indicates whether the packages have already been collected</td></tr><tr><td>paid</td><td>Indicates if the delivery has been paid</td></tr><tr><td>notesJson</td><td>The object where the reason for the change of state is stored</td></tr><tr><td>notesJson.comment</td><td>General comment about the state change</td></tr><tr><td>notesJson.reason</td><td>Reason for the state change</td></tr><tr><td>notesJson.reasonId</td><td>Reason ID</td></tr><tr><td>itemsNumber</td><td>Total of itens in the delivery</td></tr><tr><td>itemsWeight</td><td>Total weight of the delivery</td></tr><tr><td>itemsPrice</td><td>Total price of the delivery</td></tr><tr><td>references</td><td>Delivery extra information</td></tr><tr><td>incidences</td><td>Delivery incidences</td></tr><tr><td>metadata</td><td>Delivery extra information</td></tr><tr><td>previousStatus</td><td>Previous status</td></tr><tr><td>eventType</td><td>Event type</td></tr><tr><td>eventAuthor</td><td>Information of the user who performed the event</td></tr><tr><td>eventCreatedAt</td><td>Date when the event was created</td></tr><tr><td>eventDescription</td><td>Event description</td></tr><tr><td>eventParams</td><td>Parameters sent to the event</td></tr><tr><td>status</td><td>Current status of the delivery</td></tr><tr><td>eventId</td><td>Event ID</td></tr><tr><td>images</td><td>Array of images of the delivery proofs. It can be in URL or base64 format depending on the configuration</td></tr><tr><td>signature</td><td>Attach the recipient's signature as a PNG image with a transparent background. It can be in URL or base64 format depending on the configuration</td></tr><tr><td>trackingUrl</td><td>Private delivery tracking URL</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

### How to test the webhook?&#x20;

Once the automation is created, you can proceed to test it. If you do not yet have an endpoint ready to receive updates, you can use a[ test endpoint ](https://webhook.site/#!/view/4ffe8bb1-eb10-4560-812a-fc7d0ee54c63/aa83de64-adbe-4923-ba2a-e404399a50bc/1)to test the webhook configuration and see the payload. For this example, we will configure the webhook automation to send the update when the delivery changes to "Completed" status.

<figure><img src="https://3636047909-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3sizVsCVOI8uyboT6DNP%2Fuploads%2FJMLnYtTd4Ol0U24uDiqQ%2Fimage.png?alt=media&#x26;token=9be4e9f9-6696-46ef-b3db-1cf98be96df5" alt=""><figcaption><p>Webhook</p></figcaption></figure>

1. Create a delivery [in Dash](https://dash.shippify.co/deliver) (if you have already created one you can skip this step).&#x20;
2. Change the status as appropriate for the automation, in this case, we will change the status to Completed because that is how we configured our test automation.

<figure><img src="https://3636047909-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3sizVsCVOI8uyboT6DNP%2Fuploads%2F31nY8wJ2tJkbi1bJu9DY%2FupdateStatus.gif?alt=media&#x26;token=b35a1a07-c692-4455-aedf-baecf13ce406" alt=""><figcaption><p>Actualización de estado</p></figcaption></figure>

3. Observe the payload sent to the webhook, in this case we used a[ test webhook](https://webhook.site/#!/view/4ffe8bb1-eb10-4560-812a-fc7d0ee54c63/aa83de64-adbe-4923-ba2a-e404399a50bc/1) so we can see the payload sent, in case you already have an endpoint configured to receive notifications you can place a log to identify that the call was made.

<figure><img src="https://3636047909-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3sizVsCVOI8uyboT6DNP%2Fuploads%2FHILilgvIV3wp5wCnCaL8%2Fimage.png?alt=media&#x26;token=6846795e-865a-4a39-811e-c5ee94116948" alt=""><figcaption><p>Webhook</p></figcaption></figure>

Within the automation, you can see the failed and successful executions of the automation along with the identifier of the associated delivery. In this case, we have a successful execution for delivery `t-pruaas-5104.`

<figure><img src="https://3636047909-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3sizVsCVOI8uyboT6DNP%2Fuploads%2FedEp6UXM382HGuVMxB2G%2Fimage.png?alt=media&#x26;token=c1d1d418-531e-4cbe-ab6a-d1a0aeafd249" alt=""><figcaption><p>Histogram</p></figcaption></figure>

## Subscribers to errors

Once the webhook is successfully configured, error subscriptions can be activated. Here you can register one or more emails in which alerts will be sent whenever a notification fails to be sent or the endpoint responds with an error.

<figure><img src="https://3636047909-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3sizVsCVOI8uyboT6DNP%2Fuploads%2FrscvYY9HJT8O77Fn06xh%2Fimage.png?alt=media&#x26;token=267977c3-2f5c-43e8-8e55-8eff1c6217a5" alt=""><figcaption><p>Error subscriptors</p></figcaption></figure>

<figure><img src="https://3636047909-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3sizVsCVOI8uyboT6DNP%2Fuploads%2FpbgEJOeU5vFyfFnRaNwc%2Fimage.png?alt=media&#x26;token=1131a8fc-08dd-4d20-a975-624122a55b29" alt=""><figcaption><p>Error notification mail</p></figcaption></figure>

## Custom configurations

If you need to use the webhook but require receiving a different payload than the previous one, you must request it by email, attaching the payload you want to receive for each state, and send it to <integrations@shippify.co> with the [following table corresponding to Shippify's statuses](https://docs.shippify.co/developers/en/integration-guide/basic-processes/statuses#enlace-de-estados-con-plataforma-externa).&#x20;

<details>

<summary>Request example</summary>

{% code overflow="wrap" %}

```
Good morning,

I would like to update the orders in my platform using a webhook with a customized payload.

* Email of my company in Shippify: example@shippify.co
* Table with the equivalent states in Shippify and the customized payloads: Attached document

Thank you in advance,

Best regards,
Name
```

{% endcode %}

</details>


---

# 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.shippify.co/developers/en/integration-guide/basic-processes/status-update/webhook-subscriptions.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.
