ZeroCopyZeroCopy
Account

Management API

Create customer keys, manage partner domains and retry Management API writes safely

Use the Management API to manage your team's own and customer API keys, read usage and configure partner domains without a console session. Create a management key, then send it in Authorization: Bearer YOUR_MANAGEMENT_KEY to the console's origin. An SWQoS API key cannot authenticate these requests.

The Management API reference lists exact endpoints, request fields, response fields and errors. The console also publishes its schema at /api/v1/openapi.json.

Scopes

ScopeAccess
partner:readRead partner settings, tip accounts, domains, customer keys and customer usage
partner:writeManage domains and create, update, revoke, pause or resume customer keys
keys:readRead your team's own API keys
keys:writeCreate, update and revoke your team's own API keys
usage:readRead key statistics, transactions and metrics

Grant the scopes each integration needs. partner:write does not grant partner:read. Existing management keys keep their assigned scopes; create a new key if an integration needs additional access. In the console, all team roles can read partner details; admins and developers can manage domains.

Partner operations

Partner operations require an enrolled white label team. A nonpartner receives 404. Use the partner endpoint reference for the available operations.

After enrollment, your own keys keep using company tip accounts. Choose a prefix in White label > Tip accounts for exactly eight vanity accounts, then wait for approval. You can configure domains while waiting. Customer keys can only be created after all eight accounts are live, when your team's own and customer keys switch to the vanity set.

GET /api/v1/partner reports tip_account_count for all assigned accounts and live_tip_account_count for live accounts. GET /api/v1/partner/tip-accounts returns each account's address and status; pending accounts cannot accept tips.

Before sending transactions, call getTipAccounts with the key that will send them. Use the returned accounts.

Customer keys

After the vanity accounts are live, create a customer key with partner:write. Set KEY_REQUEST_ID to an idempotency key for this creation attempt and reuse it with the same body when retrying.

src/bin/create_customer_key.rs
use serde_json::{Value, json};
use swqos_examples::swqos::{Result, required};

#[tokio::main]
async fn main() -> Result<()> {
    let response = reqwest::Client::new()
        .post("https://console.zerocopy.sh/api/v1/customer-keys")
        .bearer_auth(required("MANAGEMENT_API_KEY")?)
        .header("Idempotency-Key", required("KEY_REQUEST_ID")?)
        .json(&json!({ "name": "Acme primary", "customer_ref": "acme-123" }))
        .send()
        .await?;
    let status = response.status();
    let body = response.text().await?;
    let reply: Value = serde_json::from_str(&body)
        .map_err(|error| format!("HTTP {status}: {error}; body: {body}"))?;
    if !status.is_success() {
        return Err(format!("HTTP {status}: {reply}").into());
    }
    println!("{}", serde_json::to_string_pretty(&reply)?);
    Ok(())
}

The response has HTTP status 201 and contains { "key": ..., "secret": ... }. Store the secret from this response; later reads return only the key's fields. Names are trimmed to 1 to 64 characters. An optional customer_ref is trimmed to 1 to 100 characters, or can be null for an unassigned key. Creation and updates accept only name and customer_ref. Products, rules, expiry and send settings cannot be set through these endpoints.

List customer keys with customer_ref=acme-123 to select an exact customer reference. Lists accept limit from 1 to 100, defaulting to 50. Pass the returned next_cursor as cursor for the next page; null ends the collection. Own keys stay on the separate /keys endpoints.

To rename a key or change its customer reference, PATCH /api/v1/customer-keys/{id} with the fields to change. Set customer_ref to null to clear it. Read the key's ETag from creation or a GET response, then send it as If-Match to reject a stale update with 412 precondition_failed. The same header works for revocation, pause and resume.

Pause and resume use bodyless POST requests to /api/v1/customer-keys/{id}/pause and /resume. A paused key keeps its secret and rejects sending requests with key_paused. Use a fresh Idempotency-Key for each state change and reuse it for retries. Repeating a pause on a paused key, or a resume on an active key, returns 400 invalid_request without an idempotent replay.

Revoke a key with DELETE /api/v1/customer-keys/{id} to stop it permanently. The response contains the revoked key. Repeating the request returns its current state; a revoked key cannot be resumed.

With partner:read, read per-key statistics or usage grouped by customer. Both accept range=24h, 7d or 30d, defaulting to 24h. For example:

