Idempotency
Get an API keyA network error can leave you unsure whether a post was created. Send an Idempotency-Key header with POST /v1/posts and POST /v1/media, and retry with the same key: Sofia answers what it answered the first time, and creates nothing twice.
curl -X POST https://api.sofia-post.com/api/v1/posts \
-H "Authorization: Bearer $SOFIA_API_KEY" \
-H 'Content-Type: application/json' \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-d @post.json- Use a new random key (a UUID) for each new post, and the same key for each retry of that post.
- The same key with a different body answers
422 idempotency_key_reused. - While the first request is still running, the same key answers
409 idempotency_in_progress: retry a moment later.