# Personal access tokens

Source: https://www.pontive.com/docs/api-reference/management/personal-access-tokens

Base URL: `https://api.{region}.pontive.com/v1` (operations that name another server say so).

Authentication: send `Authorization: Bearer <token>` with a secret key (`pontive_sk_…`, which implies its instance) or an access token issued for this API. A token that can reach several instances also names one with `X-Pontive-Instance-ID: inst_…`. Secret keys are for servers only.

## List personal access tokens

```http
GET https://api.{region}.pontive.com/v1/personal-access-tokens
```

List personal access tokens with filtering and pagination.

Operation ID: `ListPATs`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `user_id` | string |  | Filter by user id (usr_…) |
| `status` | string |  | Filter by status (active\|revoked) |
| `sort` | string |  | Sort field; prefix with - for descending (e.g. -created_at). Allowed: created_at, updated_at, name, status. Default: -created_at |
| `page` | integer |  | Page number |
| `limit` | integer |  | Items per page |

### Responses

- `200` OK: ListPATsResponse
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `500` Internal Server Error: ErrResponse

## Create personal access token

```http
POST https://api.{region}.pontive.com/v1/personal-access-tokens
```

Mint a personal access token bound to a user. The token value is returned only here. Omit organization_id for an all-orgs token.

Operation ID: `CreatePAT`

### Request body (`application/json`, required): CreatePATRequest

Create PAT payload

### Responses

- `201` Created: PATWithToken
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `500` Internal Server Error: ErrResponse

## Get personal access token

```http
GET https://api.{region}.pontive.com/v1/personal-access-tokens/{personal_access_token_id}
```

Get a personal access token by ID.

Operation ID: `GetPAT`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `personal_access_token_id` | string | yes | PAT ID |

### Responses

- `200` OK: PAT
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `500` Internal Server Error: ErrResponse

## Update personal access token

```http
PATCH https://api.{region}.pontive.com/v1/personal-access-tokens/{personal_access_token_id}
```

Update mutable fields (name, description, metadata).

Operation ID: `UpdatePAT`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `personal_access_token_id` | string | yes | PAT ID |

### Request body (`application/json`, required): UpdatePATRequest

Update payload

### Responses

- `200` OK: PAT
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse

## Revoke personal access token

```http
POST https://api.{region}.pontive.com/v1/personal-access-tokens/{personal_access_token_id}/revoke
```

Revoke a personal access token immediately and irreversibly.

Operation ID: `RevokePAT`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `personal_access_token_id` | string | yes | PAT ID |

### Responses

- `204` No Content
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse

## Schemas

### ListPATsResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | PAT[] |  |  |
| `object` | string |  |  |
| `pagination` | Pagination |  | Pagination is the page answered (api-route-review D9). |

### ErrResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | ErrBody |  |  |

### CreatePATRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string |  |  |
| `expires_at` | string |  |  |
| `metadata` | Metadata |  |  |
| `name` | string | yes |  |
| `organization_id` | string |  |  |
| `user_id` | string | yes |  |

### PATWithToken

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `created_at` | string |  |  |
| `description` | string |  |  |
| `expires_at` | string |  |  |
| `id` | string |  |  |
| `instance_id` | string |  |  |
| `key_preview` | string |  |  |
| `last_used_at` | string |  |  |
| `metadata` | Metadata |  |  |
| `name` | string |  |  |
| `object` | string |  |  |
| `organization_id` | string |  |  |
| `status` | "active" \| "revoked" \| "deleted" \| "expired" |  |  |
| `token` | string |  |  |
| `updated_at` | string |  |  |
| `user_id` | string |  |  |

### PAT

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `created_at` | string |  |  |
| `description` | string |  |  |
| `expires_at` | string |  |  |
| `id` | string |  |  |
| `instance_id` | string |  |  |
| `key_preview` | string |  |  |
| `last_used_at` | string |  |  |
| `metadata` | Metadata |  |  |
| `name` | string |  |  |
| `object` | string |  |  |
| `organization_id` | string |  |  |
| `status` | "active" \| "revoked" \| "deleted" \| "expired" |  |  |
| `updated_at` | string |  |  |
| `user_id` | string |  |  |

### UpdatePATRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string |  |  |
| `metadata` | Metadata |  |  |
| `name` | string |  |  |

### Pagination

Pagination is the page answered (api-route-review D9).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | integer |  | Limit is the maximum number of items per page. |
| `page` | integer |  | Page is the 1-based index of the returned page. |
| `total` | integer |  | Total is the total number of items across all pages. |
| `total_pages` | integer |  | TotalPages is the total number of pages available. |

### ErrBody

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string |  | Code is the spec's machine-readable code for this error, in snake case: a domain code such as seat_limit_reached where the refusal has one, otherwise a generic one such as permission_denied, not_found, conflict, invalid_request or service_unavailable. |
| `details` | ErrDetail[] |  | Details are per-field findings, present only on a refusal that has them, e.g. a 422 invalid_theme names each invalid value by its path, a 422 package_invalid each problem, and a 409 capability_in_use each count by its name. |
| `doc_url` | string |  | DocURL links to documentation about this error, when available. |
| `message` | string |  | Message is a human-readable description of what went wrong. |
| `object` | string |  | Object is the discriminator; always "error". |
| `param` | string |  | Param names the request parameter this error refers to, when applicable. |
| `type` | "validation_error" \| "authentication_error" \| "authorization_error" \| "not_found" \| "conflict_error" \| "rate_limit_error" \| "internal_error" |  | Type is the error's category, set by its HTTP status: one of validation_error, authentication_error, authorization_error, not_found, conflict_error, rate_limit_error, internal_error. |

### Metadata

Type: Record<string, string>

### ErrDetail

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `field` | string |  | Field is where the finding is: for a theme, its dotted path. |
| `message` | string |  | Message is what is wrong there. |
