> For the complete documentation index, see [llms.txt](https://en.help.firstline.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://en.help.firstline.cc/developer/api/request-methods.md).

# Request method description

FIRST LINE REST API uses different HTTP methods depending on the endpoint `GET`,`POST`,`PUT`,`DELETE` and other HTTP methods,**The actual method is subject to each endpoint's documentation**.

| Method   | Common uses                      | Parameter placement                                                     |
| -------- | -------------------------------- | ----------------------------------------------------------------------- |
| `GET`    | Query data                       | Path Parameters, Query Parameters                                       |
| `POST`   | Create data or perform an action | Path Parameters, JSON Request Body                                      |
| `PUT`    | Update data                      | Path Parameters, JSON Request Body                                      |
| `DELETE` | Delete data                      | Path Parameters; other data depends on individual endpoint requirements |

## Standard Headers

```http
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json
```

Please put it in `Authorization` Header with the Access Token; do not put it in the URL. If the request has no JSON Body (e.g. GET), it can be omitted `Content-Type`.

## POST: Example of creating a customer

```bash
curl -X POST "https://{API_HOST}/api/v1/contact" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "first_name": "Chen",
    "last_name": "Dahua",
    "membership_no": "R0000555",
    "gender": 0,
    "birth_at": "1990-01-01"
  }'
```

In Postman, select **Body → raw → JSON**; do not put `first_name` and other creation data into the URL query string.

## GET: Filter with Query Parameters

```bash
curl -G "https://{API_HOST}/api/v1/contact" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  --data-urlencode "page=1" \
  --data-urlencode "search=John"
```

**GET query conditions should be sent via Query Parameters; do not provide JSON in the GET Request Body.**

## PUT: Example of updating a customer

```bash
curl -X PUT "https://{API_HOST}/api/v1/contact/2" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"first_name":"Wang","last_name":"Xiaoming"}'
```

If the endpoint indicates to use `PUT`, please send it directly with `PUT` to send the request. If the integration tool you use does not support that method, please check the tool settings; do not arbitrarily convert all `PUT` into `POST`.

## HTTP status codes

| Status code | Description and recommendations                                                      |
| ----------- | ------------------------------------------------------------------------------------ |
| `200`       | Request successful; read the response JSON                                           |
| `201`       | Resource created successfully (depending on the actual response of each endpoint)    |
| `204`       | Succeeded with no Response Body; do not attempt to parse it `{}`                     |
| `400`       | Invalid request format                                                               |
| `401`       | Authentication failed or token expired                                               |
| `403`       | Authenticated but insufficient permissions                                           |
| `404`       | The specified resource does not exist or is inaccessible                             |
| `405`       | The HTTP method is not supported by this endpoint                                    |
| `422`       | Field validation failed; adjust the input according to the error message             |
| `429`       | Requests are too frequent; reduce the frequency and retry with backoff               |
| `500`,`503` | Server or service temporarily abnormal; keep the Request ID/time for troubleshooting |

{% hint style="info" %}
The actual response format for the same status code varies by API. Please refer to the success status codes, Response Body, and validation rules listed for each endpoint.
{% endhint %}
