# Components

A project's components.

## List a project's components

`GET /orgs/{org}/projects/{project}/components`

Scope: `projects:read`

An Organisation project's components by name, with how many of their tasks the person can open. A Team project has no components (404, as its view isn't there).

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `project` (string, required): The project's key (WEB), an old key, or its id. [1 to 60 characters]

### Query parameters

- `limit` (integer): How many items a page holds, 1 to 200. [from 1 to 200; default 50]
- `cursor` (string): The next_cursor of the previous page; leave it out for the first page. [at most 1000 characters]
- `count` (string): true adds total, the number of items in the whole list. [one of: true, false]
- `fields` (string): Only these fields, comma-separated: id, project, name, description, lead, default_assignee, tasks. id always comes; the fields not asked for are left out, required or not.

### Request

```sh
curl -X GET "https://projqo.example/api/v1/orgs/{org}/projects/{project}/components" \
  -H "Authorization: Bearer $PROJQO_TOKEN"
```

### Answer: 200

```json
{
  "items": [
    {
      "id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
      "project": {
        "id": "1b2c3d4e-5f6a-4b7c-8d9e-0f1a2b3c4d5e",
        "key": "WEB",
        "name": "Website"
      },
      "name": "Checkout",
      "description": "Basket and payment pages.",
      "lead": {
        "id": "8d0e5f7a-1c2b-4d3e-8f9a-0b1c2d3e4f5a",
        "name": "Priya Shah"
      },
      "default_assignee": "component_lead",
      "tasks": 9
    }
  ],
  "next_cursor": null
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation.
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).

## Create a component

`POST /orgs/{org}/projects/{project}/components`

Scope: `projects:write`

Adds a component to an Organisation project (its admins and organisation admins). Names are unique in the project.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `project` (string, required): The project's key (WEB), an old key, or its id. [1 to 60 characters]

### Headers

- `Idempotency-Key` (string): A unique key (such as a uuid): the same key and body within 24 hours gets the first answer again without a second create; another body gets 422. [1 to 200 characters]

### Body

- `name` (string, required) [at most 255 characters]
- `description` (string) [at most 4000 characters]
- `lead` (string or null): The lead's id or email; null for none.
- `default_assignee` (string) [one of: component_lead, project_default, project_lead, unassigned]

### Request

```sh
curl -X POST "https://projqo.example/api/v1/orgs/{org}/projects/{project}/components" \
  -H "Authorization: Bearer $PROJQO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "string",
  "description": "string",
  "lead": "string",
  "default_assignee": "component_lead"
}'
```

### Answer: 201

```json
{
  "id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
  "project": {
    "id": "1b2c3d4e-5f6a-4b7c-8d9e-0f1a2b3c4d5e",
    "key": "WEB",
    "name": "Website"
  },
  "name": "Checkout",
  "description": "Basket and payment pages.",
  "lead": {
    "id": "8d0e5f7a-1c2b-4d3e-8f9a-0b1c2d3e4f5a",
    "name": "Priya Shah"
  },
  "default_assignee": "component_lead",
  "tasks": 9
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation. refused: The token's person can see the thing but may not do this; the message says why. read_only: The organisation is read-only (over the Free plan's people, or a payment is overdue).
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 413 `too_large`: too_large: The body or a file is larger than allowed.
- 415 `unsupported_media_type`: unsupported_media_type: The body isn't JSON.
- 422 `idempotency_key_reused`: idempotency_key_reused: The same Idempotency-Key was sent within 24 hours with a different body.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).

## Get a component

`GET /orgs/{org}/components/{component}`

Scope: `projects:read`

One component. A component of a project the person can't open answers 404.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `component` (string (uuid), required)

### Query parameters

- `fields` (string): Only these fields, comma-separated: id, project, name, description, lead, default_assignee, tasks. id always comes; the fields not asked for are left out, required or not.

### Request

```sh
curl -X GET "https://projqo.example/api/v1/orgs/{org}/components/6f1c2a9e-3b7d-4e21-9a55-0c8d2f4b7e10" \
  -H "Authorization: Bearer $PROJQO_TOKEN"
```

### Answer: 200

```json
{
  "id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
  "project": {
    "id": "1b2c3d4e-5f6a-4b7c-8d9e-0f1a2b3c4d5e",
    "key": "WEB",
    "name": "Website"
  },
  "name": "Checkout",
  "description": "Basket and payment pages.",
  "lead": {
    "id": "8d0e5f7a-1c2b-4d3e-8f9a-0b1c2d3e4f5a",
    "name": "Priya Shah"
  },
  "default_assignee": "component_lead",
  "tasks": 9
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation.
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).

## Update a component

`PATCH /orgs/{org}/components/{component}`

Scope: `projects:write`

Changes a component's name, description, lead or default assignee.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `component` (string (uuid), required)

### Body

- `name` (string) [at most 255 characters]
- `description` (string) [at most 4000 characters]
- `lead` (string or null): The lead's id or email; null for none.
- `default_assignee` (string) [one of: component_lead, project_default, project_lead, unassigned]

### Request

```sh
curl -X PATCH "https://projqo.example/api/v1/orgs/{org}/components/6f1c2a9e-3b7d-4e21-9a55-0c8d2f4b7e10" \
  -H "Authorization: Bearer $PROJQO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "string",
  "description": "string",
  "lead": "string",
  "default_assignee": "component_lead"
}'
```

### Answer: 200

```json
{
  "id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
  "project": {
    "id": "1b2c3d4e-5f6a-4b7c-8d9e-0f1a2b3c4d5e",
    "key": "WEB",
    "name": "Website"
  },
  "name": "Checkout",
  "description": "Basket and payment pages.",
  "lead": {
    "id": "8d0e5f7a-1c2b-4d3e-8f9a-0b1c2d3e4f5a",
    "name": "Priya Shah"
  },
  "default_assignee": "component_lead",
  "tasks": 9
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation. refused: The token's person can see the thing but may not do this; the message says why. read_only: The organisation is read-only (over the Free plan's people, or a payment is overdue).
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 413 `too_large`: too_large: The body or a file is larger than allowed.
- 415 `unsupported_media_type`: unsupported_media_type: The body isn't JSON.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).

## Delete a component

`DELETE /orgs/{org}/components/{component}`

Scope: `projects:write`

Deletes a component; its tasks move to move_to (another component of the project) or lose it.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `component` (string (uuid), required)

### Query parameters

- `move_to` (string (uuid))

### Request

```sh
curl -X DELETE "https://projqo.example/api/v1/orgs/{org}/components/6f1c2a9e-3b7d-4e21-9a55-0c8d2f4b7e10" \
  -H "Authorization: Bearer $PROJQO_TOKEN"
```

### Answer: 204

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation. refused: The token's person can see the thing but may not do this; the message says why. read_only: The organisation is read-only (over the Free plan's people, or a payment is overdue).
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).
