Core concepts
Idempotency
Retry a request that changes data without doing it twice. Send an Idempotency-Key, and Sublaunch answers a repeat with the first result.
Send a key
Add the Idempotency-Key header to any POST, PATCH or DELETE. Use a value unique to the operation, up to 255 characters. A UUID v4 is a good choice.
If the connection drops before you get the answer, send the same request with the same key. Sublaunch does the work once and gives you its result, so a post is never published twice.
Keys are kept 24 hours. An answer of 409, 429 or 5xx is not kept, so a retry runs again. GET requests never change data and need no key.
curl -X POST https://api.sublaunch.com/v1/webhook_endpoints \
-H "Authorization: Bearer $SUBLAUNCH_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 9f1c4f5e-3b0a-4f7e-9d2c-6a8b1e2d4c7f" \
-d '{
"url": "https://example.com/webhooks/sublaunch",
"events": ["member.joined"]
}'How Sublaunch answers
| Request | Answer |
|---|---|
| Same key, same method, path and body, within 24 hours | The first response again, same status and body, with the header Idempotent-Replayed: true. |
| Same key, another method, path or body | 409 idempotency_error with the code idempotency_key_reused. |
| Same key while the first request still runs | 409 with the code idempotency_key_in_use. Try again a second later. |
| A key longer than 255 characters | 400 with the code idempotency_key_invalid. |
When to retry
- A network error or a timeout, retry with the same key.
- A 500 or a 502, retry with the same key after a short wait.
- A 400, 401, 403 or 404, fix the request and send it with a new key.