
## Delete a key

`DELETE /v1/search/credentials/:id`

Deletes the current user's BYOK key. The key cannot be restored through the API — add a new one via [`POST /v1/search/credentials`](/docs/search/credentials/create) if needed.

## Parameters

| Parameter | Type | Req. | Description |
|----------|-----|:-----:|---------|
| `id` (path) | string | yes | Key identifier from the [`GET /v1/search/credentials`](/docs/search/credentials/list) response or from the creation response |

## Examples

### curl — personal key

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

### curl — OAuth app

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

### JavaScript — personal key

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

if (res.status === 204) {
  console.log('Key deleted')
}
```

### JavaScript — OAuth app

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

if (res.status === 204) {
  console.log('Key deleted')
}
```

## Response

On a successful deletion, HTTP status `204 No Content` is returned with an empty body. The success marker is the response code, not the content.

## Response example

```
HTTP/1.1 204 No Content
```

## Error response example

404 — the key is not found or belongs to another user:

```json
{
  "error": {
    "code": "CREDENTIAL_NOT_FOUND",
    "message": "cmol3pnk5001fo70zefbwb6dl"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `INVALID_API_KEY` | Invalid API key |
| 401 | `UNAUTHORIZED` | The request goes through a `vibe_app_…` key without `Authorization: Bearer <session_token>` |
| 403 | `SCOPE_DENIED` | The key lacks the `vibe:search` scope |
| 404 | `CREDENTIAL_NOT_FOUND` | A key with this `id` does not exist for the current user |
| 429 | `RATE_LIMITED` | The overall request limit is exceeded |
| 500 | `INTERNAL_ERROR` | Internal server error |

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

## Known specifics

**Another user's key is not accessible.** When attempting to delete another user's key, the server returns `404 CREDENTIAL_NOT_FOUND` — without indicating whether the record exists in the system.

**Deleting the default key.** When the default key is deleted, subsequent [`POST /v1/search`](/docs/search/run) calls without an explicit `provider` go through the USER → PORTAL → PLATFORM cascade again. If no other USER keys remain, requests go through the default engine configured on the instance (shown by the `defaultProvider` field in [`GET /v1/me`](/docs/keys-auth)).

**Repeat deletion.** A repeat `DELETE` on the same `id` returns `404 CREDENTIAL_NOT_FOUND`. Use 204 as the "deleted just now" signal, 404 as "the key is already gone".

## See also

- [Your own keys (BYOK)](/docs/search/credentials) — subsection overview
- [List your keys](/docs/search/credentials/list) — `GET /v1/search/credentials`
- [Add a key](/docs/search/credentials/create) — `POST /v1/search/credentials`
- [Test a key](/docs/search/credentials/test) — `POST /v1/search/credentials/:id/test`
- [Search (POST /v1/search)](/docs/search/run) — BYOK key selection cascade
- [Errors](/docs/errors) — API error code reference
