307
HTTPREDIRECTNotable3xx RedirectionHIGH confidence

Temporary Redirect

Production Risk

Low. It clearly communicates a temporary move while preserving the request method, which is important for API clients.

What this means

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.

Why it happens
  1. 1A resource is temporarily moved for maintenance, and future requests should use the same method (e.g., POST).
  2. 2A non-idempotent action needs to be redirected to a different endpoint without changing the method.
  3. 3Used when the temporary URI is subject to change again in the future.
How to reproduce

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.

trigger — this will error
trigger — this will error
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

Use 307 when temporarily redirecting a non-GET request and method must be preserved
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.

What not to do

Version notes

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All HTTP errors