Skip to content

toil.added webhook event

The toil.added event fires when an approver or admin records already-approved TOIL for a user, or when a TOIL request is auto-approved without a manual approver step. The webhook owner must hold the toil:read scope. This page maps the delivery headers, the payload shape, and the practical checks for handling the event correctly.

When toil.added fires

Two real-world changes produce this event:

  • An approver or admin adds TOIL that is already approved for a user.
  • A TOIL request is approved automatically, without a separate approver action.

If a user submits a TOIL request that still needs a decision, that is a different event (toil.requested). If an approver explicitly approves an existing open request, that is toil.approved. Use the table below to pick the right subscription for your integration.

Choosing the right TOIL event

The TOIL event family shares one payload shape but separates the lifecycle into distinct events. The table summarizes the practical decision.

Delivery headers

Every delivery carries the following headers, and all are required. The signature header is built from a Unix-seconds timestamp plus a hex HMAC-SHA256 digest computed over the timestamp, a literal dot, and the raw request body; during the 24-hour window that follows a secret rotation, a second digest signed with the outgoing secret is included so receivers can still validate. The webhook ID tells you which subscription the delivery belongs to. The event ID matches the body's id and is the recommended deduplication key. The event type matches the body's type. The delivery ID stays stable across retries of the same delivery, while the delivery attempt starts at 1 and increments. The User-Agent header is a fixed string delivered verbatim from the protected User-Agent module.

Payload fields

The body is JSON and follows the ToilWebhookEvent shape. Top-level fields:

  • id — the event ID, deterministic per change, matching the VT-Event-Id header. Use it to skip duplicates. Test deliveries (webhook.test) get a random ID.
  • type — the event type. For this page, toil.added. webhook.test is sent only by test deliveries and cannot be subscribed to.
  • apiVersion — the data shape version, currently "2".
  • createdAt — ISO 8601 timestamp of when the event was created.
  • companyId — the company the event belongs to.
  • data — the affected TOIL resource, in the same shape the matching GET endpoint returns.
  • apiClient — present only when the change was made through the API; contains keyId, optional name, and ownerId.

Inside data, the TOIL record exposes id, userId, approverId (null until approved), leaveTypeId, startDate and endDate (YYYY-MM-DD), isFullDayLeave, optional startHour/endHour/startMinute/endMinute (only when isFullDayLeave is false), optional durationWorkingDays, locationId, departmentId, status, reason, statusReason, approvalDate, and createdAt. The status enum is OPEN, APPROVED, DENIED, CANCELLED, EXPIRED, DELETED.

The reason and statusReason fields require the leaves:read-reason scope; without it they arrive as null. durationWorkingDays counts full days directly, and converts part-day TOIL using an 8-hour day regardless of the user's working hours.

Handling checklist

A practical sequence for a toil.added consumer:

  1. Verify the VT-Signature header against the raw body before parsing. Accept the previous-secret v1 entry during the 24-hour rotation window.
  2. Reject deliveries whose VT-Webhook-Id does not match a known subscription.
  3. Deduplicate on VT-Event-Id (or body id). Do not deduplicate on VT-Delivery-Id — that value stays the same across retries of the same delivery, so it will not distinguish a retried delivery from a new one.
  4. Confirm VT-Event-Type equals toil.added before routing.
  5. Read data.status to confirm the record is APPROVED; if you need reason or statusReason, ensure the leaves:read-reason scope is granted, otherwise treat null as expected.
  6. Use VT-Delivery-Attempt to detect retries and apply backoff on your side.
  7. Persist data.id (the TOIL request ID) as the stable resource key.

Worked example

Suppose a user submits a TOIL request that needs approval. That produces toil.requested with data.status OPEN and approverId null. If the approver then approves it, the toil.approved event fires. If instead the request is auto-approved by policy, the toil.added event fires with data.status APPROVED and approverId populated. If an admin later adds already-approved TOIL directly for the user, toil.added fires again with a fresh data.id. In each case, the deterministic body id lets you correlate the event to the underlying change without relying on timestamps.

Common failure distinctions

  • Duplicate delivery vs retry: a duplicate delivery has the same VT-Event-Id and a new VT-Delivery-Id; a retry has the same VT-Delivery-Id and an incremented VT-Delivery-Attempt.
  • Auto-approval vs manual add: both produce toil.added; the difference is whether an approver acted on an existing request or an admin created an already-approved record. Inspect data.approverId and the surrounding audit context.
  • Missing reason fields: if reason or statusReason is null, the leaves:read-reason scope is likely absent; this is not a data error.
  • Signature mismatch during rotation: accept the second v1 entry signed with the previous secret for up to 24 hours after rotation.
TOIL event decision table
ChangeEventdata.statusapproverId
User submits a TOIL request needing approvaltoil.requestedOPENnull
Approver approves an open requesttoil.approvedAPPROVEDpopulated
Request is auto-approvedtoil.addedAPPROVEDpopulated
Admin adds already-approved TOILtoil.addedAPPROVEDpopulated
Request is deniedtoil.deniedDENIEDpopulated
Request is cancelledtoil.cancelledCANCELLEDpopulated
Request expires without a decisiontoil.expiredEXPIREDnull

Event-to-status mapping reflects the documented TOIL event family; approverId presence follows the approverId description.

Frequently asked questions

What scope does the webhook owner need for toil.added?

The toil:read scope. If you also need the reason and statusReason fields populated, grant leaves:read-reason; without it those fields arrive as null.

How do I deduplicate toil.added deliveries?

Use VT-Event-Id (or the body's id). It is deterministic per change, so the same change always yields the same ID. VT-Delivery-Id is stable across retries of the same delivery and is not a deduplication key.

How is toil.added different from toil.approved?

toil.added fires when already-approved TOIL is recorded by an approver or admin, or when a request is auto-approved. toil.approved fires when an approver explicitly approves an existing open request. Both carry APPROVED status, but the trigger differs.

Can I subscribe to webhook.test?

No. webhook.test is sent only by test deliveries and cannot be subscribed to. Its body carries a random id rather than a deterministic one.

VT-Signature

FieldTypeRequiredDescriptionConstraints
VT-SignaturestringYest= ,v1= . "> . For 24 hours after a secret rotation it carries a second v1 entry signed with the previous secret. See Signature verification at the top of this document.

VT-Webhook-Id

FieldTypeRequiredDescriptionConstraints
VT-Webhook-IdstringYesthe ID of the webhook the delivery is for.

VT-Event-Id

FieldTypeRequiredDescriptionConstraints
VT-Event-IdstringYesthe event ID, the same as id in the body. Use it to skip duplicate deliveries.

VT-Event-Type

FieldTypeRequiredDescriptionConstraints
VT-Event-TypestringYesthe event type, the same as type in the body.Allowed values: $3b

VT-Delivery-Id

FieldTypeRequiredDescriptionConstraints
VT-Delivery-IdstringYesthe delivery ID, unique per delivery and kept across retries of the same delivery.

VT-Delivery-Attempt

FieldTypeRequiredDescriptionConstraints
VT-Delivery-AttemptintegerYesthe attempt number of this delivery, starting at 1.1 <= value