Subscribe to each event by its exact name. There is no wildcard. The full list of valid event-type strings is returned by
GET /api/p/v1.0/webhooks/event-types.
When document events fire
- Uploaded fires when a document is first saved. In rare cases it can fire again for the same document, so deduplicate on
data.document.id. - Deleted fires when a document is removed.
- A rename, or a change to the document type, sends no event. For example, a call to Change load document type or Change trip document type sends nothing. If you need the current name and type, read the documents again with the list-documents endpoint.
Payload
Document events use the standard Alvys webhook envelope. The envelopeversion is v1. data has two fields:
- The holder key from the table above (for example
loadNumber). It identifies the record the document belongs to. document, an object that describes the document.
null value are omitted, except the top-level subsidiaryId.
For document events, the envelope id has the form {documentId}-{etag}. Treat the id as an opaque string. Use it only to deduplicate, and do not parse it.
The document object
Download links expire after 10 minutes
downloadUrl is valid for 10 minutes from the time Alvys builds the event, not from the time your endpoint receives it. Alvys builds the event one time. Each retry sends the same body, so a retry can carry a link that has already expired.
If expiresAt is in the past, or the download fails, get a fresh link from the list-documents endpoint for the holder:
- Load:
GET /api/p/v2.0/loads/{loadNumber}/documents(List load documents) - Trip: List trip documents
- Driver: List driver documents
- Carrier: List carrier documents
- Truck: List truck documents
- Trailer: List trailer documents
Trip documents
For trip document events, the two identifiers are different:data.tripIdis the trip id.data.document.parentIdis the load number of the trip’s load, not the trip id.
data.tripId to find the trip.
Carrier documents go to every webhook
A carrier has no Subsidiary. Forcarrier.document.uploaded and carrier.document.deleted:
- The envelope
subsidiaryIdis alwaysnull. - Alvys sends the event to every webhook in the tenant that subscribes to it, whatever Subsidiaries the webhook covers.
Examples
truck.document.* and trailer.document.* events have the same shape as the driver example, with truckId or trailerId in place of driverId.
The examples show these points:
- On
load.document.deleted,downloadUrlandexpiresAtare absent. They are not sent asnull. - On
trip.document.uploaded,uploadedByis absent because it is unknown.parentIdis the load number. - On
carrier.document.deleted,subsidiaryIdisnull. Fields such asattachmentSizeanduploadedAtare absent because they are unknown.
Notes
- Delivery is at-least-once. Deduplicate on
X-Alvys-Event-Id. See Event Delivery & Reliability. - Document events do not carry a
data.diffnode. - Load and trip changes send their own events. See Load events and Trip events.