
## List keys

`GET /v1/ai/credentials`

Returns all BYOK keys connected by the current user (USER scope), together with usage statistics for the last 30 days. Bitrix24 account-level keys (PORTAL) do not appear in this list — they are connected by the administrator in the Vibecode dashboard.

## Parameters

There are no request parameters.

## Examples

### curl — personal key

```bash
curl https://vibecode.bitrix24.com/v1/ai/credentials \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl https://vibecode.bitrix24.com/v1/ai/credentials \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/ai/credentials', {
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { data } = await res.json()
data.forEach((cred) => {
  console.log(`${cred.name} (${cred.provider.name}) — ${cred.usage.requests} requests over 30 days`)
})
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/ai/credentials', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { data } = await res.json()
console.log('Providers connected:', data.length)
```

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of connected keys |
| `data[].id` | string | Unique key ID |
| `data[].providerId` | string | Provider ID. List: [`GET /v1/ai/providers`](/docs/ai/credentials/providers) |
| `data[].provider.slug` | string | System provider name: `openai`, `anthropic`, `custom-openai-compat`, etc. |
| `data[].provider.name` | string | Display name of the provider |
| `data[].name` | string | Key name set by the user |
| `data[].isDefault` | boolean | Default-key flag for the provider |
| `data[].lastError` | string \| null | Last verification error (null if there were no errors) |
| `data[].lastErrorAt` | string \| null | Time of the last error in `ISO 8601` |
| `data[].usage.requests` | number | Number of requests over the last 30 days |
| `data[].usage.promptTokens` | number | Input tokens over 30 days |
| `data[].usage.completionTokens` | number | Response tokens over 30 days |
| `data[].createdAt` | string | Creation time in `ISO 8601` |
| `data[].updatedAt` | string | Time of the last update in `ISO 8601` |

## Response example

```json
{
  "success": true,
  "data": [
    {
      "id": "cred_abc123def456",
      "providerId": "openai",
      "provider": {
        "slug": "openai",
        "name": "OpenAI"
      },
      "name": "My personal OpenAI",
      "isDefault": true,
      "lastError": null,
      "lastErrorAt": null,
      "usage": {
        "requests": 142,
        "promptTokens": 45200,
        "completionTokens": 18300
      },
      "createdAt": "2026-04-15T10:00:00.000Z",
      "updatedAt": "2026-04-20T14:30:00.000Z"
    }
  ]
}
```

If no keys are connected — `data` will be an empty array:

```json
{
  "success": true,
  "data": []
}
```

## Error response example

`403 scope_missing` — the API key does not have the `vibe:ai` scope:

```json
{
  "success": false,
  "error": {
    "code": "scope_missing",
    "message": "API key does not have the vibe:ai scope"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 403 | `scope_missing` | The API key lacks the `vibe:ai` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not provided |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

**Only USER keys are visible.** The endpoint shows the keys you connected personally. Bitrix24 account-level keys (PORTAL scope) that the administrator configured for all members are not shown here. They are connected by the administrator in the Vibecode dashboard.

**`lastError` shows the latest problem.** If a key's `lastError` is not `null` — the provider returned an error on the last check (via `POST /v1/ai/credentials/:id/test` or when used in chat completion). The field resets on a successful `PATCH` that updates `credentials` or on a successful check.

**Statistics for a fixed 30-day period.** The `usage` field contains figures for the last 30 days with no option to set the period. For an arbitrary period — [`GET /v1/ai/credentials/:id/usage?days=N`](./usage.md).

## See also

- [Connect a key](./create.md)
- [List of providers](/docs/ai/credentials/providers)
- [Your own keys (BYOK)](/docs/ai/credentials)
