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

# GET /v1/me

> Returns the scopes of the authenticated Personal Access Token. Useful for verifying the token works and discovering which endpoints you can call.

Returns the scopes of the authenticated token as stored in the database. Mostly useful for:

* Validating at the start of your integration that the token is alive and carries the scopes you expect.
* Showing the end user (in your app's settings UI) which actions they'll be able to perform.
* Detecting whether the token has been revoked (the endpoint will return `401`).

## Endpoint

```
GET https://api.keebai.com/v1/me
```

## Headers

| Header          | Required | Value                    |
| --------------- | -------- | ------------------------ |
| `Authorization` | Yes      | `Bearer kbai_pk_<token>` |

No body, query params, or path params required.

## Example request

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.keebai.com/v1/me \
    -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ```

  ```js JavaScript theme={null}
  const response = await fetch("https://api.keebai.com/v1/me", {
    headers: { Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}` },
  });
  const { permissions } = await response.json();
  ```

  ```python Python theme={null}
  import os, requests

  resp = requests.get(
      "https://api.keebai.com/v1/me",
      headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
      timeout=10,
  )
  resp.raise_for_status()
  permissions = resp.json()["permissions"]
  ```
</CodeGroup>

## Response

### 200 OK

```json theme={null}
{
  "permissions": [
    "messages:send",
    "templates:read"
  ]
}
```

| Field         | Type       | Description                                                                                                                     |
| ------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `permissions` | `string[]` | The token's scopes. Matches the `scopes` array chosen at creation. Doesn't change between requests unless you mint a new token. |

### 401 Unauthorized

Token is invalid, revoked, or expired. See [Authentication errors](/dev/authentication#authentication-errors).

```json theme={null}
{
  "message": "Invalid or missing API token",
  "error": "Unauthorized",
  "statusCode": 401
}
```

### 429 Too Many Requests

You hit the rate limit. See [Rate limits](/dev/rate-limits).

## Common patterns

### Validate at integration startup

```python theme={null}
import os, requests, sys

REQUIRED = {"messages:send", "templates:read"}

resp = requests.get(
    "https://api.keebai.com/v1/me",
    headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
    timeout=10,
)
if resp.status_code == 401:
    sys.exit("Token invalid or revoked")
resp.raise_for_status()

scopes = set(resp.json()["permissions"])
missing = REQUIRED - scopes
if missing:
    sys.exit(f"Missing scopes: {sorted(missing)}")

print("Token OK with scopes:", sorted(scopes))
```

### Integration health check

Call `GET /v1/me` every 5 minutes as an internal liveness probe: if you get `401` repeatedly, alert your team that the token has been revoked or has expired.

## Revoke the current token

`DELETE /v1/me/token` — server-side logout: marks the PAT this request is authenticated with as revoked. Future requests with the same token return `401`.

```bash theme={null}
curl -X DELETE https://api.keebai.com/v1/me/token \
  -H "Authorization: Bearer kbai_pk_xxx"
```

**Response 204** — no body.

Equivalent to `keebai logout` from the CLI: the local credentials file is removed and server-side the token is permanently invalid.

<Tip>
  No scope required. Any PAT can revoke itself. To revoke **other** tokens (for instance, from an admin panel), use the portal's internal endpoints, not the public API.
</Tip>

Typical use cases:

<CardGroup cols={2}>
  <Card title="Logout in a multi-tenant integration">
    Your app lets a user unlink Keebai. You fire `DELETE /v1/me/token` and delete the token from your storage.
  </Card>

  <Card title="Rotation with guaranteed expiry">
    After minting a new token and rotating your integration, call `DELETE /v1/me/token` on the old one to make sure it's invalid (don't wait for the user to revoke it manually).
  </Card>
</CardGroup>


## OpenAPI

````yaml GET /v1/me
openapi: 3.0.0
info:
  title: Keebai Public API
  description: Superficie pública REST autenticada con Personal Access Tokens (PAT).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.keebai.com
    description: Production
security: []
tags: []
paths:
  /v1/me:
    get:
      tags:
        - me
      summary: Obtener permisos efectivos del token
      description: >-
        Devuelve los permisos efectivos otorgados por el Personal Access Token
        autenticado.
      operationId: MeController_getMe
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MeResponseDto'
        '401':
          description: Token inválido, revocado o expirado
      security:
        - PAT: []
components:
  schemas:
    MeResponseDto:
      type: object
      properties:
        permissions:
          description: >-
            Permisos efectivos del token: intersección entre los scopes del
            token y los permisos actuales del usuario.
          example:
            - conversations.read
            - contacts.read
          type: array
          items:
            type: string
      required:
        - permissions
  securitySchemes:
    PAT:
      scheme: bearer
      bearerFormat: kbai_pk_<hex>
      type: http
      description: >-
        Personal Access Token con prefijo `kbai_pk_`. Generar desde el portal
        con permiso `developer.manage_tokens`.

````