Skip to main content

What is POST used for?

POST is an HTTP method used to send data to a server and perform actions that change the server's state.

In simple terms: POST is needed to "transfer data and do something".


The main purpose of POST

POST is used when you need to:

  • send form data
  • create a new resource
  • pass data to an API
  • perform an operation on the server

Typical examples:

  • user registration
  • sending a message
  • creating an order
  • authorization

How POST works

  1. The client sends an HTTP request with the POST method
  2. Data is sent in the request body
  3. The server processes the data
  4. The server changes its state (creates, saves, processes)
  5. The server returns an HTTP response

Where data is sent with POST

Unlike GET:

  • data is sent in the request body
  • it is not visible in the URL
  • large amounts of data can be sent

For example:

json
{ "username": "alice", "password": "12345" }

Key properties of POST

1. Not idempotent

A repeated POST:

  • can create duplicates
  • can trigger the action again

2. Not cached by default

POST requests:

  • are usually not cached by browsers
  • are always sent to the server

3. Used to change data

POST changes the server's state, unlike GET.


POST vs GET (very briefly)

  • GET - get data
  • POST - send data and change state

Real-life example

POST is like:

  • filling out a form and submitting it
  • placing an order
  • sending a message

You transfer something, and the system does something.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.