Skip to main content

Creating webhooks

You may subscribe to events through webhooks to be alerted when events are triggered. Visit https://app.terminal49.com/developers/webhooks and click the ‘Create Webhook Endpoint’ button to create your webhook through the UI. If you prefer to create webhooks programmatically then see the webhooks post endpoint documentation.

Available webhook events

Each WebhookNotification event represents some change to a model which you may be notified of. List of supported events:

Receiving webhooks

When an event is triggered, Terminal49 attempts to post to the URL you provided with the webhook. The payload of every webhook is a webhook_notification. Each webhook notification includes a reference_object in its relationships, which is the subject of that notification (e.g., a tracking request or an updated container). Your endpoint must return HTTP 200 OK, HTTP 201, HTTP 202, or HTTP 204. Any other response, including a timeout, triggers retries (up to a dozen attempts).
json_schema
How to Troubleshoot Missing Webhook Notifications

Security

There are a few ways you can verify the webhooks sent by Terminal49. Verify webhook signatures to confirm that received events are sent from Terminal49. Additionally, Terminal49 sends webhook events from a set list of IP addresses. Only trust events coming from these IP addresses.

Webhook notification origin IP

The full list of IP addresses that webhook notifications may come from is:

Verifying the webhook signature (optional)

When you create or get a webhook the model will include an attribute secret. Whenever a webhook notification is delivered, Terminal49 creates a signature by using the webhook secret as the key to generate an HMAC hex digest with SHA-256 on the body. This signature is added as the header X-T49-Webhook-Signature If you would like to verify that the webhook payload has not been tampered with by a 3rd party, then you can perform the same operation on the response body with the webhook secret and confirm that the digests match. Below is a basic example of how this might look in a rails application.

Webhook notification examples

container.updated

The container updated event lets you know about changes to container properties at the terminal, or which terminal the container is (or will be) located at. The changeset attribute is a hash of all the properties that changed on the container. Each changed property is the hash key. The prior value is the first item in the array, and the current value is the second item in the array. For example:
Shows that the pickup last free day has changed from not being set to May 20 2020. Terminal49 shows changes for the following properties: In every case, the attribute container_updated.timestamp tells you when Terminal49 picked up the changes from the terminal. As container availability becomes known or changes at the POD Terminal, Terminal49 sends container_updated events with the key available_for_pickup in the changeset.
The pod_terminal is a relationship of the container. When the pod_terminal changes the id is included. The terminal will be serialized in the included models. N.B. the container_updated_event also has a relationship to a terminal which refers to where the information came from. Currently this is always the POD terminal. In the future this may be the final destination terminal or an off-dock location.

tracking_request.succeeded

shipment.estimated.arrival

container.transport.vessel_arrived