# HTTP methods

The API uses four methods. There is no `PUT`: every change is a `PATCH` that names only what changes.

| Method   | Used for                                                                                  | Typical answer                                   |
| -------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------ |
| `GET`    | Reading one item or a list. Never changes anything.                                       | `200`                                            |
| `POST`   | Creating an item, and running an action (`/transitions/{t}`, `/move`, `/clone`, `/rank`). | `201` for a create, `200` or `202` for an action |
| `PATCH`  | Changing some fields of an item. Fields you leave out keep their values.                  | `200` with the changed item                      |
| `DELETE` | Deleting an item (or moving it to the trash, where projqo has one).                       | `204`, no body                                   |

## PATCH names only what changes

```http
PATCH /api/v1/orgs/{org}/tasks/WEB-12
Content-Type: application/json

{ "summary": "Fix the sign-in redirect on Safari" }
```

Fields with several values take what to add and what to remove, so you don't need to read the task first:

```json
{ "labels": { "add": ["frontend"], "remove": ["triage"] } }
```

## Actions are POSTs to a sub-path

Moving a task to another status, moving it to another project, cloning it or ranking it are actions, each a `POST` to a sub-path of the task:

- `POST /tasks/{task}/transitions/{transition}`
- `POST /tasks/{task}/move`
- `POST /tasks/{task}/clone`
- `POST /tasks/{task}/rank`

`GET /tasks/{task}/transitions` lists the transitions open to the caller right now.

## Safe to repeat

`GET`, `PATCH` and `DELETE` can be sent again safely after a network error. A `POST` that creates can make a second item if sent twice; send an `Idempotency-Key` header to make it safe to repeat (see [idempotency](/guides/idempotency/)).

## Statuses

See [conventions](/guides/conventions/#statuses) for every success status and [errors](/guides/errors/) for every error.
