Update a customer key
Requires the partner:write scope. Updates a customer key's name or customer reference and returns its current fields. Omitted fields keep their values. Set customer_ref to null to clear it. A name is trimmed to 1 to 64 characters; a non-null customer reference is trimmed to 1 to 100 characters. Only these two fields are accepted; products, rules, expiry and send settings cannot be changed. An empty patch returns 400 invalid_request.
managementKeyAuthorizationBearer <zc_mgmt_>id*string^key_[0-9a-f]{12}$If-Match?stringChange only the key version last read; a stale validator returns 412
application/json- body
Change name or customer reference; omitted fields keep their values
name?string1 <= length <= 64customer_ref?|Trimmed customer reference; null leaves the key unassigned
1 <= length <= 100The key as changed
application/json- response
id*stringname*string|nullproducts*array<>created_at*|nullexpires_at*|nullpaused_at*|When the key was paused, or null. Use the customer-key pause and resume endpoints to change it
revoked*booleanrevoked_at*|nullrules*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
customer_ref*|Customer reference, or null for an unassigned key
1 <= length <= 100Change name or customer reference; omitted fields keep their values
// src/bin/management_update_customer_key.rs
// Builds on the example project (/reference/json-rpc#example-project).
use swqos_examples::swqos::{Result, required};
use serde::Serialize;
#[derive(Serialize)]
struct CustomerKeyPatch {
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 = CustomerKeyPatch { name };
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()
.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(())
}{
"id": "key_012345abcdef",
"name": "Acme production",
"products": [
"send"
],
"created_at": "2026-11-12T09:00:00Z",
"expires_at": null,
"paused_at": null,
"revoked": false,
"revoked_at": null,
"rules": {
"endpoints": {
"mode": "all"
},
"ips": [],
"origins": [],
"methods": {
"mode": "all",
"list": []
}
},
"send": {
"rate_per_second": 15,
"min_tip_lamports": 1000000
},
"customer_ref": "acme-prod"
}