Skip to main contentClaim $5 in free credit — one-time, per account. Claim $5 free
Krova CloudKrova Cloud
API Design & Rate Limiting

HTTP 303 vs 307: Choose What Happens After a POST

A POST can succeed while its redirect sends the wrong next request. Choose 303 for result retrieval or 307 for temporary method-preserving routing, then verify the chain.

DM
Dhruv Malaviya5 min read
Share
A frosted request capsule branches toward a result document and repeat-request symbol beside the headline 303 or 307? Choose the Next Request.

Suppose a settings form saves a delivery rule, then sends the browser to a confirmation page. The database change succeeds, but the confirmation route returns “method not allowed.” In this hypothetical example, the redirect sent another POST to a route that only reads results. The save worked; the next request had the wrong job.

Use 303 See Other when the next request should retrieve the result of a completed POST. Use 307 Temporary Redirect when the client should repeat the request at a temporary destination without changing its method. Choose the destination's contract first, then verify what your actual client sends. RFC 9110 defines 303 as an indirect response at another resource and 307 as a method-preserving temporary redirect.

Give the next request one clear job

For the settings form, the write handler should finish the authorized change before offering its confirmation URL. The confirmation handler should read that result, not save it again. Here's an illustrative exchange; the IDs and routes are examples, not Krova API endpoints.

POST /delivery-rules HTTP/1.1
Host: app.example.com
Content-Type: application/x-www-form-urlencoded

label=Morning

HTTP/1.1 303 See Other
Location: /delivery-rules/42
Cache-Control: no-store

In this design, the client follows with GET /delivery-rules/42. That read can render the saved rule. It still needs normal authentication and authorization: the redirect and an opaque-looking ID do not grant access to somebody else's result.

A 307 answers a different question. Imagine /submit is temporarily accepting submissions through /submit-v2. If the client follows that redirect, the destination needs to accept the original method and submitted content. It should be an intended write destination, not the read-only confirmation page. Decide which handler performs the mutation; don't have the first handler save and then invite another handler to save the same operation.

HTTP/1.1 307 Temporary Redirect
Location: /submit-v2
Cache-Control: no-store

That response describes temporary routing, not a successful write. Keep destinations controlled by the application and check the full route, including any redirects added by a proxy or a trailing-slash rule. A redirect chain can change the outcome after the first hop.

Watch the request instead of guessing from the final page

A final 200 OK tells you little about how the client got there. Start by inspecting the first response without following it. Then inspect the destination's method, submitted fields and recorded effects. The useful evidence is the chain, not just its last status.

For a controlled rehearsal, create two disposable routes in staging. Have /redirect-lab/see-other return a 303 to a read-only receipt route. Have /redirect-lab/temporary return a 307 to a receiver that records a harmless test field. These routes must exist before the examples below will work. Use synthetic data, with outbound mail, payments and background effects disabled.

# Replace with your own staging origin and implemented rehearsal routes.
base='https://staging.example.com'

# Inspect the first response only. This sends one disposable POST.
curl --silent --show-error --max-time 10 \
  --dump-header - --output /dev/null \
  --data-urlencode 'label=redirect-rehearsal' \
  "$base/redirect-lab/see-other"

# A separate submission: follow the controlled same-origin redirect chain.
curl --silent --show-error --max-time 10 \
  --location --max-redirs 3 \
  --dump-header - \
  --data-urlencode 'label=redirect-rehearsal' \
  "$base/redirect-lab/see-other"

The second command makes a fresh submission; it does not continue the first one. Repeat it against your /redirect-lab/temporary route to compare behavior. Review the destination's staging logs or test receiver: the 303 path should arrive as a GET without the submitted form body, while the 307 path should arrive as a POST carrying the test field. Those are proposed acceptance checks, not results from a test we ran.

The curl manual documents redirect following with --location and the POST-to-GET behavior for 303. The data option selects POST here. Avoid adding -X POST or --post303 to this rehearsal: these options can override the behavior you're trying to observe. Check the client options in a real failure report before concluding the server chose the wrong status.

A browser or SDK still has a say

Don't treat the curl exercise as a certification of every client. The Fetch standard's redirect procedure changes a non-GET/non-HEAD request to GET for a 303 and removes its body. It also describes failures when a redirect would require replaying a body whose source is unavailable. A method-preserving redirect doesn't guarantee a client can replay every upload.

Exercise the browser form, fetch call or SDK configuration that your application actually uses. Record the initial status and Location, each subsequent method, the final destination and whether the expected operation happened. If a browser-based API caller needs navigation to a confirmation page, make that UI behavior explicit; following an HTTP request is not itself a complete user-interface flow.

Keep duplicate protection separate from redirection

Returning the form's user to a GET page avoids making that confirmation read another submission. It doesn't resolve a lost response. The original write may commit even if the client never receives the redirect; a later POST still needs the application's operation-identity and recovery policy. Krova's webhook retry guide explains that separate problem.

Likewise, a redirect isn't a promise that background work has finished. If the API has accepted work that remains pending, define a status resource and failure path; see HTTP 202 and job status URLs. Keep acceptance, completion and result retrieval as separate decisions.

For the hypothetical settings form, the fix is a contract you can check: save once, return a controlled result URL, read it with GET, and verify that refreshing the result doesn't run the write handler. Start with one affected route and its actual client. Change the redirect only after those observations match the job you want the next request to do.

Rehearse your API flow on a Cube

A Krova Cube provides a self-managed Linux environment for an API and a separate staging deployment. Your application owns redirect semantics, authorization and duplicate handling.

Creation context: this AI-assisted guide uses a hypothetical form and illustrative HTTP exchanges. The staging procedure was checked against the linked primary documentation but was not executed against an application. The cover is a generated conceptual illustration; no personal testing by the bylined author is claimed.

For AI agents:llms.txtsitemap

Related posts