Rookery
Developer docsRetries
Basics

Retries

Which requests are safe to send again after a timeout, and how to check before retrying the ones that aren't.

Updated View as Markdown

Networks drop requests. When a request times out, you can't always tell whether it reached Rookery. Whether it's safe to send again depends on what it does.

Safe to retry

Doing these twice has the same result as doing them once:

  • every GET: reading and listing;
  • Change status: setting the same status again changes nothing;
  • Tag or untag: a tag that's already there isn't added twice;
  • Assign: assigning to the same person again changes nothing;
  • Set priority: setting the same priority again changes nothing.

Check before retrying

These make something new each time, so a retry can make a second one:

There's no Idempotency-Key header yet. After a timeout on one of these, read the conversation first, and only retry if yours isn't there:

  1. Call Read a conversation with the same id.
  2. Look at the end of the timeline:
    • a note shows as "type": "note" with your key as author: { "type": "app", "id": "agt_…", "name": "…" }, the id and name that Check your key gives;
    • a reply shows as "type": "message", "direction": "outbound", with "status": "draft", or scheduled, sending or sent if you passed send: true, and your text.
  3. If it's there, the first request worked. If not, send it again.

A reply whose status is unconfirmed was handed to the mail service with no answer back, so it may have reached them. Rookery never sends it again on its own, and neither should you: check with them first.

A doubled draft is easy to fix: it waits in Needs your yes, and the person approving can throw one away. That's one more reason to draft, not send.

Each operation in the OpenAPI spec says whether it's safe to retry, in x-rookery-idempotent.

Coming later

An Idempotency-Key header for requests that create things, so a retry with the same key returns the first answer instead of doing it twice. It will be optional, and calls without it will work as they do now. The same key with a different body will answer 422 with the code idempotency_key_reused.