> ## Documentation Index
> Fetch the complete documentation index at: https://handbook.nyotaimara.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GET & DELETE /v1/accounts/devices — Session Management

> List active sessions and sign-in history for the authenticated user. Revoke any session remotely with DELETE /v1/accounts/devices/:sessionId.

Manage the sessions associated with the authenticated account. The GET endpoint returns two datasets: active sessions (each showing device, IP, and creation time) and a historical log of the last 20 authentication events. The DELETE endpoint lets users remotely sign out of any session other than their current one.

## GET /v1/accounts/devices

List active sessions and sign-in history.

**GET** `/v1/accounts/devices`

Requires a Bearer token in the `Authorization` header.

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url "https://api.nyotaimara.com/v1/accounts/devices" \
    --header "Authorization: Bearer <token>"
  ```
</CodeGroup>

### Response

<ResponseField name="success" type="boolean" required>
  `true` when the request succeeded.
</ResponseField>

<ResponseField name="data" type="object" required>
  Container for both session datasets.

  <Expandable title="properties">
    <ResponseField name="activeSessions" type="object[]" required>
      List of currently active sessions.

      <Expandable title="session properties">
        <ResponseField name="sessionId" type="string" required>
          Unique session identifier. Use this value with the DELETE endpoint.
        </ResponseField>

        <ResponseField name="userAgent" type="string">
          Raw User-Agent string from the session.
        </ResponseField>

        <ResponseField name="ipAddress" type="string">
          IP address from which the session was created.
        </ResponseField>

        <ResponseField name="createdAt" type="string" required>
          ISO 8601 timestamp when the session was established.
        </ResponseField>

        <ResponseField name="updatedAt" type="string" required>
          ISO 8601 timestamp of the last activity on this session.
        </ResponseField>

        <ResponseField name="isCurrentDevice" type="boolean" required>
          `true` if this session corresponds to the token used in the current request.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="history" type="object[]" required>
      The last 20 authentication log entries for this user, ordered newest first.

      <Expandable title="history entry properties">
        <ResponseField name="id" type="string" required>
          Unique log entry ID.
        </ResponseField>

        <ResponseField name="event" type="string" required>
          The event type, e.g. `"login"` or `"signup"`.
        </ResponseField>

        <ResponseField name="status" type="string" required>
          Outcome of the event: `"success"` or `"failure"`.
        </ResponseField>

        <ResponseField name="ipAddress" type="string">
          IP address associated with the event.
        </ResponseField>

        <ResponseField name="userAgent" type="string">
          Parsed device description, e.g. `"Chrome on Windows 10"`.
        </ResponseField>

        <ResponseField name="country" type="string">
          Country resolved from the IP address.
        </ResponseField>

        <ResponseField name="city" type="string">
          City resolved from the IP address.
        </ResponseField>

        <ResponseField name="createdAt" type="string" required>
          ISO 8601 timestamp of the event.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

```json theme={null}
{
  "success": true,
  "data": {
    "activeSessions": [
      {
        "sessionId": "sess_abc123",
        "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...",
        "ipAddress": "102.0.0.1",
        "createdAt": "2024-06-01T08:00:00.000Z",
        "updatedAt": "2024-06-01T12:45:00.000Z",
        "isCurrentDevice": true
      }
    ],
    "history": [
      {
        "id": "log_xyz789",
        "event": "login",
        "status": "success",
        "ipAddress": "102.0.0.1",
        "userAgent": "Chrome on macOS",
        "country": "Kenya",
        "city": "Nairobi",
        "createdAt": "2024-06-01T08:00:00.000Z"
      }
    ]
  }
}
```

***

## DELETE /v1/accounts/devices/:sessionId

Revoke a specific session.

**DELETE** `/v1/accounts/devices/:sessionId`

Requires a Bearer token in the `Authorization` header.

### Request

<ParamField path="sessionId" type="string" required>
  The `sessionId` of the session to revoke. Obtain this value from `GET /v1/accounts/devices`. You cannot revoke the session that belongs to the token you are currently using.
</ParamField>

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl --request DELETE \
    --url "https://api.nyotaimara.com/v1/accounts/devices/sess_abc123" \
    --header "Authorization: Bearer <token>"
  ```
</CodeGroup>

### Response

<ResponseField name="success" type="boolean" required>
  `true` when the session was successfully revoked.
</ResponseField>

<ResponseField name="message" type="string" required>
  Human-readable confirmation.
</ResponseField>

```json theme={null}
{
  "success": true,
  "message": "Device successfully logged out."
}
```

<Note>
  **Error cases**

  | Status | Error                                              | Description                                              |
  | ------ | -------------------------------------------------- | -------------------------------------------------------- |
  | 400    | `Use standard logout to end your current session.` | The `sessionId` matches the caller's own active session. |
  | 401    | —                                                  | Missing or invalid Bearer token.                         |
  | 403    | `Session does not belong to this user.`            | The session exists but is owned by a different user.     |
  | 500    | `Failed to fetch/revoke device activity`           | An unexpected server-side error occurred.                |
</Note>
