SkillNavora
Foundations · Technical

APIs for Product Managers

How requests, methods, status codes, endpoints and JSON fit together, using an order as the running example. No coding needed.

How to use this lesson. Read each part, look at the worked example, then do the practice at the end. You don't need to code. The aim is to be able to read an API request, explain it to an engineer, and spot what is wrong when something breaks.

1. What an API is

An API (Application Programming Interface) is a set of rules that lets one program ask another for something. Apps rarely hold their own business data. They ask a server, and the server answers.

Think of a restaurant. You are the user, the waiter is the API, and the kitchen is the backend. You never go into the kitchen, and the waiter takes your order in a fixed format.

Every API call has two halves:

  • Request (from the app): a method (what to do), an endpoint (the address to act on), headers (extra details such as the login), and often a body (the data, usually in JSON).
  • Response (from the server): a status code (the outcome), and often a body (the result).

2. Worked example: placing an order

The user taps Place order. Here is what happens behind the screen.

  1. The app builds the request.
    POST /orders
    Content-Type: application/json
    Authorization: Bearer <login token>

    {
    "customerId": 123,
    "productId": 456,
    "quantity": 2,
    "amount": 1500
    }
  2. The API checks it first. Is the user logged in (otherwise 401)? Is the JSON valid with every required field (otherwise 400)? Does the product exist (otherwise 404)?
  3. The backend does the work: it creates the order, reserves stock and calls the payment step.
  4. The API replies 201 Created with the new order: ID 789, status Confirmed. The app shows "Order placed".

What the API needs before it will accept a request

  • The exact endpoint and method (POST /orders)
  • Required fields with the right types. customerId must be a number, not "123", if the API says so.
  • Authentication: usually a login token or an API key
  • The Content-Type: application/json header
  • Documentation of all of the above, often an OpenAPI (Swagger) specification

How payment usually works

The example above shows the order and its result, not every payment step. The usual pattern is:

  1. The order is created first, usually as pending_payment.
  2. The backend sends the charge to a payment provider. Card details go to the provider directly, which keeps most card data out of your own systems.
  3. The provider approves or declines, and returns the result.
  4. On success the order becomes Confirmed. Some designs finish inside one request, as in the example. Others return pending and send a later notification, called a webhook.
Questions a product manager should ask
  • Is amount in rupees or paise? Write it in the specification.
  • Does the server recalculate the price from the product and quantity? It should. If it trusts the amount the app sends, a user could change the price.
  • If payment is declined after the order exists, is the order cancelled or left pending?

3. HTTP methods: what each one means

A method says what to do with the thing named in the endpoint. Two properties matter for product work. Safe means the call changes nothing. Idempotent means that repeating the same call leaves the same result, which matters when a network error hides the answer and the app retries.

MethodPurposeExampleSafeIdempotent
GETRead data/customers/123YesYes
POSTCreate or start something/ordersNoNo
PUTReplace the whole record/customers/123NoYes
PATCHChange selected fields/customers/123NoNot guaranteed
DELETERemove a record/addresses/123NoYes
GET asks for a record and changes nothing, so it has no body. Success returns 200 OK with the customer as JSON. A missing customer returns 404 Not Found. Product takeaway: GET is safe to repeat, so it can be cached.
POST creates a new record or starts an operation, and usually returns 201 Created. Product takeaway: repeating a POST can create duplicates unless the API supports idempotency keys, a unique ID sent with each attempt.
PUT sends the complete record and replaces the stored one. If you leave out a field such as city, PUT can clear it. Product takeaway: PUT means a full update; use PATCH to change one field.
PATCH sends only the fields that change, for example {"phone": "9876543210"}. Product takeaway: use PATCH for a single setting such as a notification preference.
DELETE removes a record and returns 204 No Content (or 200, or 404 if it is already gone). Product takeaway: check whether deletion is permanent or soft, and any audit or legal rules, before you specify it.

4. Status codes: reading the first digit

The first digit tells you who has to act.

RangeMeaningWho acts
1xxInformational: still in progressRarely visible
2xxSuccessNobody
3xxRedirect: a new address to followThe app
4xxClient error: the request or the access was wrongThe UI or the data
5xxServer error: the server failedEngineering

Common codes:

CodeNameWhat it means for the product
200OKCustomer details returned
201CreatedNew order created
204No ContentDeleted, nothing returned
301Moved PermanentlyThe record has a new address
304Not ModifiedUse the copy you already have
400Bad RequestThe data sent was invalid
401UnauthorizedNot logged in, or the login has expired
403ForbiddenLogged in, but not allowed to do this
404Not FoundThe order or record does not exist
409ConflictClashes with existing data, such as a duplicate
429Too Many RequestsRate limit reached: retry later
500Internal Server ErrorUnexpected failure on the server
503Service UnavailableService down or overloaded
504Gateway TimeoutAnother service did not answer in time
When you report a bug, include the status code and the time it happened. A 4xx points at the screen or the data. A 5xx points at engineering.

5. Endpoints: the address structure

An endpoint is the specific address that performs an action. Each part has a job:

