ZeroCopyZeroCopy
ReferenceManagement API

Create an API key

POST
/keys

Requires the keys:write scope. Creates an own API key and returns its secret once. Use Create a customer key for customer keys. Only send is available as a product. Product entries must be distinct. The name is trimmed and must contain 1 to 64 characters. Read product rules do not restrict SWQoS.

Authorization

managementKey
headerAuthorizationBearer <zc_mgmt_>

Header Parameters

Idempotency-Key?string

Makes a retry return the first response instead of creating another key

Length1 <= length <= 255

Request Body

application/json
  1. body
name*string
Length1 <= length <= 64
products?array<>
Items1 <= items <= 7
Default
[
  "send"
]
expires_in_days?||||

Days from now until the key stops working; 0 never

Default0
rules?

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

Response Body

The key and its secret, shown once

application/json
  1. response
key*
secret*string

The key's secret, returned once and never again

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

use serde::Serialize;

#[derive(Serialize)]
struct KeyCreate {
    name: String,
    products: [&'static str; 1],
    expires_in_days: u16,
}

#[tokio::main]
async fn main() -> Result<()> {
    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 = KeyCreate { name, products: ["send"], expires_in_days: 30 };
    let endpoint = reqwest::Url::parse("https://console.zerocopy.sh/api/v1/keys")?;
    let request = reqwest::Client::new()
        .post(endpoint)
        .bearer_auth(required("MANAGEMENT_API_KEY")?);
    // Reuse this key and the same body when retrying this creation attempt.
    let request = request.header("Idempotency-Key", required("KEY_REQUEST_ID")?);
    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
{
  "key": {
    "id": "key_012345abcdef",
    "name": "production",
    "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
    }
  },
  "secret": "zc_live_ExampleOnly0123456789abc"
}