# Revoke a customer key

Permanently revokes a customer key and returns its current fields, including the new ETag.

Source: https://zerocopy.sh/docs/reference/management-api/revoke-a-customer-key

`DELETE https://console.zerocopy.sh/api/v1/customer-keys/{id}`

Authentication: API key, one of: `Authorization: Bearer` header.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes |  |
| `If-Match` | header | string | no | Change only the key version last read; a stale validator returns 412 |

## Responses

### 200

The revoked key

| Header | Type | Description |
| --- | --- | --- |
| `ETag` | string | Strong validator of the returned key state |

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes |  |
| `name` | string or null | yes |  |
| `products` | array of `"send"` or `"jsonrpc"` or `"ws"` or `"grpc"` or `"deshred"` or `"das"` or `"history"` | yes |  |
| `created_at` | string (date-time) or null | yes |  |
| `expires_at` | string (date-time) or null | yes |  |
| `paused_at` | string (date-time) or null | yes | When the key was paused, or null. Use the customer-key pause and resume endpoints to change it |
| `revoked` | boolean | yes |  |
| `revoked_at` | string (date-time) or null | yes |  |
| `rules` | object | yes | Rules for a key's read products; a request must also pass the endpoint's own |
| `rules.endpoints` | object or object | yes | Endpoints the key reads through: every one, or only those listed Default `{"mode":"all"}`. |
| `rules.endpoints.mode` | `"all"` | yes |  |
| `rules.endpoints.mode` | `"only"` | yes |  |
| `rules.endpoints.ids` | array of string | yes | maxItems: `256`. |
| `rules.ips` | array of string | yes | IPv4 addresses or CIDR ranges requests may come from; empty allows any Default `[]`. maxItems: `256`. |
| `rules.origins` | array of string | yes | Web origins requests may carry; empty allows any Default `[]`. maxItems: `256`. |
| `rules.methods` | object | yes | JSON-RPC methods allowed or refused Default `{"mode":"all","list":[]}`. |
| `rules.methods.mode` | `"all"` or `"allow"` or `"deny"` | yes |  |
| `rules.methods.list` | array of string | yes | Default `[]`. maxItems: `256`. |
| `send` | object or null | yes | The key's sending settings; null without the `send` product |
| `send.rate_per_second` | integer | yes | minimum: `-9007199254740991`. maximum: `9007199254740991`. |
| `send.min_tip_lamports` | integer | yes | minimum: `-9007199254740991`. maximum: `9007199254740991`. |
| `customer_ref` | string or null | yes | Customer reference, or null for an unassigned key minLength: `1`. maxLength: `100`. |

```json title="Permanently revoked customer key"
{
  "id": "key_012345abcdef",
  "name": "Acme primary",
  "products": [
    "send"
  ],
  "created_at": "2026-11-12T09:00:00Z",
  "expires_at": null,
  "paused_at": null,
  "revoked": true,
  "revoked_at": "2026-11-13T02:14:00Z",
  "rules": {
    "endpoints": {
      "mode": "all"
    },
    "ips": [],
    "origins": [],
    "methods": {
      "mode": "all",
      "list": []
    }
  },
  "send": {
    "rate_per_second": 15,
    "min_tip_lamports": 1000000
  },
  "customer_ref": "acme-123"
}
```

### 400

A refusal; `code` is stable

Content type: `application/problem+json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `title` | string | yes |  |
| `status` | integer | yes | minimum: `-9007199254740991`. maximum: `9007199254740991`. |
| `code` | string | yes | Stable, for programs to branch on |
| `detail` | string | yes |  |
| `request_id` | string | yes |  |
| `errors` | array of object | no |  |
| `errors[].path` | string | yes |  |
| `errors[].message` | string | yes |  |

```json title="Invalid request"
{
  "title": "Bad request",
  "status": 400,
  "code": "invalid_request",
  "detail": "The request does not match the schema.",
  "request_id": "8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"
}
```

### 401

A refusal; `code` is stable

Content type: `application/problem+json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `title` | string | yes |  |
| `status` | integer | yes | minimum: `-9007199254740991`. maximum: `9007199254740991`. |
| `code` | string | yes | Stable, for programs to branch on |
| `detail` | string | yes |  |
| `request_id` | string | yes |  |
| `errors` | array of object | no |  |
| `errors[].path` | string | yes |  |
| `errors[].message` | string | yes |  |

```json title="Unknown, revoked or expired management key"
{
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The management key is unknown, revoked or expired.",
  "request_id": "8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"
}
```

### 403

A refusal; `code` is stable

Content type: `application/problem+json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `title` | string | yes |  |
| `status` | integer | yes | minimum: `-9007199254740991`. maximum: `9007199254740991`. |
| `code` | string | yes | Stable, for programs to branch on |
| `detail` | string | yes |  |
| `request_id` | string | yes |  |
| `errors` | array of object | no |  |
| `errors[].path` | string | yes |  |
| `errors[].message` | string | yes |  |

```json title="IP restriction"
{
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden_ip",
  "detail": "This key does not allow requests from this address.",
  "request_id": "8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"
}
```

### 404

A refusal; `code` is stable

Content type: `application/problem+json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `title` | string | yes |  |
| `status` | integer | yes | minimum: `-9007199254740991`. maximum: `9007199254740991`. |
| `code` | string | yes | Stable, for programs to branch on |
| `detail` | string | yes |  |
| `request_id` | string | yes |  |
| `errors` | array of object | no |  |
| `errors[].path` | string | yes |  |
| `errors[].message` | string | yes |  |