https://api.shop.com  /v1  /customers  /123  /orders  ?status=paid&limit=10
  • Base address: where the API lives.
  • /v1: the version. It lets the API change without breaking older apps.
  • /customers: the resource, written as a plural noun.
  • /123: which one. This is a path parameter.
  • /orders: a related resource under that customer.
  • ?status=paid&limit=10: query parameters, covered in the next part.

Design rules: use nouns, not actions (/orders, not /createOrder), keep collection names plural, and let the method carry the action.

6. Parameters: where the information goes

A parameter is a piece of information the request passes to the API. Each kind of parameter has its own place in the request, and each answers a different question.

KindWhere it sitsQuestion it answersExample
PathIn the URL path, between slashesWhich specific record?/orders/123
QueryAfter the ?How should the results be filtered, sorted or paged??status=shipped
HeaderIn the request headersWho is asking, and in what format?Authorization: Bearer …
BodyIn the JSON bodyWhat data should be created or changed?{"quantity": 2}

Path parameters identify one record

A path parameter is a value inside the URL path that points at one resource. Read the request from left to right:

GET /orders/123
  • GET is the action: read.
  • /orders identifies the resource type: the collection of orders.
  • 123 identifies the specific order: the path parameter.

The same pattern works for other resources:

  • GET /customers/456: one customer
  • GET /products/789: one product
  • GET /shipments/12345: one shipment, so you can check its status

Business use cases

  • Retrieve a customer's profile
  • View a specific order
  • Check the status of a shipment
  • Retrieve a particular product

Common mistakes with path parameters

  • Wrong or missing ID. The API returns 404 Not Found. Check that the app passes the right ID, for example a shipment number instead of an order number.
  • Changing the type. If the API expects a number, /orders/abc will fail. Check the documentation for each ID type.
  • Guessable IDs without access checks. If the ID is simply 1, 2, 3, a user can try other numbers and read someone else's order. The server must check that the logged-in user is allowed to see the record, even when the ID is valid. This is a common security bug, and the answer is an access check on every request.
PM takeaway: path parameters answer one question: which specific record are we working with? When you write a requirement, name the ID that identifies the record, and state who may read it.

Path or query? A quick test

Ask whether the value names a specific thing or only narrows a list. /orders/123 names one order, so it is a path parameter. /orders?status=shipped narrows the list of orders, so it is a query parameter. Both can appear in one request: GET /customers/456/orders?status=paid means "paid orders for customer 456".

7. Query parameters: filtering and sorting

Query parameters follow the ?. They are name=value pairs joined by &. They narrow or order the results, and do not change the method.

GET /orders?status=shipped&sort=-created_at&limit=20&page=2
  • status=shipped: only shipped orders
  • sort=-created_at: newest first (the minus sign means descending)
  • limit=20: 20 results per page
  • page=2: the second page

Spaces are encoded, so "New Delhi" becomes New%20Delhi in the address.

8. JSON: the format of the instructions

JSON (JavaScript Object Notation) is the text format most APIs use for data. Four rules cover most cases:

  • Objects go in { } and hold name and value pairs.
  • Lists go in [ ].
  • Text is in double quotes: "name": "Rahul Kumar".
  • Numbers, true, false and null take no quotes: "quantity": 2. A trailing comma or a single quote makes the whole message invalid.
{
"customerId": 123,
"productId": 456,
"quantity": 2,
"amount": 1500
}

If quantity were sent as "two", the API would reply 400 Bad Request. The reply is JSON too, so the app can read the order ID and show it to the user.

9. Key takeaways

  • An API is a set of rules for asking another program for something.
  • GET reads, POST creates, PUT replaces, PATCH changes some fields, DELETE removes.
  • Status codes tell you who has to act: 2xx success, 4xx the request or access, 5xx the server.
  • Endpoints are nouns in a clear hierarchy. Path parameters name one record; query parameters filter and sort.
  • JSON bodies are instructions the server checks before it acts.
  • Always ask: what happens if the request is repeated, and does the server check prices and permissions itself?

10. Practice exercise

  1. Write the request for a customer changing only their phone number. Choose the method and endpoint, and write the body.
  2. A user reports "I can see my order but cannot cancel it" and the app shows an error. List three status codes that could explain it, and what each one tells the engineer.
  3. Your payment step times out and the user taps Pay again. What can go wrong? Name the safeguard you would specify.
  4. Write the request to show a customer's paid orders from last month. Mark which part is a path parameter and which parts are query parameters.

Check your answers against sections 2, 3, 4, 6 and the payment steps in section 2.

11. Quick check

1. Which method should you use to update a customer's phone number only?
PATCH, because it changes selected fields. PUT would replace the whole record.

2. A request returns 401. What is the most likely cause?
The user is not logged in, or the login has expired. It is not a problem with the data.

3. In GET /shipments/12345, which part is the path parameter?
12345. It identifies the one shipment. /shipments names the resource type.

4. Why must the server check access even when the ID is valid?
Because a user can guess or change IDs. A valid ID does not prove the user is allowed to see that record.

5. Why should the server, not the app, set the order price?
The app can be changed by the user, so the server must recalculate the price from the product and quantity.

Examples are simplified for learning. Real APIs differ in names, limits and error formats. Always read the documentation of the API you use.

Refer & earn