Idempotency and async requests

A post is not sent inside the HTTP call. POST /v1/posts checks the request, accepts it, and answers while the send runs on. You then read the outcome from a request resource. Because the call can fail after the send started, send every post with an Idempotency-Key.

Idempotency-Key

Idempotency-Key: order-1234-announcement

The header is optional, but without it a retry after a timeout can send twice.

Rule Value
Format 1 to 255 printable ASCII characters, no spaces. Anything else is invalid-request.
Scope Per system (the "System that uses the key" set when the key was created), not per key. Two keys of the same system and the same mode share their idempotency keys; another system's keys are separate. A test key and a live key of one system do not share them.
Lifetime At least 24 hours from the first call. After that the key can be used again.
Matched on The method, the route and the body. Key order inside the JSON body does not matter. Query parameters such as wait are not part of the match.

Use a new key for every new post, for example a unique id from your own system. Use the same key only to retry the same body.

What happens with a key you sent before

Situation Answer
New key The call runs.
Same key, same body, call already accepted The original 202 answer is returned again, with the header Idempotent-Replayed: true and the same Location. Nothing is sent a second time.
Same key, different body 422 unprocessable, detail idempotency-key-reused.
Same key and body, first call still being accepted (less than a minute old) 409 conflict, detail idempotency-key-in-flight: req_.... Retry in a few seconds.
Same key and body, and two calls try to start the same request at the same moment (for example, a retry that took over a stalled first call) 409 conflict, detail already-in-progress: req_..., naming the request the key holds. Nothing new is sent, and the key stays used. Read that request, or retry the same call in a few seconds.
Same key and body, and the post targets status@broadcast while an identical send is in progress 409 conflict, detail already-in-progress: req_.... The Idempotency-Key does not skip the duplicate check for a Status post. The key is released, so retry the same call once the first send has finished.
Same key and body, first call started more than a minute ago and never finished The API completes it. If the send had started, it returns the original acceptance (Idempotent-Replayed: true). If the send never began, your call takes the key over and runs it, keeping the same req_ id. Either way the message is not sent twice.

What is stored

The key stores the acceptance, not the outcome. A replay always returns the 202 acceptance (status: "accepted"), even if the send has since finished or failed, and even if the first call returned 200 through ?wait. To learn the outcome, read the request resource.

A call that is refused or fails before the send starts, such as a validation error, a rate limit, or an out-of-scope bot, does not keep the key. Retrying the same key then runs the call fresh. The one exception is the 409 already-in-progress above: that call collides with a request the key already holds, so the key is kept. Once a post was accepted, the key stays used for 24 hours. If that post then fails, send a new post with a new Idempotency-Key.

The request resource

Every accepted post is a request, named by an id like req_00000000-0000-0000-0000-000000000000.

curl https://api.groupapp.co.il/v1/requests/req_00000000-0000-0000-0000-000000000000 \
  -H "Authorization: Bearer $GROUPAPP_API_KEY"
{
  "object": "request",
  "id": "req_00000000-0000-0000-0000-000000000000",
  "status": "succeeded",
  "botId": "my-bot",
  "createdAt": "2026-01-01T09:00:00.000Z",
  "completedAt": "2026-01-01T09:00:02.000Z",
  "metadata": { "order": "1234" },
  "result": {
    "targets": [
      { "targetId": "[email protected]", "status": "sent", "messageId": "..." }
    ]
  }
}
Field Meaning
id The req_ id. The path accepts the bare uuid as well.
status See below.
botId The bot the post was sent through.
createdAt, completedAt Timestamps. completedAt is present once the request has a result.
metadata The metadata you sent with the post, echoed back. Up to 20 pairs; a key is 1 to 40 characters of A-Z, a-z, 0-9, _ or -; a value is a string of at most 500 characters.
result What the send did. Present on succeeded, and on a failed request that has partial results.
error Present on failed: {type, title, code, detail} with type ending in request-failed. code and detail are a short lowercase code; a code the API cannot show safely becomes send-failed.

Statuses

status Meaning
accepted The post was accepted and is being sent.
in_progress The send is still running after the first wait. It may still finish.
succeeded The send finished.
failed The send finished with an error. See error, and result for the targets.
unknown No result after 30 minutes. Check the groups before you send again.

accepted and in_progress are open. Poll until the status is something else. While a request is open the response carries Retry-After: 2, so poll at most every 2 seconds. A resource that is not open has no Retry-After.

Result

A post to groups (targetIds) has one entry per target:

{ "targets": [
  { "targetId": "[email protected]", "status": "sent", "messageId": "..." },
  { "targetId": "[email protected]", "status": "failed", "error": "send-failed" }
] }

Each entry has targetId, status (sent or failed), and, when known, messageId (sent), error (failed, a short code) and refused: true (the send was refused before it was tried).

A post to a super group (superGroupId) has { "postId": "pst_..." } once the post exists. Read the post, and the outcome per group, with GET /v1/posts/{postId}. The result is {} when no post id is available.

Who can read a request, and for how long

  • A request is visible only to keys of the system that created it, of the same mode: a test key's request answers 404 to a live key and the other way round. Any other key gets 404 not-found, admin-role keys included.
  • A request is kept for 30 days. After that it answers 404.

Test mode

A ga_test_ key uses the same calls, headers and statuses as a live key. The post is accepted with 202, the request ends succeeded, and ?wait and Idempotency-Key work as above. The difference is that nothing is sent, and the result is a sample: for targetIds, each target is sent with a messageId starting with test_, or failed if it is one of the reserved ids described in the quickstart; for superGroupId, result is {}. A test key has its own idempotency keys, its own requests and its own rate-limit counts.

A test send produces no post.* webhook event. A test send to targetIds does queue a send.completed event, and a request.completed event for a test key does not reach subscriptions that receive live events. See Webhooks.

?wait

curl -X POST "https://api.groupapp.co.il/v1/posts?wait=10" ...

wait is a whole number of seconds from 0 to 10. The default is 0. Any other value is invalid-request.

With wait above 0 the API holds the response until the send finishes or the time runs out. If the send finished in time and the request is no longer open, the answer is 200 with the request resource. Otherwise the answer is the usual 202. In both cases the request exists and can be read later. wait only changes how long you wait, never whether the post is sent.

Which answers are 202 and which are 200

Call Answer
POST /v1/posts accepted 202, Location: /v1/requests/req_..., body {object: "request", id, status: "accepted", botId, metadata?}.
POST /v1/posts?wait=N, finished in time 200, the finished request resource. No Location.
POST /v1/posts replayed through an Idempotency-Key 202 with Idempotent-Replayed: true and Location.
GET /v1/requests/{id} 200, with Retry-After: 2 while the request is open.
GET /v1/posts/{postId} 200.

A post that is refused (bad body, no scope, rate limit, and so on) never returns 202: it answers a problem and no request is created.