# API-Key löschen

Ab diesem Zeitpunkt lehnt das Gateway den Key ab. Mit ihm erstellte Generierungen behalten ihre Key-ID. Ein Management-Key kann keine Management-Keys löschen, auch nicht den eigenen (403).

`DELETE https://tokenlane.de/api/keys/{id}`

## Authentifizierung

[
  [
    {
      "name": "Authorization",
      "description": "Management-Key der Organisation: `Authorization: Bearer sk-tl-v1-…`. Bestehende `sk-eu-`-Keys bleiben gültig. Erforderliche Scopes stehen in `x-scopes`; Inferenz-Keys berechtigen nicht zu Verwaltungsoperationen.",
      "type": "http bearer",
      "location": "",
      "scopes": []
    }
  ]
]

## curl

```curl
curl --request DELETE \
  --url 'https://tokenlane.de/api/keys/key_01k7tm3w8vfz6b2r4m9q5xyz7c' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Origin: https://tokenlane.de'
```

## node

```node
const response = await fetch("https://tokenlane.de/api/keys/key_01k7tm3w8vfz6b2r4m9q5xyz7c", {
  method: "DELETE",
  headers: {
    "Authorization": "Bearer " + process.env.TOKENLANE_API_KEY,
    "Origin": "https://tokenlane.de",
  },
});
console.log(await response.text());
```

## python

```python
import os
import urllib.request

request = urllib.request.Request(
    "https://tokenlane.de/api/keys/key_01k7tm3w8vfz6b2r4m9q5xyz7c",
    method="DELETE",
    headers={
        "Authorization": "Bearer " + os.environ["TOKENLANE_API_KEY"],
        "Origin": "https://tokenlane.de",
    },
)

with urllib.request.urlopen(request) as response:
    print(response.read().decode("utf-8"))
```

## vercel

```vercel
// This operation uses HTTP directly.
const response = await fetch("https://tokenlane.de/api/keys/key_01k7tm3w8vfz6b2r4m9q5xyz7c", {
  method: "DELETE",
  headers: {
    "Authorization": "Bearer " + process.env.TOKENLANE_API_KEY,
    "Origin": "https://tokenlane.de",
  },
});
console.log(await response.text());
```

## Pfadparameter: id (Pflichtfeld)

Key-ID

### s14: string

Key-ID

{}

```json
"key_01k7tm3w8vfz6b2r4m9q5xyz7c"
```

## Antwort 204: 

Key gelöscht

## Antwort 400: application/json

Ungültige Anfrage: Validierungsfehler oder ungültige Eingabe.

```json
{
  "status": 400,
  "code": "VALIDATION_ERROR",
  "message": "Request validation failed"
}
```

### s11: object

{}

- requestId (optional): s56

### s56: string

Serverseitige Zuordnungs-ID für einen internen Fehler. Auch in X-Request-Id enthalten.

uuid

{}

- status (Pflichtfeld): s57

### s57: number

HTTP-Statuscode

{}

```json
400
```

- code (Pflichtfeld): s58

### s58: string

Fehlercode

{}

```json
"VALIDATION_ERROR"
```

- message (Pflichtfeld): s59

### s59: string

Fehlermeldung

{}

```json
"Request validation failed"
```

- remedy_hint (optional): s60

### s60: string

Sichere, ausführbare Abhilfe aus dem Fehlerkatalog.

{}

- details (optional): s61

### s61: array

Detaillierte Validierungsfehler

{}

### s154: object

{}

- path (Pflichtfeld): s179

### s179: string

Feldpfad

{}

```json
"title"
```

- message (Pflichtfeld): s180

### s180: string

Fehlermeldung zum Feld

{}

```json
"Required"
```

## Antwort 401: application/json

Authentifizierung erforderlich: Zugangsdaten fehlen oder sind ungültig.

```json
{
  "status": 400,
  "code": "VALIDATION_ERROR",
  "message": "Request validation failed"
}
```

## Antwort 403: application/json

Berechtigungsumfang reicht nicht aus: authentifiziert, aber nicht berechtigt.

```json
{
  "status": 400,
  "code": "VALIDATION_ERROR",
  "message": "Request validation failed"
}
```

## Antwort 404: application/json

Ressource nicht gefunden

```json
{
  "status": 400,
  "code": "VALIDATION_ERROR",
  "message": "Request validation failed"
}
```

## Antwort 409: application/json

Konflikt mit dem aktuellen Zustand, beispielsweise ein bereits vorhandener Name.

```json
{
  "status": 400,
  "code": "VALIDATION_ERROR",
  "message": "Request validation failed"
}
```

## Antwort 500: application/json

Interner Serverfehler

```json
{
  "status": 400,
  "code": "VALIDATION_ERROR",
  "message": "Request validation failed"
}
```

## Antwort 503: application/json

Konfigurierter Upstream hat das Zeitlimit überschritten, ist fehlgeschlagen oder hat eine ungültige Antwort geliefert.

```json
{
  "status": 400,
  "code": "VALIDATION_ERROR",
  "message": "Request validation failed"
}
```
