# Links

Links between tasks (blocking links stand for dependencies), link types and web links.

## List link types

`GET /orgs/{org}/link-types`

Scope: `tasks:read`

The organisation's link types, each with its outward and inward wording. linking is false when the organisation has switched linking off (existing links stay; new ones are refused). Organisation admins change link types in the app.

### Path parameters

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

### Request

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

### Answer: 200

```json
{
  "items": [
    {
      "id": "7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d",
      "name": "Blocks",
      "outward": "blocks",
      "inward": "is blocked by",
      "key": "blocks"
    }
  ],
  "next_cursor": null,
  "linking": true
}
```

### 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).

## List a task's links

`GET /orgs/{org}/tasks/{task}/links`

Scope: `tasks:read`

The task's links to other tasks, oldest first, only those whose other task you can open. Blocking links (dependencies) say blocks or blocked_by; the whole list comes in one page.

### Path parameters

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

### Request

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

### Answer: 200

```json
{
  "items": [
    {
      "id": "2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f",
      "type": {
        "id": "7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d",
        "name": "Blocks"
      },
      "direction": "outward",
      "phrase": "blocks",
      "blocking": "blocks",
      "task": {
        "id": "3d4e5f6a-7b8c-4d9e-8f0a-1b2c3d4e5f6a",
        "key": "WEB-14",
        "summary": "Publish the pricing page",
        "status": {
          "id": "4e5f6a7b-8c9d-4e0f-9a1b-2c3d4e5f6a7b",
          "name": "To do",
          "category": "todo"
        },
        "archived": false
      }
    }
  ],
  "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).

## Link a task to others

`POST /orgs/{org}/tasks/{task}/links`

Scope: `tasks:write`

Links the task to one or more tasks (by id or key) with one link type, as Link in the app: you need Link tasks in both tasks' projects, neither may be archived, and two tasks link once per type. One change in the task's History. All or nothing: if one task can't be linked, none is.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `task` (string, required): The task's id or key (WEB-12). [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

- `type` (string, required): A link type's id, its key (blocks) or its name. [1 to 200 characters]
- `direction` (string): outward (the default): this task → the others (this task blocks them); inward: the others → this task. [one of: outward, inward; default outward]
- `tasks` (array of string, required): The other tasks, by id or key: 1 to 50. [1 to 50 items]

### Request

```sh
curl -X POST "https://projqo.example/api/v1/orgs/{org}/tasks/{task}/links" \
  -H "Authorization: Bearer $PROJQO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "type": "string",
  "direction": "outward",
  "tasks": [
    "string"
  ]
}'
```

### Answer: 201

```json
{
  "items": [
    {
      "id": "2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f",
      "type": {
        "id": "7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d",
        "name": "Blocks"
      },
      "direction": "outward",
      "phrase": "blocks",
      "blocking": "blocks",
      "task": {
        "id": "3d4e5f6a-7b8c-4d9e-8f0a-1b2c3d4e5f6a",
        "key": "WEB-14",
        "summary": "Publish the pricing page",
        "status": {
          "id": "4e5f6a7b-8c9d-4e0f-9a1b-2c3d4e5f6a7b",
          "name": "To do",
          "category": "todo"
        },
        "archived": false
      }
    }
  ],
  "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. 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.
- 409 `archived`: archived: The item (or its project) is archived, so it can't be changed. conflict: The thing changed since it was read, or the change clashes with its state.
- 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).

## Change a link's type or direction

`PATCH /orgs/{org}/tasks/{task}/links/{link}`

Scope: `tasks:write`

Changes the link's type (or turns it round), as unlinking and linking again in the app: both are written in the task's History, in one change. The link gets a new id.

### Path parameters

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

### Body

- `type` (string): A link type's id, its key (blocks) or its name. [1 to 200 characters]
- `direction` (string) [one of: outward, inward]

### Request

```sh
curl -X PATCH "https://projqo.example/api/v1/orgs/{org}/tasks/{task}/links/6f1c2a9e-3b7d-4e21-9a55-0c8d2f4b7e10" \
  -H "Authorization: Bearer $PROJQO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "type": "string",
  "direction": "outward"
}'
```

### Answer: 200

```json
{
  "id": "2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f",
  "type": {
    "id": "7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d",
    "name": "Blocks"
  },
  "direction": "outward",
  "phrase": "blocks",
  "blocking": "blocks",
  "task": {
    "id": "3d4e5f6a-7b8c-4d9e-8f0a-1b2c3d4e5f6a",
    "key": "WEB-14",
    "summary": "Publish the pricing page",
    "status": {
      "id": "4e5f6a7b-8c9d-4e0f-9a1b-2c3d4e5f6a7b",
      "name": "To do",
      "category": "todo"
    },
    "archived": false
  }
}
```

### 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.
- 409 `archived`: archived: The item (or its project) is archived, so it can't be changed. conflict: The thing changed since it was read, or the change clashes with its state.
- 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).

## Remove a link

`DELETE /orgs/{org}/tasks/{task}/links/{link}`

Scope: `tasks:write`

Removes the link between the two tasks, as Unlink in the app (written in History).

### Path parameters

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

### Request

```sh
curl -X DELETE "https://projqo.example/api/v1/orgs/{org}/tasks/{task}/links/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.
- 409 `archived`: archived: The item (or its project) is archived, so it can't be changed.
- 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).

## List a task's web links

`GET /orgs/{org}/tasks/{task}/web-links`

Scope: `tasks:read`

Web addresses and Docs pages linked to the task, oldest first. A Docs page you can't open shows without its title or address.

### Path parameters

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

### Request

```sh
curl -X GET "https://projqo.example/api/v1/orgs/{org}/tasks/{task}/web-links" \
  -H "Authorization: Bearer $PROJQO_TOKEN"
```

### Answer: 200

```json
{
  "items": [
    {
      "id": "5f6a7b8c-9d0e-4f1a-8b2c-3d4e5f6a7b8c",
      "kind": "web",
      "text": "Design notes",
      "url": "https://example.com/notes"
    }
  ],
  "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).

## Add a web link

`POST /orgs/{org}/tasks/{task}/web-links`

Scope: `tasks:write`

Adds a web address (http or https, with its text) or a Docs page (by id) to the task. Needs Link tasks.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `task` (string, required): The task's id or key (WEB-12). [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

- `url` (string): An http or https address. [at most 2000 characters]
- `text` (string): The link's text. [at most 255 characters]
- `page` (string (uuid)): A Docs page's id, instead of url.

### Request

```sh
curl -X POST "https://projqo.example/api/v1/orgs/{org}/tasks/{task}/web-links" \
  -H "Authorization: Bearer $PROJQO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "string",
  "text": "string",
  "page": "6f1c2a9e-3b7d-4e21-9a55-0c8d2f4b7e10"
}'
```

### Answer: 201

```json
{
  "id": "5f6a7b8c-9d0e-4f1a-8b2c-3d4e5f6a7b8c",
  "kind": "web",
  "text": "Design notes",
  "url": "https://example.com/notes"
}
```

### 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.
- 409 `archived`: archived: The item (or its project) is archived, so it can't be changed. conflict: The thing changed since it was read, or the change clashes with its state.
- 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).

## Remove a web link

`DELETE /orgs/{org}/tasks/{task}/web-links/{link}`

Scope: `tasks:write`

Removes the web link from the task. Needs Link tasks.

### Path parameters

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

### Request

```sh
curl -X DELETE "https://projqo.example/api/v1/orgs/{org}/tasks/{task}/web-links/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.
- 409 `archived`: archived: The item (or its project) is archived, so it can't be changed.
- 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).
