# Users

The users of Ella PSAP and their API tokens. Paths under `/api/v1/users/me` act on the user of the token. The others require Admin, and an access token rather than an API token.

## Get My User

Returns the logged-in user and their role.

| Method | Path |
| --- | --- |
| GET | `/api/v1/users/me` |

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `email` | string | Email address. |
| `role_id` | int | `1`, `2` or `3`. See [roles](<https://docs.ellanetworks.com/psap/reference/api/index.md#roles>). |
| `password_set` | boolean | The user has a password. |
| `oidc_linked` | boolean | The user is linked to an account at the current [identity provider](<https://docs.ellanetworks.com/psap/reference/api/oidc/index.md>). |
| `available` | boolean | Emergencies ring for the user. See [call takers](<https://docs.ellanetworks.com/psap/reference/api/call_takers/index.md>). |

The other paths that return users return the same fields.

### Sample Response

```
{
    "result": {
        "email": "admin@example.com",
        "role_id": 1,
        "password_set": true,
        "oidc_linked": false,
        "available": true
    }
}
```

## Update My Password

Changes the password of the logged-in user, and ends their other sessions.

| Method | Path |
| --- | --- |
| PUT | `/api/v1/users/me/password` |

### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `current_password` | string | Yes | Current password. |
| `password` | string | Yes | New password, 8 to 72 bytes. |

### Sample Request

```
{
    "current_password": "correct horse",
    "password": "correct horse battery"
}
```

### Sample Response

```
{
    "result": {
        "message": "Password updated successfully"
    }
}
```

## Update My Availability

Sets whether emergencies ring for the logged-in user.

| Method | Path |
| --- | --- |
| PUT | `/api/v1/users/me/availability` |

### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `available` | boolean | Yes | `true`: emergencies ring for the user. |

### Sample Request

```
{
    "available": false
}
```

### Sample Response

```
{
    "result": {
        "email": "taker@example.com",
        "role_id": 2,
        "password_set": true,
        "oidc_linked": false,
        "available": false
    }
}
```

## List Users

Returns the users of Ella PSAP and their roles.

| Method | Path |
| --- | --- |
| GET | `/api/v1/users` |

### Query Parameters

| Name | In | Type | Default | Allowed | Description |
| --- | --- | --- | --- | --- | --- |
| `page` | query | int | `1` | `>= 1` | 1-based page index. |
| `per_page` | query | int | `25` | `1…100` | Number of items per page. |

### Sample Response

```
{
    "result": {
        "items": [
            {
                "email": "admin@example.com",
                "role_id": 1,
                "password_set": true,
                "oidc_linked": false,
                "available": true
            },
            {
                "email": "taker@example.com",
                "role_id": 2,
                "password_set": true,
                "oidc_linked": false,
                "available": true
            }
        ],
        "page": 1,
        "per_page": 25,
        "total_count": 3
    }
}
```

## Create a User

Creates a user with an email, a password and a role.

| Method | Path |
| --- | --- |
| POST | `/api/v1/users` |

### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | string | Yes | Email address. ASCII letters are stored in lower case. |
| `password` | string | No | Empty, or 8 to 72 bytes. Empty or without it, the user logs in only through the [identity provider](<https://docs.ellanetworks.com/psap/reference/api/oidc/index.md>). Not allowed for a Dispatch System. |
| `role_id` | int | Yes | `1`, `2` or `3`. See [roles](<https://docs.ellanetworks.com/psap/reference/api/index.md#roles>). |

### Sample Request

```
{
    "email": "taker@example.com",
    "password": "another horse",
    "role_id": 2
}
```

### Sample Response

```
{
    "result": {
        "message": "User created successfully"
    }
}
```

## Get a User

Returns one user and their role.

| Method | Path |
| --- | --- |
| GET | `/api/v1/users/{email}` |

### Sample Response

```
{
    "result": {
        "email": "taker@example.com",
        "role_id": 2,
        "password_set": true,
        "oidc_linked": false,
        "available": true
    }
}
```

## Update a User

Changes the role of a user. A new role ends their sessions and deletes their API tokens.

| Method | Path |
| --- | --- |
| PUT | `/api/v1/users/{email}` |

### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `role_id` | int | Yes | `1`, `2` or `3`. |

### Sample Request

```
{
    "role_id": 1
}
```

### Sample Response

```
{
    "result": {
        "message": "User updated successfully"
    }
}
```

## Update a User's Availability

Sets whether emergencies ring for a user.

| Method | Path |
| --- | --- |
| PUT | `/api/v1/users/{email}/availability` |

### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `available` | boolean | Yes | `true`: emergencies ring for the user. |

### Sample Request

```
{
    "available": false
}
```

### Sample Response

```
{
    "result": {
        "email": "taker@example.com",
        "role_id": 2,
        "password_set": true,
        "oidc_linked": false,
        "available": false
    }
}
```

## Update a User's Password

Sets a new password for a user, and ends their sessions.

| Method | Path |
| --- | --- |
| PUT | `/api/v1/users/{email}/password` |

### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `password` | string | Yes | 8 to 72 bytes. |

### Sample Response

```
{
    "result": {
        "message": "Password updated successfully"
    }
}
```

## Remove a User's Password

Removes a user's password, so they can log in only through the identity provider.

| Method | Path |
| --- | --- |
| DELETE | `/api/v1/users/{email}/password` |

### Sample Response

```
{
    "result": {
        "message": "Password removed successfully"
    }
}
```

## Unlink a User

Unlinks a user from their account at the identity provider.

| Method | Path |
| --- | --- |
| DELETE | `/api/v1/users/{email}/oidc` |

### Sample Response

```
{
    "result": {
        "message": "User unlinked successfully"
    }
}
```

## Delete a User

Deletes a user with their sessions and API tokens.

| Method | Path |
| --- | --- |
| DELETE | `/api/v1/users/{email}` |

### Sample Response

```
{
    "result": {
        "message": "User deleted successfully"
    }
}
```

## Create an API Token

Creates an API token for an admin or a dispatch system, and returns it the only time it is shown.

| Method | Path |
| --- | --- |
| POST | `/api/v1/users/me/api-tokens` |
| POST | `/api/v1/users/{email}/api-tokens` |

### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | Yes | 3 to 50 characters, unique among the user's tokens. |
| `expires_at` | string | No | RFC 3339 time in the future. Without it, the token does not expire. |

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `token` | string | `ellapsap_`, the token identifier, `_` and the secret. |

### Sample Request

```
{
    "name": "Prometheus scraper",
    "expires_at": "2027-11-13T00:00:00Z"
}
```

### Sample Response

```
{
    "result": {
        "token": "ellapsap_95Q0Y4lBtx2O_FAPT4VAIG3XDCT2V3D2LTEEYCS"
    }
}
```

## List API Tokens

Returns the user's API tokens, without their secret.

| Method | Path |
| --- | --- |
| GET | `/api/v1/users/me/api-tokens` |
| GET | `/api/v1/users/{email}/api-tokens` |

### Query Parameters

| Name | In | Type | Default | Allowed | Description |
| --- | --- | --- | --- | --- | --- |
| `page` | query | int | `1` | `>= 1` | 1-based page index. |
| `per_page` | query | int | `25` | `1…100` | Number of items per page. |

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Token identifier: the part of the token between `ellapsap_` and the next `_`. |
| `name` | string | Name. |
| `created_at` | string | Creation time. |
| `expires_at` | string | Expiry time. Absent for a token that does not expire. |
| `last_used_at` | string | Time of the last use, updated at most once a minute. Absent for a token never used. |

### Sample Response

```
{
    "result": {
        "items": [
            {
                "id": "95Q0Y4lBtx2O",
                "name": "Prometheus scraper",
                "created_at": "2026-11-13T16:30:39.168Z",
                "expires_at": "2027-11-13T00:00:00.000Z",
                "last_used_at": "2026-11-13T16:30:55.267Z"
            }
        ],
        "page": 1,
        "per_page": 25,
        "total_count": 1
    }
}
```

## Delete an API Token

Deletes one of the user's API tokens, which stops working at once.

| Method | Path |
| --- | --- |
| DELETE | `/api/v1/users/me/api-tokens/{id}` |
| DELETE | `/api/v1/users/{email}/api-tokens/{id}` |

### Sample Response

```
{
    "result": {
        "message": "API token deleted successfully"
    }
}
```
