Sobes.tech
Junior — Middle

Can POST requests be considered safe for re-execution without changes to server state?

sobes.tech AI

Answer from AI

POST requests are not considered safe for repeated execution without changes to the server state. The HTTP POST method is intended for creating or modifying resources, so repeating a POST request can lead to duplicate data or other side effects.

Unlike GET, which should be idempotent and safe (not changing state), POST is usually not idempotent.

If the ability to repeat without changes is needed, it is better to use PUT or PATCH methods with idempotent logic, or implement server-side protection against repeated requests (for example, through unique transaction identifiers).