Cancel a trigger
To cancel a trigger, send DELETE /cancel with its ID or its custom key:
curl -X DELETE https://api.timetriggers.io/cancel \-H "ttr-api-key: YOUR_API_KEY" \-H "ttr-trigger-id: 3f2b8c1e-7d4a-4e5b-9c2f-1a2b3c4d5e6f"
A 204 No Content with an empty body means the trigger is cancelled. A one-shot trigger then won't fire. A recurring trigger creates no new runs, but runs that are already due still fire.
Request headers
| Header | Description |
|---|---|
ttr-api-keyreq. | Your API key. Authorization: Bearer isn't accepted on /cancel. See Authentication. |
ttr-trigger-idopt. | Send this or ttr-custom-keyheader. The trigger's ID: the triggerId returned by /schedule, or the id of an operation returned by /declare or /bulk. For a recurring trigger, use the recurring trigger's ID. |
ttr-custom-keyopt. | Send this or ttr-trigger-idheader. The custom key you gave the trigger. See Cancelling by custom key. |
Send exactly one of ttr-trigger-idheader and ttr-custom-keyheader. An empty value counts as missing.
Only triggers in your project are looked up. The ID or key is checked against recurring triggers first, then against one-shot triggers.
Which triggers can be cancelled
Whether a one-shot trigger can be cancelled depends on its status:
| Status | Cancellable | Notes |
|---|---|---|
registered | Yes | Scheduled and not due yet. |
skipped | Yes | Scheduled in the past without ttr-run-missedheader, so it never fires anyway. See Past-dated triggers. |
retrying | Yes | An attempt failed and the trigger is waiting for its next retry. No further attempts are made. |
queued | No, 410 | Due and waiting to be sent, usually only for a moment, longer when a tag policy's throughput or concurrency limit holds it back. It still fires. |
running | No, 410 | The request is being sent. |
completed | No, 410 | Finished, whether it succeeded or ended as a dead letter. |
cancelled | No | Already cancelled. See Cancelling again. |
A queued trigger can't be cancelled with /cancel. If it carries a tag, a /bulk cancel by tag ({"cancels": [{"tag": "billing"}]}) stops it, along with every other trigger that carries that tag.
Cancelling a recurring trigger
Send the recurring trigger's ID (the triggerId that /schedule returned when you created it) or its custom key. A 204 means:
- The recurring trigger creates no new instances.
- Its upcoming instance, the one that isn't due yet, is cancelled too.
- Instances whose time has already come are not cancelled and still fire:
- Queued instances, for example ones held back by a tag policy, are sent once the policy lets them through. You can't cancel them one by one (
410). - Retrying instances keep retrying until an attempt succeeds or the retries run out. To stop one, cancel it with its own ID in
ttr-trigger-idheader. - Running instances finish their request, and retry if it fails and a retry policy applies. Finished instances are kept as they are.
- Queued instances, for example ones held back by a tag policy, are sent once the policy lets them through. You can't cancel them one by one (
To cancel the recurring trigger together with its queued and retrying instances, give it a tag of its own and cancel by that tag with /bulk instead.
Each run of a recurring trigger (an instance) has its own ID, which you see in the dashboard. /schedule only returns the recurring trigger's ID.
Cancelling a single instance doesn't skip a run. If you send the ID of an upcoming instance, you get 204, but the recurring trigger stays active and creates a new instance for the same time within a few seconds. There's no way to skip one run: edit the schedule or cancel the whole recurring trigger.
In the dashboard, the Cancel button on an upcoming instance cancels the whole recurring trigger.
Cancelling by custom key
curl -X DELETE https://api.timetriggers.io/cancel \-H "ttr-api-key: YOUR_API_KEY" \-H "ttr-custom-key: appointment-42-reminder"
A custom key matches an active recurring trigger with that key or, if there's none, a one-shot trigger with that key that isn't cancelled.
Cancelling by key is reliable as long as the key has only been used for one trigger. In these cases, cancel by ttr-trigger-idheader instead:
- You've reused the key. You scheduled the key again after an earlier trigger with it was already queued, running or completed, so
/scheduleanswered"operation": "schedule"with a newtriggerId. Cancel the new trigger by thattriggerId. - A recurring and a one-shot trigger share the key. This can happen with
/declareand/bulk. A cancel by key cancels the recurring trigger; cancel the one-shot trigger by its ID.
Cancelling again
/cancel isn't idempotent. Once a trigger is cancelled, repeating the call no longer returns 204:
- By ID:
410, withJob is no longer cancellable (status=cancelled)orGenerator already cancelled. - By custom key:
404, withJob not found, because cancelled triggers are ignored. You get410instead if an older trigger with the same key is queued, running or completed.
If your client retries cancels, for example after a timeout, treat 404 and 410 on a retry as "nothing left to cancel".
Status codes
| Status code | Message | When |
|---|---|---|
| 204No Content | (empty body) | The trigger was cancelled. |
| 400Bad Request | (empty body) | ttr-api-keyheader is missing. A request that only sends Authorization: Bearer gets this too. |
| 400Bad Request | Must provide either ttr-trigger-id or ttr-custom-key header | Neither identifier was sent, or it was empty. |
| 400Bad Request | Provide either ttr-trigger-id or ttr-custom-key, not both | Both identifiers were sent. |
| 401Unauthorized | Invalid api key | ttr-api-keyheader isn't a valid key. The identifier checks run first, so a request with a bad key and no identifier gets 400. |
| 404Not Found | Job not found | By ID: no one-shot or recurring trigger in your project has this ID. By custom key: no active recurring trigger and no uncancelled one-shot trigger has this key, which includes a trigger that's already cancelled. The message is the same for recurring triggers. |
| 410Gone | Job is no longer cancellable (status=<status>) | The one-shot trigger is queued, running or completed, or, by ID only, already cancelled. |
| 410Gone | Generator already cancelled | By ID only: the recurring trigger was already cancelled. |
Errors with a message have a JSON body such as {"_tag": "NotFound", "message": "Job not found"}. See Errors.
Good to know
- Only
DELETEis accepted. Any other method on/cancelgets404with an empty body. - Cancelling doesn't use quota, and it keeps working when your monthly quota is used up.
- Triggers belong to your project, not to the API key that created them. Any key of the project can cancel them, and deleting a key doesn't cancel the triggers it created.
- To cancel many triggers in one call, use the
cancelslist of/bulk, by ID, custom key or tag.