Temporary Redirect
Production Risk
Low. It clearly communicates a temporary move while preserving the request method, which is important for API clients.
The server sends this response to direct the client to get the requested resource at another URI with the same method that was used in the prior request. This has the same semantics as the 302 Found HTTP response code, with the exception that the user agent must not change the HTTP method used.
- 1A resource is temporarily moved for maintenance, and future requests should use the same method (e.g., POST).
- 2A non-idempotent action needs to be redirected to a different endpoint without changing the method.
- 3Used when the temporary URI is subject to change again in the future.
An API endpoint /api/v1/submit is being updated, and for a short time all POST requests are redirected to /api/v2/submit to be handled.
POST /api/v1/submit HTTP/1.1
Host: example.com
Content-Type: application/json
{ "data": "some data" }expected output
HTTP/1.1 307 Temporary Redirect Location: /api/v2/submit
Fix
Use 307 when temporarily redirecting a non-GET request and method must be preserved
WHEN When a POST, PUT, or DELETE endpoint temporarily moves and the client must repeat the same method at the new location
HTTP/1.1 307 Temporary Redirect Location: https://api-v2.example.com/submit Cache-Control: no-store
Why this works
307 guarantees the client re-sends the original request method (POST, PUT, etc.) to the Location URL. Use it instead of 302 when method preservation is important. For permanent method-preserving redirects, use 308.
✕
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev