# Authorities endpoints

Every path starts at your [API URL](https://docs.qualithm.com/api.md#find-your-api-url). Every response is JSON, and an error has the [error body](https://docs.qualithm.com/api.md#errors).

## List the team's certificate authorities

`GET /v1/teams/{teamId}/authorities`

Newest first, by `createdAt` then `id`.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `authority.read` permission, which the owner and manager roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `limit` | query | integer | No | Items per page, 1 to 100. Default 50. |
| `cursor` | query | string | No | A previous page's `nextCursor`, to read the page after it |

**Response:** `200` with [AuthorityPage](#authoritypage) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/teams/<team-id>/authorities" \
  -H "Authorization: Bearer <your-api-token>"
```

## Register a certificate authority

`POST /v1/teams/{teamId}/authorities`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `authority.manage` permission, which the owner and manager roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `Idempotency-Key` | header | string | No | A unique key for this request. A retry with the same key and body returns the first response instead of acting again; keys last 24 hours. |

**Request body:** [CreateAuthorityRequest](#createauthorityrequest)

**Response:** `201` with [Authority](#authority) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `409`, `413`, `415`, `429`, `500`, `503`

```bash
curl -X POST "<your-api-url>/v1/teams/<team-id>/authorities" \
  -H "Authorization: Bearer <your-api-token>" \
  -H "Content-Type: application/json" \
  -d '{"name":"<name>","kind":"platform"}'
```

## Revoke a certificate authority and every credential it issued

`DELETE /v1/teams/{teamId}/authorities/{authorityId}`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `authority.manage` permission, which the owner and manager roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |
| `authorityId` | path | string | Yes | A device authority ID: `dca_…`; also accepts the legacy `auth_…` |

**Response:** `204` with no body.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl -X DELETE "<your-api-url>/v1/teams/<team-id>/authorities/<authority-id>" \
  -H "Authorization: Bearer <your-api-token>"
```

## Types

### AuthorityPage

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `items` | array of [Authority](#authority) | Yes |  |
| `nextCursor` | string or null | Yes | Pass as `cursor` to read the next page; `null` on the last page |

### Authority

A certificate authority device certificates chain to: platform-managed or brought by the team.

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `id` | string | Yes | A device authority ID: `dca_…`; also accepts the legacy `auth_…` |
| `teamId` | string | Yes | A team ID: `tem_…`; also accepts the legacy `tm_…` |
| `name` | string | Yes |  |
| `kind` | one of `"platform"`, `"byo"` | Yes |  |
| `certificatePem` | string or null | Yes |  |
| `fingerprint` | string or null | Yes | SHA-256 of the CA certificate |
| `status` | one of `"active"`, `"revoked"` | Yes |  |
| `createdAt` | string (date-time) | Yes | UTC time, RFC 3339 |
| `updatedAt` | string (date-time) | Yes | UTC time, RFC 3339 |

### CreateAuthorityRequest

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `name` | string | Yes | 1 to 64 characters |
| `kind` | one of `"platform"`, `"byo"` | Yes | `platform` generates a managed CA; `byo` registers the team's own |
| `certificatePem` | string | No | The CA certificate, required for `byo` |
