Sobes.tech
Junior — Middle

Can you explain what the property of idempotency means in the context of web APIs or system calls?

sobes.tech AI

Answer from AI

Idempotence is a property of an operation where multiple executions of the same operation with the same input data lead to the same result, without changing the system's state after the first call.

In the context of web APIs, this means that if a client resends the same request (for example, due to a timeout or network error), the server should not change the state or data more than once.

Example: The HTTP method PUT is usually idempotent because it updates a resource to a specified state, and repeated requests with the same data will not change the result.

PUT /users/123
{
  "name": "Ivan"
}

If this request is sent multiple times, the user with id 123 will have the name "Ivan" — the state will not change after the first request.

This is important for the reliability and predictability of systems, especially in distributed and networked applications.