```json title="Unknown route"
{
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No such route.",
  "request_id": "8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"
}
```

### 412

A refusal; `code` is stable

Content type: `application/problem+json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `title` | string | yes |  |
| `status` | integer | yes | minimum: `-9007199254740991`. maximum: `9007199254740991`. |
| `code` | string | yes | Stable, for programs to branch on |
| `detail` | string | yes |  |
| `request_id` | string | yes |  |
| `errors` | array of object | no |  |
| `errors[].path` | string | yes |  |
| `errors[].message` | string | yes |  |

```json title="Stale key version"
{
  "title": "Precondition failed",
  "status": 412,
  "code": "precondition_failed",
  "detail": "The API key changed. Read it again before retrying.",
  "request_id": "8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"
}
```

### 429

A refusal; `code` is stable

Content type: `application/problem+json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `title` | string | yes |  |
| `status` | integer | yes | minimum: `-9007199254740991`. maximum: `9007199254740991`. |
| `code` | string | yes | Stable, for programs to branch on |
| `detail` | string | yes |  |
| `request_id` | string | yes |  |
| `errors` | array of object | no |  |
| `errors[].path` | string | yes |  |
| `errors[].message` | string | yes |  |

```json title="Management write limit"
{
  "title": "Too many requests",
  "status": 429,
  "code": "rate_limited",
  "detail": "This key may make 60 such requests a minute.",
  "request_id": "8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"
}
```

## Code samples

```rust title="Rust"
// src/bin/management_revoke_customer_key.rs
// Builds on the example project (/reference/json-rpc#example-project).
use swqos_examples::swqos::{Result, required};

#[tokio::main]
async fn main() -> Result<()> {
    let key_id: String = required("KEY_ID")?;
    let mut endpoint = reqwest::Url::parse("https://console.zerocopy.sh/api/v1/customer-keys/")?;
    endpoint.path_segments_mut().map_err(|_| "invalid base URL")?
        .pop_if_empty().push(&key_id);
    let request = reqwest::Client::new()
        .delete(endpoint)
        .bearer_auth(required("MANAGEMENT_API_KEY")?);
    let request = if let Ok(etag) = std::env::var("KEY_ETAG") {
        request.header("If-Match", etag)
    } else {
        request
    };
    let response = request.send().await?;
    let status = response.status();
    let request_id = response.headers().get("Request-Id")
        .map(|value| value.to_str()).transpose()?.unwrap_or("<missing>").to_owned();
    if let Some(etag) = response.headers().get("ETag") {
        eprintln!("ETag: {}", etag.to_str()?);
    }
    let body = response.text().await?;
    if !status.is_success() {
        return Err(format!("HTTP {status}; Request-Id: {request_id}; {body}").into());
    }
    eprintln!("Request-Id: {request_id}");
    println!("{body}");
    Ok(())
}
```

```go title="Go"
// management_revoke_customer_key/main.go
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
)

func required(name string) (string, error) {
    value := os.Getenv(name)
    if value == "" {
        return "", fmt.Errorf("set %s", name)
    }
    return value, nil
}

func run() error {
    apiKey, err := required("MANAGEMENT_API_KEY")
    if err != nil {
        return err
    }
    keyID, err := required("KEY_ID")
    if err != nil {
        return err
    }
    endpoint, err := url.Parse("https://console.zerocopy.sh/api/v1/customer-keys/")
    if err != nil {
        return err
    }
    endpoint.Path += keyID
    request, err := http.NewRequest(http.MethodDelete, endpoint.String(), nil)
    if err != nil {
        return err
    }
    request.Header.Set("Authorization", "Bearer "+apiKey)
    if etag := os.Getenv("KEY_ETAG"); etag != "" {
        request.Header.Set("If-Match", etag)
    }
    response, err := http.DefaultClient.Do(request)
    if err != nil {
        return err
    }
    defer response.Body.Close()
    requestID := response.Header.Get("Request-Id")
    body, err := io.ReadAll(response.Body)
    if err != nil {
        return fmt.Errorf("Request-Id: %s: %w", requestID, err)
    }
    if response.StatusCode < 200 || response.StatusCode >= 300 {
        return fmt.Errorf("HTTP %d; Request-Id: %s; %s", response.StatusCode, requestID, body)
    }
    fmt.Fprintln(os.Stderr, "Request-Id:", requestID)
    if etag := response.Header.Get("ETag"); etag != "" {
        fmt.Fprintln(os.Stderr, "ETag:", etag)
    }
    fmt.Println(string(body))
    return nil
}

func main() {
    if err := run(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}
```

```ts title="TypeScript"
// management-revoke-customer-key.ts
export {}

function required(name: string): string {
  const value = process.env[name]
  if (!value) throw new Error(`set ${name}`)
  return value
}

const keyId: string = required('KEY_ID')
const endpoint = new URL('https://console.zerocopy.sh/api/v1/customer-keys/')
endpoint.pathname += encodeURIComponent(keyId)
const headers: Record<string, string> = {
  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,
}
if (process.env.KEY_ETAG) headers['If-Match'] = process.env.KEY_ETAG
const response = await fetch(endpoint, { method: 'DELETE', headers })
const requestId = response.headers.get('Request-Id')
const body = await response.text()
if (!response.ok) {
  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)
}
console.error('Request-Id:', requestId)
const etag = response.headers.get('ETag')
if (etag) console.error('ETag:', etag)
console.log(body)
```
