# Credentials API

> Personal access tokens, service accounts and API keys. Every route, its parameters and fields.

Personal access tokens, service accounts and API keys. 12 routes; send a bearer token with each (see [Authentication](/api/authentication.md)).

| Route | What it does |
| --- | --- |
| `GET /v1/personal-access-tokens` | My personal access tokens |
| `POST /v1/personal-access-tokens` | Create a personal access token |
| `DELETE /v1/personal-access-tokens/{id}` | Revoke a personal access token |
| `GET /v1/service-accounts` | Service accounts (admins) |
| `POST /v1/service-accounts` | Create a service account (admins) |
| `PATCH /v1/service-accounts/{id}` | Rename, change role or deactivate a service account (admins) |
| `GET /v1/service-accounts/{id}/credentials` | A service account's client credentials (admins) |
| `POST /v1/service-accounts/{id}/credentials` | Create client credentials (admins) |
| `DELETE /v1/service-accounts/{id}/credentials/{credentialId}` | Revoke client credentials (admins) |
| `GET /v1/service-accounts/{id}/api-keys` | A service account's API key (admins) |
| `POST /v1/service-accounts/{id}/api-keys` | Create API key (admins) |
| `DELETE /v1/service-accounts/{id}/api-keys/{credentialId}` | Revoke API key (admins) |

## My personal access tokens

`GET https://staging-api.naruskacrm.com/v1/personal-access-tokens`

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of [Credential](/api/reference/objects.md#credential) | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Create a personal access token

`POST https://staging-api.naruskacrm.com/v1/personal-access-tokens`

The token is in this response only. A replay with the same Idempotency-Key returns the metadata without it.

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string | yes | 1–200 characters |
| `scopes` | array of `records:read`, `records:write`, `records:delete`, `webhooks:manage`, `usage:read` | yes |  |
| `expires_in_days` | integer |  | 1–365, default `90` |

### Response 201

Returns: [Credential](/api/reference/objects.md#credential).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Revoke a personal access token

`DELETE https://staging-api.naruskacrm.com/v1/personal-access-tokens/{id}`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 204

Done.
No body.

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Service accounts (admins)

`GET https://staging-api.naruskacrm.com/v1/service-accounts`

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of [User](/api/reference/objects.md#user) | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Create a service account (admins)

`POST https://staging-api.naruskacrm.com/v1/service-accounts`

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `display_name` | string | yes | 1–200 characters |
| `role` | `rep`, `manager`, `director` |  |  |
| `is_admin` | boolean |  |  |

### Response 201

Returns: [User](/api/reference/objects.md#user).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Rename, change role or deactivate a service account (admins)

`PATCH https://staging-api.naruskacrm.com/v1/service-accounts/{id}`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `display_name` | string |  | 1–200 characters |
| `role` | `rep`, `manager`, `director` |  |  |
| `deactivated` | boolean |  |  |

### Response 200

Returns: [User](/api/reference/objects.md#user).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## A service account's client credentials (admins)

`GET https://staging-api.naruskacrm.com/v1/service-accounts/{id}/credentials`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of [Credential](/api/reference/objects.md#credential) | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Create client credentials (admins)

`POST https://staging-api.naruskacrm.com/v1/service-accounts/{id}/credentials`

The secret is in this response only. A replay with the same Idempotency-Key returns the metadata without it.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string | yes | 1–200 characters |
| `scopes` | array of `records:read`, `records:write`, `records:delete`, `webhooks:manage`, `usage:read` | yes |  |
| `expires_in_days` | integer |  | 1–365, default `365` |

### Response 201

Returns: [Credential](/api/reference/objects.md#credential).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Revoke client credentials (admins)

`DELETE https://staging-api.naruskacrm.com/v1/service-accounts/{id}/credentials/{credentialId}`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `credentialId` | path | string (uuid) | yes |  |

### Response 204

Done.
No body.

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## A service account's API key (admins)

`GET https://staging-api.naruskacrm.com/v1/service-accounts/{id}/api-keys`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of [Credential](/api/reference/objects.md#credential) | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Create API key (admins)

`POST https://staging-api.naruskacrm.com/v1/service-accounts/{id}/api-keys`

The secret is in this response only. A replay with the same Idempotency-Key returns the metadata without it.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string | yes | 1–200 characters |
| `scopes` | array of `records:read`, `records:write`, `records:delete`, `webhooks:manage`, `usage:read` | yes |  |
| `expires_in_days` | integer |  | 1–365, default `365` |

### Response 201

Returns: [Credential](/api/reference/objects.md#credential).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Revoke API key (admins)

`DELETE https://staging-api.naruskacrm.com/v1/service-accounts/{id}/api-keys/{credentialId}`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `credentialId` | path | string (uuid) | yes |  |

### Response 204

Done.
No body.

Errors are problem details with a stable `code`: see [Errors](/errors.md).

