> For the complete documentation index, see [llms.txt](https://banktech.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://banktech.gitbook.io/docs/developer-guide/methods.md).

# Methods

The HTTP verbs comprise our “uniform interface” and provide us with the action counterpart to noun-based resources. The most-commonly-used verbs (or methods) are POST, GET, PUT, PATCH, and DELETE. These correspond to create, read, update, and delete (or CRUD) operations, respectively.

### `HEAD`

The `HEAD` method is used to request HTTP headers from the server. The `HEAD`request is identical to the `GET`request except that the server must not return the message body in the response. Requests using the `HEAD` method will only retrieve data and are considered safe.

```
// Request:

HEAD /echo/head/json HTTP/1.1
Accept: application/json
Host: api.bank.tech

// Response from host:

HTTP/1.1 200 OK
Content-Length: 19
Content-Type: application/json
```

{% hint style="info" %}
You should fetch the headers of each method you intend to use to familiarise yourself with the expected structure of the header for the method you intend to make use of.
{% endhint %}

Since BankTech uses a bearer token authentication scheme, your header request will always include:

```
// Request:

POST http://www.example.com/customers HTTP/1.1
Host: example.com
Authorization: Bearer AbCdEf123456
Content-Type: application/json
```

### `GET`

The `GET` verb is used to retrieve a representation of a resource. According to the design of the HTTP specification, `GET` (along with `HEAD`) requests are used only to read data and not change it. Requests using the `GET`method will only retrieve data and are considered safe.

```
GET http://www.example.com/customers/12345
```

### `POST`

The `POST` verb is most often utilized to create new resources. In particular, it's used to create subordinate resources. That is, subordinate to some other (e.g. parent) resource. Making two identical `POST` requests will most likely result in two resources containing the same information.

```
POST http://www.example.com/customers

[
  {
    "objectId": 1,
    "firstName": "John",
    "lastName": "Smith",
    "accountID": "12345"    
  }
]
```

### `PUT`

The `PUT` verb is most-often utilized for update capabilities, PUT-ing to a known resource with the request body containing the newly-updated version of the original resource. However, `PUT` can also be used to create a resource in the case where the resource ID is chosen by the client instead of by the server.

```
PUT http://www.example.com/customers/12345

[
  {
    "objectId": 1,
    "firstName": "Sarah",
    "lastName": "Jones",
    "accountID": "54321"    
  }
]
```

### `PATCH`

The `PATCH` verb is used for modify capabilities. The `PATCH` request only needs to contain the changes to the resource, not the complete resource. This resembles `PUT`, but the body contains a set of instructions describing how a resource on the server should be modified to produce a new version.

```
PATCH http://www.example.com/customers/54321

[
  {
    "objectId": 1,
    "firstName": "Sarah",
    "lastName": "Smith"
  }
]
```

### `DELETE`

The `DELETE` verb is pretty easy to understand. It is used to delete a resource identified.  HTTP-spec-wise, `DELETE` operations are idempotent. If you `DELETE` a resource, it is removed. Repeatedly calling `DELETE` on that resource ends up with the same result: the resource is already gone.&#x20;

```
DELETE http://www.example.com/customers/54321
```
