# Sessions


## List session pins

`GET /v1/session-pins`

List the caller's saved session pins, including unpinned revisions for offline reconciliation.

Permission: `chat.use` (Every member).

### Responses

- `200` The caller's pin settings in this organization. (application/json, SessionPinList)
  - `pins` (array of SessionPin, required)
    - `source` ("chat" | "synced", required)
    - `sessionId` (string, required)
    - `pinned` (boolean, required)
    - `version` (integer, required)
    - `updatedAt` (string (date-time) | null, required)
  - `chats` (array of ChatSession, required)
    - `id` (string, required)
    - `title` (string, required): The first question until you rename it
    - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages
    - `model` (string, required): The model asked for: nexus/auto by default
    - `lastModel` (string): The model that ran last
    - `team` (string): The team its spend is attributed to
    - `archived` (boolean, required)
    - `webSearch` (boolean): Whether the model may search the web in this session (default false)
    - `messageCount` (integer, required)
    - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum
    - `createdAt` (string (date-time), required)
    - `updatedAt` (string (date-time), required)
    - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact
    - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact
      - `artifactId` (string, required)
      - `version` (integer, required)
      - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only.
        - `kind` ("org" | "teams" | "people" | "external" | "public", required)
        - `teams` (array of string, required): Team slugs (kind teams)
        - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization.
      - `allowContinue` (boolean, required)
      - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path
      - `path` (string, required): /app/<org>/artifacts/<id>
      - `viewerUrl` (string): The fast viewer: <origin>/a/<id>
      - `publicUrl` (string): Kind public: <origin>/a/<token>
      - `expiresAt` (string (date-time)): Kind public: when the link stops opening
    - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included)
      - `id` (string, required)
      - `version` (integer, required) [min 1]
      - `status` ("active" | "revoked", required)
      - `audience` ("org" | "teams" | "people" | "external" | "public", required)
      - `createdAt` (string (date-time), required)
      - `revokedAt` (string (date-time))
    - `author` (ArtifactAuthor): You (listed and read sessions)
      - `email` (string)
      - `name` (string)
    - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue)
      - `artifactId` (string, required)
      - `version` (integer, required)
      - `title` (string)
  - `threads` (array of SyncedThread, required)
    - `threadId` (string, required)
    - `personId` (string, required): The thread's person (`users.id`): you, unless an auditor or a teammate reads it.
    - `agent` (string | null, required): The latest event's agent: `claude`, `codex` or `nexus`; null before the first event.
    - `model` (string | null, required)
    - `status` ("running" | "completed" | "interrupted" | "error" | null, required)
    - `totals` (SyncedTotals, required): A thread's usage totals.
      - `inputTokens` (integer, required)
      - `outputTokens` (integer, required)
      - `cacheReadTokens` (integer, required)
      - `cacheWriteTokens` (integer, required)
      - `costUsd` (string, required): A decimal string.
    - `lastSeq` (integer | null, required): The highest event number stored; null before the first event.
    - `keyVersion` (integer | null, required): The newest content key version of a sealed event.
    - `private` (boolean, required): Whether its owner keeps it from their teammates (setSyncedThreadPrivate). Otherwise it is team-visible: any member reads it while the organization's `multiplayerSessions` is on.
    - `followers` (array of string, required): Who follows it: members' ids (`users.id`), in the order they followed it (followSyncedThread).
    - `lastEventAt` (string (date-time) | null, required)
    - `createdAt` (string (date-time), required)
    - `updatedAt` (string (date-time), required)

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/session-pins" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fsession-pins)

## Set session pin

`PUT /v1/session-pins/{source}/{id}`

Set a personal session pin if the caller's revision matches.

Permission: `chat.use` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `source` | path | "chat" \| "synced" | yes |  |
| `id` | path | string | yes |  |

### Request body (application/json, required)

- `pinned` (boolean, required)
- `expectedVersion` (integer, required)

### Responses

- `200` The matching pin, also returned on a retry when the requested state already holds. (application/json, SessionPin)
  - `source` ("chat" | "synced", required)
  - `sessionId` (string, required)
  - `pinned` (boolean, required)
  - `version` (integer, required)
  - `updatedAt` (string (date-time) | null, required)
- `404` The caller cannot pin this session.
- `409` Another device changed this pin (`session_pin_changed`). Read the current list before retrying.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | The caller cannot pin this session. |
| 409 |  | Another device changed this pin (`session_pin_changed`). Read the current list before retrying. |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X PUT "$NEXUS_URL/v1/session-pins/<source>/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "pinned": false,
    "expectedVersion": 1
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fsession-pins%2F%7Bsource%7D%2F%7Bid%7D)
