# API

Here’s a clean study table you can add to your guide.

| REST Method | Purpose                    | Description                                                                                       | Common Usage Example                                     |
| ----------- | -------------------------- | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
| GET         | Retrieve data              | Used to request or fetch information from a server or API. Does not modify data.                  | Retrieve customer profile, chat history, ticket status   |
| POST        | Create / Send data         | Used to submit new data to a server or trigger actions. Often creates new resources.              | Start chat session, create ticket, authenticate user     |
| PUT         | Update existing data       | Used to fully update or replace an existing resource.                                             | Update customer information, modify interaction settings |
| PATCH       | Partial update             | Used to update only specific fields of an existing resource.                                      | Change customer status, update phone number only         |
| DELETE      | Remove data                | Used to delete a resource or remove information from the system.                                  | Delete session, remove user, close/delete record         |
| OPTIONS     | Discover supported methods | Used to determine what operations an API endpoint supports. Often used in CORS/preflight checks.  | Browser checking allowed API methods                     |
| HEAD        | Retrieve headers only      | Similar to GET but returns headers only, without response body. Useful for validation or testing. | Check if resource exists, validate API availability      |

---

# Example REST API Calls

## GET Example

```http id="g1"
GET /api/customers/12345
```

Purpose:
Retrieve customer information.

---

## POST Example

```http id="g2"
POST /api/chat/start
```

Purpose:
Create/start a new chat session.

---

## PUT Example

```http id="g3"
PUT /api/customer/12345
```

Purpose:
Update full customer record.

---

## PATCH Example

```http id="g4"
PATCH /api/customer/12345
```

Purpose:
Update only selected fields.

---

## DELETE Example

```http id="g5"
DELETE /api/session/12345
```

Purpose:
Delete session or resource.

---

# Easy Interview Explanation

## REST APIs

REST APIs allow systems to communicate using standard HTTP methods such as GET, POST, PUT, and DELETE to retrieve, create, update, or remove data.