Notifications›Webhooks
Webhooks
TrustCold POSTs status changes to your HTTPS URL, including cancel and delete.
curl -X PUT https://trustcoldeg.com/api/v1/b2b/webhook \
-H "Authorization: Bearer CLIENT_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"url":"https://partner.example/trustcold/hooks"}'First registration
{
"data": {
"url": "https://partner.example/trustcold/hooks",
"secret_set": true,
"secret": "Qm3…40 characters…shown only the first time"
}
}URL refused
{
"message": "The domain points to a private or reserved address.",
"errors": {
"url": ["The domain points to a private or reserved address."]
}
}POST /webhook/test
{
"data": {
"event_id": "7f3c1e2a-5d34-4b86-9a52-0c9e2a6d41b8",
"result": "delivered",
"error": null
}
}Key points
- Register — PUT /webhook with {"url":"https://partner.example/hooks"\}. The secret is shown once.
- Test — POST /webhook/test sends a signed webhook.test event and tells you the result.
- Rotate — POST /webhook/rotate-secret issues a new secret. The old one stops working at once.
- Verify — Check X-TrustCold-Signature-V2 on every request. See Verify signatures.
Register one HTTPS URL. TrustCold POSTs a signed JSON event each time a trip status changes. If your server is down, the trip still continues.
The secret is returned once, the first time you register a URL. Store it in your secrets manager. TrustCold keeps it encrypted and cannot show it again. Lost it? Rotate it.
URL rules
| Rule | Why |
|---|---|
https:// on port 443 | Webhooks are never sent in clear text |
| A public domain name | No IP addresses, localhost, .local, .internal |
| Resolves to public addresses only | Private, loopback, link-local and cloud-metadata ranges are refused. Checked when you save and again on every delivery |
| No credentials in the URL | Use the signature instead of user:pass@ |
| Redirects are not followed | Answer on the registered URL itself |
Manage
| Call | What it does |
|---|---|
GET /webhook | Shows the URL and whether a secret is set (never the secret) |
PUT /webhook | Sets or changes the URL. Keeps the current secret |
POST /webhook/rotate-secret | New secret, shown once. The old one stops working immediately |
POST /webhook/test | Sends a signed webhook.test event and returns delivered or failed |
curl -X POST https://trustcoldeg.com/api/v1/b2b/webhook/rotate-secret \
-H "Authorization: Bearer CLIENT_KEY" \
-H "Accept: application/json"curl -X POST https://trustcoldeg.com/api/v1/b2b/webhook/test \
-H "Authorization: Bearer CLIENT_KEY" \
-H "Accept: application/json"Request headers
| Header | Value |
|---|---|
X-TrustCold-Event | Unique event id. Same as event_id in the body |
X-TrustCold-Timestamp | Unix time (seconds) when TrustCold signed the request |
X-TrustCold-Signature-V2 | t=<timestamp>,v1=<hex> where v1 is HMAC-SHA256 of "{timestamp}.{raw body}". Use this one. |
X-TrustCold-Signature | sha256=<hex> HMAC of the raw body only. Kept for older integrations. It has no replay protection |
Step by step with code: Verify signatures.
Delivery
- Answer with any 2xx within 4 seconds. Do slow work after you reply.
- Otherwise TrustCold tries up to 3 times in a row. Events can arrive more than once and out of order: use
event_idand the tripstatus, not arrival order. - The payload carries ids, the code and the new status. It never carries the client key or the webhook secret.
Event
{
"event_id": "7f3c1e2a-5d34-4b86-9a52-0c9e2a6d41b8",
"event": "trip.status_changed",
"trip": {
"id": 10025,
"code": "TRUST10025",
"status": "en_route",
"status_label": "En route",
"deleted": false
}
}