307 Temporary Redirect
Same as 302 but the request method and body must be preserved when following the redirect.
Status
HTTP/1.1 307 Temporary Redirect
Details
- Category: 3xx
- Status: Standard. Registered with IANA and defined by a current standards-track RFC.
- Specification: RFC 9110 §15.4.8
- Cacheable: Only with explicit cache headers
- Response body: Allowed
- Retry: Safe to retry
307 was created to remove the ambiguity in 302. The move is temporary, and the client is explicitly forbidden from changing the method: a POST to the old URL becomes a POST to the new one, with the same body.
That makes it the right code for temporarily relocating an API endpoint, for maintenance failover, and for any redirect where dropping the request body would break the operation. HSTS preloading also relies on method-preserving upgrades of this kind.
Headers
- Location: Required. The temporary URL, to be requested with the original method.
Common causes
- An API endpoint moved temporarily during a migration or failover.
- A load balancer sent traffic to a secondary region while the primary was drained.
How to fix it
As the client
- Replay the same method and body against the new URL. Many older HTTP libraries need this enabled explicitly.
- Re-read any authentication requirements. Cross-origin redirects usually strip Authorization headers.
As the server
- Use 307 rather than 302 whenever the request body matters.
- Keep the redirect target on the same origin where possible, so credentials survive the hop.
Examples
POST /v1/ingest HTTP/1.1
Host: api.example.com
Content-Type: application/json
{"event":"click"}
HTTP/1.1 307 Temporary Redirect
Location: https://api-eu.example.com/v1/ingest