ZeroCopyZeroCopy
ReferenceManagement API

Update an API key

PATCH
/keys/{id}

Requires the keys:write scope. Updates an own API key and returns its current fields; omitted fields retain their values. Within rules.methods, mode and list can be changed independently. An endpoints replacement must contain a complete all or only shape. Only send is available as a product; product entries must be distinct.

Authorization

managementKey
headerAuthorizationBearer <zc_mgmt_>

Path Parameters

id*string
Match^key_[0-9a-f]{12}$

Header Parameters

If-Match?string

Change only the key version last read; a stale validator returns 412

Request Body

application/json
  1. body

The fields to change; omitted fields keep their value

name?string
Length1 <= length <= 64
products?array<>
Items1 <= items <= 7
expires_in_days?||||

Days from now until the key stops working; 0 never

rules?

Response Body

The key as changed

application/json
  1. response
id*string
name*string|null
products*array<>
created_at*|null
expires_at*|null
paused_at*|

When the key was paused, or null if it is not paused

revoked*boolean
revoked_at*|null
rules*

Rules for a key's read products; a request must also pass the endpoint's own

send*|

The key's sending settings; null without the send product

The fields to change; omitted fields keep their value

Example request
// src/bin/management_update_key.rs
// Builds on the example project (/reference/json-rpc#example-project).
use swqos_examples::swqos::{Result, required};

use serde::Serialize;

#[derive(Serialize)]
struct KeyPatch {
    name: String,
}

#[tokio::main]
async fn main() -> Result<()> {
    let key_id: String = required("KEY_ID")?;
    let name = required("KEY_NAME")?.trim().to_owned();
    if !(1..=64).contains(&name.chars().count()) {
        return Err("KEY_NAME must have 1 to 64 characters after trimming".into());
    }
    let payload = KeyPatch { name };
    let mut endpoint = reqwest::Url::parse("https://console.zerocopy.sh/api/v1/keys/")?;
    endpoint.path_segments_mut().map_err(|_| "invalid base URL")?
        .pop_if_empty().push(&key_id);
    let request = reqwest::Client::new()
        .patch(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 request = request.json(&payload);
    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(())
}
Example response
{
  "id": "key_012345abcdef",
  "name": "production-renamed",
  "products": [
    "send"
  ],
  "created_at": "2026-11-12T09:00:00Z",
  "expires_at": "2026-12-12T09:00:00Z",
  "paused_at": null,
  "revoked": false,
  "revoked_at": null,
  "rules": {
    "endpoints": {
      "mode": "all"
    },
    "ips": [
      "203.0.113.10/32"
    ],
    "origins": [
      "https://dashboard.example"
    ],
    "methods": {
      "mode": "allow",
      "list": [
        "getBalance"
      ]
    }
  },
  "send": {
    "rate_per_second": 50,
    "min_tip_lamports": 1000000
  }
}