# HTTP status codes and what an agent should do next

A quick reference for software agents calling web APIs: what each common status code means, whether a retry is safe, and the sensible next step.

@sheet Status codes
@width A: 70
@width B: 170
@width C: 300
@width D: 150
@width E: 380
@style A1:E1: bold
| Code | Name | What it means | Safe to retry? | What an agent should do |
| --- | --- | --- | --- | --- |
| 200 | OK | Request succeeded | n/a | Use the response body |
| 201 | Created | A new resource was made | No | Save the Location header or returned ID; do not repeat the request |
| 202 | Accepted | Work queued, not finished | n/a | Poll the status URL with a delay until done |
| 204 | No Content | Success with no body | n/a | Treat as done |
| 301 | Moved Permanently | URL has changed for good | Yes | Follow it and update the stored URL |
| 302 | Found | Temporary redirect | Yes | Follow it, keep the original URL |
| 304 | Not Modified | Cached copy is still current | n/a | Use the cache |
| 307 | Temporary Redirect | Temporary redirect, same method | Yes | Follow it with the same method and body |
| 308 | Permanent Redirect | Permanent redirect, same method | Yes | Follow it and update the stored URL |
| 400 | Bad Request | The request is malformed | No | Fix the request; repeating it unchanged will fail again |
| 401 | Unauthorized | Missing or invalid credentials | Once | Refresh or re-check credentials once, then stop and report |
| 403 | Forbidden | Credentials are valid but not allowed | No | Stop. Do not look for a way around it; report it |
| 404 | Not Found | Nothing at this URL | No | Check the URL for typos; do not loop |
| 405 | Method Not Allowed | Wrong HTTP method for this URL | No | Read the Allow header and the docs |
| 408 | Request Timeout | Server gave up waiting | Yes | Retry with backoff |
| 409 | Conflict | State changed under you | After refetch | Fetch the current state, merge, then resubmit |
| 410 | Gone | Removed on purpose | No | Drop the link from your records |
| 413 | Content Too Large | Body exceeds the size limit | No | Shrink or split the body |
| 415 | Unsupported Media Type | Wrong Content-Type | No | Send a supported type |
| 422 | Unprocessable Content | Well-formed but rejected by validation | No | Read the error detail, fix the data, resubmit |
| 429 | Too Many Requests | Rate limit hit | Yes, later | Wait for the Retry-After time, then slow down |
| 500 | Internal Server Error | Server-side fault | Cautiously | Retry a few times with backoff if the action is idempotent |
| 502 | Bad Gateway | Upstream server failed | Yes | Retry with backoff |
| 503 | Service Unavailable | Overloaded or down | Yes | Honour Retry-After; retry with backoff |
| 504 | Gateway Timeout | Upstream was too slow | Cautiously | Check whether the write happened before retrying |
@endsheet

## Retry rules of thumb

- Back off exponentially (for example 1s, 2s, 4s, 8s) and add random jitter so many clients do not retry together.
- Cap the attempts (3 to 5) and the total wait. Then report the failure instead of looping.
- Only retry writes that are idempotent, or that carry an idempotency key. A POST that timed out may still have succeeded, so look before you repeat it.
- Always obey a Retry-After header over your own schedule.
- Never retry 400, 403, 404 or 422 unchanged.

Source: status code meanings follow RFC 9110 (HTTP Semantics), https://www.rfc-editor.org/rfc/rfc9110.html. Retry advice is general practice, not part of the standard.