src/bin/customer_usage.rs
use serde_json::Value;
use swqos_examples::swqos::{Result, required};

#[tokio::main]
async fn main() -> Result<()> {
    let response = reqwest::Client::new()
        .get("https://console.zerocopy.sh/api/v1/customer-keys/usage?range=7d&customer_ref=acme-123")
        .bearer_auth(required("MANAGEMENT_API_KEY")?)
        .send()
        .await?;
    let status = response.status();
    let body = response.text().await?;
    let reply: Value = serde_json::from_str(&body)
        .map_err(|error| format!("HTTP {status}: {error}; body: {body}"))?;
    if !status.is_success() {
        return Err(format!("HTTP {status}: {reply}").into());
    }
    println!("{}", serde_json::to_string_pretty(&reply)?);
    Ok(())
}

Usage returns { "window": "7d", "data": [...] }. Omit customer_ref to include all customer groups; keys without a reference share a null group. live_keys counts currently active keys. Landed rate is a percentage and tips are integer lamports. last_seen_at can precede the selected window.

Add a domain

Create a domain using the domain creation endpoint with this JSON body:

Domain request
{
  "hostname": "send.partner.example",
  "target": "sol"
}

Choose a domain you control and use sol for the nearest metro or a supported named metro. See the request constraints for exact domain rules and target values.

Set MANAGEMENT_API_KEY to your management key and DOMAIN_REQUEST_ID to an idempotency key for this creation attempt. Reuse that request ID when retrying. Rust and Go use the example project; TypeScript uses fetch.

src/bin/create_partner_domain.rs
use serde_json::{Value, json};
use swqos_examples::swqos::{Result, required};

#[tokio::main]
async fn main() -> Result<()> {
    let response = reqwest::Client::new()
        .post("https://console.zerocopy.sh/api/v1/domains")
        .bearer_auth(required("MANAGEMENT_API_KEY")?)
        .header("Idempotency-Key", required("DOMAIN_REQUEST_ID")?)
        .json(&json!({ "hostname": "send.partner.example", "target": "sol" }))
        .send()
        .await?;
    let status = response.status();
    let body = response.text().await?;
    let reply: Value = serde_json::from_str(&body)
        .map_err(|error| format!("HTTP {status}: {error}; body: {body}"))?;
    if !status.is_success() {
        return Err(format!("HTTP {status}: {reply}").into());
    }
    println!("{}", serde_json::to_string_pretty(&reply)?);
    Ok(())
}

The domain starts in pending. Read its status until the DNS challenge is available, then publish the two CNAME records. Keep both records in place for renewal.

src/bin/read_domain_setup.rs
use serde_json::Value;
use swqos_examples::swqos::{Result, required};

#[tokio::main]
async fn main() -> Result<()> {
    let response = reqwest::Client::new()
        .get("https://console.zerocopy.sh/api/v1/domains/send.partner.example")
        .bearer_auth(required("MANAGEMENT_API_KEY")?)
        .send()
        .await?;
    let status = response.status();
    let body = response.text().await?;
    let reply: Value = serde_json::from_str(&body)
        .map_err(|error| format!("HTTP {status}: {error}; body: {body}"))?;
    if !status.is_success() {
        return Err(format!("HTTP {status}: {reply}").into());
    }
    println!("{}", serde_json::to_string_pretty(&reply)?);
    Ok(())
}

Check last_error when setup or renewal fails and not_after for certificate expiry. Update clients before removing a domain. Adding it again starts a new setup and assigns a new challenge CNAME.

Idempotent writes

Send Idempotency-Key with customer-key creation, pause, resume and domain creation requests, then reuse it if you retry after a timeout. Use 1 to 255 printable ASCII characters. For 24 hours, the same management key, idempotency key and request return the saved successful response with Idempotent-Replayed: true. Refusals are not saved. A concurrent request or a different request with the same key returns 409.

If the API returns 409 idempotency_unavailable, read the domain before making a new request. A saved response can be unavailable even though the original creation succeeded.

For a customer-key request, list the keys or read the target key before starting another operation. If creation succeeded and you cannot recover its secret, revoke that key before creating a replacement.

Handling failures

Keep the response's Request-Id when reporting a failed request on Discord. Use the stable error code rather than matching message text. See the response and error reference for the exact JSON shapes and status codes.