{"openapi":"3.2.0","info":{"title":"Management API","version":"1","description":"Manage your team's own and customer API keys, inspect usage and configure white label domains through the console's management API."},"servers":[{"url":"https://console.zerocopy.sh/api/v1"}],"tags":[{"name":"Account"},{"name":"API keys"},{"name":"Usage"},{"name":"Metrics"},{"name":"White label"}],"security":[{"managementKey":[]}],"components":{"securitySchemes":{"managementKey":{"type":"http","scheme":"bearer","bearerFormat":"zc_mgmt_"}},"schemas":{"KeyCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":64},"products":{"default":["send"],"minItems":1,"maxItems":7,"type":"array","items":{"type":"string","enum":["send","jsonrpc","ws","grpc","deshred","das","history"]}},"expires_in_days":{"default":0,"anyOf":[{"type":"number","const":0},{"type":"number","const":7},{"type":"number","const":30},{"type":"number","const":90},{"type":"number","const":365}],"description":"Days from now until the key stops working; 0 never"},"rules":{"$ref":"#/components/schemas/KeyRulesInput"}},"required":["name"],"additionalProperties":false},"KeyPatch":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":64},"products":{"minItems":1,"maxItems":7,"type":"array","items":{"type":"string","enum":["send","jsonrpc","ws","grpc","deshred","das","history"]}},"expires_in_days":{"anyOf":[{"type":"number","const":0},{"type":"number","const":7},{"type":"number","const":30},{"type":"number","const":90},{"type":"number","const":365}],"description":"Days from now until the key stops working; 0 never"},"rules":{"type":"object","properties":{"endpoints":{"oneOf":[{"type":"object","properties":{"mode":{"type":"string","const":"all"}},"required":["mode"]},{"type":"object","properties":{"mode":{"type":"string","const":"only"},"ids":{"maxItems":256,"type":"array","items":{"type":"string"}}},"required":["mode","ids"]}]},"ips":{"maxItems":256,"type":"array","items":{"type":"string"}},"origins":{"maxItems":256,"type":"array","items":{"type":"string"}},"methods":{"type":"object","properties":{"mode":{"type":"string","enum":["all","allow","deny"]},"list":{"maxItems":256,"type":"array","items":{"type":"string"}}}}},"additionalProperties":false}},"additionalProperties":false,"description":"The fields to change; omitted fields keep their value"},"KeyRulesInput":{"type":"object","properties":{"endpoints":{"default":{"mode":"all"},"description":"Endpoints the key reads through: every one, or only those listed","oneOf":[{"type":"object","properties":{"mode":{"type":"string","const":"all"}},"required":["mode"]},{"type":"object","properties":{"mode":{"type":"string","const":"only"},"ids":{"maxItems":256,"type":"array","items":{"type":"string"}}},"required":["mode","ids"]}]},"ips":{"default":[],"description":"IPv4 addresses or CIDR ranges requests may come from; empty allows any","maxItems":256,"type":"array","items":{"type":"string"}},"origins":{"default":[],"description":"Web origins requests may carry; empty allows any","maxItems":256,"type":"array","items":{"type":"string"}},"methods":{"default":{"mode":"all","list":[]},"description":"JSON-RPC methods allowed or refused","type":"object","properties":{"mode":{"type":"string","enum":["all","allow","deny"]},"list":{"default":[],"maxItems":256,"type":"array","items":{"type":"string"}}},"required":["mode"]}},"description":"Rules for a key's read products; a request must also pass the endpoint's own"},"DomainCreate":{"type":"object","properties":{"hostname":{"type":"string","maxLength":253,"pattern":"^(?!.*\\.zerocopy\\.sh$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.){2,}[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$"},"target":{"type":"string","enum":["sol","fra","ams","lon","nyc","lax","tyo"]}},"required":["hostname","target"],"additionalProperties":false},"ApiKey":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"products":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"created_at":{"anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}]},"expires_at":{"anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}]},"paused_at":{"anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}],"description":"When the key was paused, or null if it is not paused","readOnly":true},"revoked":{"type":"boolean"},"revoked_at":{"anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}]},"rules":{"$ref":"#/components/schemas/KeyRules"},"send":{"anyOf":[{"type":"object","properties":{"rate_per_second":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"min_tip_lamports":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["rate_per_second","min_tip_lamports"],"additionalProperties":false},{"type":"null"}],"description":"The key's sending settings; null without the `send` product"}},"required":["id","name","products","created_at","expires_at","paused_at","revoked","revoked_at","rules","send"],"additionalProperties":false},"KeyCreated":{"type":"object","properties":{"key":{"$ref":"#/components/schemas/ApiKey"},"secret":{"type":"string","description":"The key's secret, returned once and never again"}},"required":["key","secret"],"additionalProperties":false},"KeyPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ApiKey"}},"next_cursor":{"type":["string","null"]}},"required":["data","next_cursor"],"additionalProperties":false},"KeyRules":{"type":"object","properties":{"endpoints":{"default":{"mode":"all"},"description":"Endpoints the key reads through: every one, or only those listed","oneOf":[{"type":"object","properties":{"mode":{"type":"string","const":"all"}},"required":["mode"],"additionalProperties":false},{"type":"object","properties":{"mode":{"type":"string","const":"only"},"ids":{"maxItems":256,"type":"array","items":{"type":"string"}}},"required":["mode","ids"],"additionalProperties":false}]},"ips":{"default":[],"description":"IPv4 addresses or CIDR ranges requests may come from; empty allows any","maxItems":256,"type":"array","items":{"type":"string"}},"origins":{"default":[],"description":"Web origins requests may carry; empty allows any","maxItems":256,"type":"array","items":{"type":"string"}},"methods":{"default":{"mode":"all","list":[]},"description":"JSON-RPC methods allowed or refused","type":"object","properties":{"mode":{"type":"string","enum":["all","allow","deny"]},"list":{"default":[],"maxItems":256,"type":"array","items":{"type":"string"}}},"required":["mode","list"],"additionalProperties":false}},"required":["endpoints","ips","origins","methods"],"additionalProperties":false,"description":"Rules for a key's read products; a request must also pass the endpoint's own"},"KeyStats":{"type":"object","properties":{"key_id":{"type":"string"},"window":{"type":"string","const":"24h"},"transactions":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"landed_rate":{"type":["number","null"]},"p50_slots_to_land":{"type":["number","null"]},"tips_lamports":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"last_seen_at":{"anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}]}},"required":["key_id","window","transactions","landed_rate","p50_slots_to_land","tips_lamports","last_seen_at"],"additionalProperties":false},"CustomerKeyCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":64},"customer_ref":{"type":["string","null"],"minLength":1,"maxLength":100,"description":"Trimmed customer reference; null leaves the key unassigned"}},"required":["name"],"additionalProperties":false},"CustomerKeyPatch":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":64},"customer_ref":{"type":["string","null"],"minLength":1,"maxLength":100,"description":"Trimmed customer reference; null leaves the key unassigned"}},"additionalProperties":false,"description":"Change name or customer reference; omitted fields keep their values"},"CustomerKey":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"products":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"created_at":{"anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}]},"expires_at":{"anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}]},"paused_at":{"anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}],"description":"When the key was paused, or null. Use the customer-key pause and resume endpoints to change it","readOnly":true},"revoked":{"type":"boolean"},"revoked_at":{"anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}]},"rules":{"$ref":"#/components/schemas/KeyRules"},"send":{"anyOf":[{"type":"object","properties":{"rate_per_second":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"min_tip_lamports":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["rate_per_second","min_tip_lamports"],"additionalProperties":false},{"type":"null"}],"description":"The key's sending settings; null without the `send` product"},"customer_ref":{"type":["string","null"],"minLength":1,"maxLength":100,"description":"Customer reference, or null for an unassigned key"}},"required":["id","name","products","created_at","expires_at","paused_at","revoked","revoked_at","rules","send","customer_ref"],"additionalProperties":false},"CustomerKeyCreated":{"type":"object","properties":{"key":{"$ref":"#/components/schemas/CustomerKey"},"secret":{"type":"string","description":"The key's secret, returned once and never again"}},"required":["key","secret"],"additionalProperties":false},"CustomerKeyPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CustomerKey"}},"next_cursor":{"type":["string","null"]}},"required":["data","next_cursor"],"additionalProperties":false},"CustomerKeyStats":{"type":"object","properties":{"key_id":{"type":"string"},"window":{"type":"string","enum":["24h","7d","30d"]},"transactions":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"landed_rate":{"type":["number","null"]},"p50_slots_to_land":{"type":["number","null"]},"tips_lamports":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"last_seen_at":{"anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}]}},"required":["key_id","window","transactions","landed_rate","p50_slots_to_land","tips_lamports","last_seen_at"],"additionalProperties":false},"CustomerUsagePage":{"type":"object","properties":{"window":{"type":"string","enum":["24h","7d","30d"]},"data":{"type":"array","items":{"type":"object","properties":{"customer_ref":{"type":["string","null"],"minLength":1,"maxLength":100,"description":"Exact customer reference; null groups unassigned keys"},"live_keys":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"Keys that are currently unrevoked, unpaused and unexpired"},"transactions":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"landed_rate":{"type":["number","null"]},"p50_slots_to_land":{"type":["number","null"]},"tips_lamports":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"last_seen_at":{"anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}]}},"required":["customer_ref","live_keys","transactions","landed_rate","p50_slots_to_land","tips_lamports","last_seen_at"],"additionalProperties":false}}},"required":["window","data"],"additionalProperties":false},"Me":{"type":"object","properties":{"key":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"scopes":{"type":"array","items":{"$ref":"#/components/schemas/Scope"}},"expires_at":{"type":"string","format":"date-time","description":"RFC 3339 time"}},"required":["id","name","scopes","expires_at"],"additionalProperties":false},"team":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"required":["id","name"],"additionalProperties":false}},"required":["key","team"],"additionalProperties":false},"Partner":{"type":"object","properties":{"products":{"type":"array","items":{"type":"string"}},"share_bps":{"type":"integer","minimum":0,"maximum":10000,"description":"Agreed share of net revenue. Divide this integer by 100 to obtain the percentage."},"tip_account_count":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"Total assigned vanity tip accounts, including pending accounts."},"live_tip_account_count":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"Live vanity tip accounts. Customer-key creation requires live accounts."},"domain_counts":{"type":"object","properties":{"pending":{"type":"integer","minimum":0,"maximum":9007199254740991},"awaiting_dns":{"type":"integer","minimum":0,"maximum":9007199254740991},"active":{"type":"integer","minimum":0,"maximum":9007199254740991},"failed":{"type":"integer","minimum":0,"maximum":9007199254740991}},"required":["pending","awaiting_dns","active","failed"],"additionalProperties":false}},"required":["products","share_bps","tip_account_count","live_tip_account_count","domain_counts"],"additionalProperties":false},"PartnerDomain":{"type":"object","properties":{"hostname":{"type":"string","maxLength":253,"pattern":"^(?!.*\\.zerocopy\\.sh$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.){2,}[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$"},"target":{"type":"string","enum":["sol","fra","ams","lon","nyc","lax","tyo"]},"products":{"type":"array","items":{"type":"string"}},"status":{"type":"string","enum":["pending","awaiting_dns","active","failed"]},"acme_dns_fulldomain":{"description":"Assigned challenge target, or null while preparing","type":["string","null"]},"not_after":{"description":"Certificate expiry timestamp, or null before issuance","anyOf":[{"type":"string","format":"date-time","description":"RFC 3339 time"},{"type":"null"}]},"last_error":{"description":"Setup or renewal error, or null","type":["string","null"]},"created_at":{"type":"string","format":"date-time","description":"RFC 3339 time"},"updated_at":{"type":"string","format":"date-time","description":"RFC 3339 time"},"dns_records":{"type":"array","prefixItems":[{"type":"object","properties":{"type":{"type":"string","const":"CNAME"},"name":{"type":"string"},"value":{"type":["string","null"]}},"required":["type","name","value"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"CNAME"},"name":{"type":"string"},"value":{"type":["string","null"]}},"required":["type","name","value"],"additionalProperties":false}],"items":false,"minItems":2,"maxItems":2}},"required":["hostname","target","products","status","acme_dns_fulldomain","not_after","last_error","created_at","updated_at","dns_records"],"additionalProperties":false,"description":"Both dns_records have type CNAME. The sending record points to `sol.zerocopy.sh` or `<metro>.sol.zerocopy.sh`. The challenge record value is null while preparing, then contains the assigned name under `acme.zerocopy.sh`. See [White label domains](/account/white-label#domains) for setup."},"PartnerDomainList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PartnerDomain"}}},"required":["data"],"additionalProperties":false},"PartnerTipAccounts":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"address":{"type":"string","description":"A base58 tip-account address"},"status":{"type":"string","enum":["live","pending"],"description":"Use only live tip accounts"}},"required":["address","status"],"additionalProperties":false}}},"required":["data"],"additionalProperties":false},"Problem":{"type":"object","properties":{"title":{"type":"string"},"status":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"code":{"type":"string","description":"Stable, for programs to branch on"},"detail":{"type":"string"},"request_id":{"type":"string"},"errors":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"message":{"type":"string"}},"required":["path","message"],"additionalProperties":false}}},"required":["title","status","code","detail","request_id"],"additionalProperties":false},"Product":{"type":"string","enum":["send","jsonrpc","ws","grpc","deshred","das","history"],"description":"A product an API key may use. Only `send` is available today."},"Scope":{"type":"string","enum":["keys:read","keys:write","endpoints:read","endpoints:write","usage:read","alerts:read","alerts:write","billing:read","billing:write","team:read","team:write","partner:read","partner:write"]},"Transaction":{"type":"object","properties":{"signature":{"type":"string"},"received_at":{"type":"string","format":"date-time","description":"RFC 3339 time"},"key_id":{"type":"string"},"metro":{"type":"string"},"kind":{"type":"string","enum":["tx","bundle_tx"]},"bundle_id":{"type":["string","null"]},"paths":{"type":"array","items":{"type":"string","enum":["quic","jito","harmonic","dbi","everstake","gbx"]}},"outcome":{"type":"string","enum":["landed","failed","expired"]},"error":{"type":["string","null"]},"sent_slot":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"landed_slot":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"slots_to_land":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"tip_lamports":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991,"description":"Lamports transferred to tip accounts"},"token_tips":{"type":"array","items":{"type":"object","properties":{"mint":{"type":"string","description":"Base58 mint address"},"symbol":{"type":"string","enum":["USDC","USDT","WSOL"]},"amount":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991,"description":"Base units of the token"}},"required":["mint","symbol","amount"],"additionalProperties":false},"description":"Token transfers to tip accounts' token accounts; empty when none"},"token_tip_lamports":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991,"description":"SOL value of the token tips when sent, in lamports"},"priority_fee_lamports":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["signature","received_at","key_id","metro","kind","bundle_id","paths","outcome","error","sent_slot","landed_slot","slots_to_land","tip_lamports","token_tips","token_tip_lamports","priority_fee_lamports"],"additionalProperties":false},"TransactionPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Transaction"}},"next_cursor":{"type":["string","null"]}},"required":["data","next_cursor"],"additionalProperties":false},"MetricsText":{"type":"string","description":"Prometheus text exposition 0.0.4; every metric is a gauge with an explicit minute-end millisecond timestamp"},"MetricsSeries":{"type":"object","properties":{"metric":{"type":"string","enum":["transactions","landed_rate","failed_rate","expired_rate","slots_to_land","edge_time","tips","priority_fees"]},"unit":{"type":"string","enum":["transactions","percent","slots","microseconds","lamports"]},"quantile":{"anyOf":[{"type":"number","const":0.5},{"type":"number","const":0.9},{"type":"number","const":0.99}]},"step_seconds":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991},"from":{"type":"string","format":"date-time","description":"RFC 3339 time"},"to":{"type":"string","format":"date-time","description":"RFC 3339 time"},"series":{"type":"array","items":{"type":"object","properties":{"labels":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"points":{"type":"array","items":{"type":"array","prefixItems":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":["number","null"]}],"items":false,"minItems":2,"maxItems":2}}},"required":["labels","points"],"additionalProperties":false}}},"required":["metric","unit","step_seconds","from","to","series"],"additionalProperties":false}},"examples":{"CurrentManagementKey":{"summary":"Current management key","value":{"key":{"id":"mk_0123456789abcdef01234567","name":"Grafana metrics","scopes":["usage:read"],"expires_at":"2027-02-11T09:00:00Z"},"team":{"id":"org_012345abcdef","name":"Example team"}}},"ApiKeyList":{"summary":"Own API keys","value":{"data":[{"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}},{"id":"key_89abcdef0123","name":"research","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}}],"next_cursor":null}},"CreatedApiKey":{"summary":"Created key and its one-time secret","value":{"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"}},"RetrievedApiKey":{"summary":"Active API key","value":{"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}}},"UpdatedApiKey":{"summary":"Renamed API key","value":{"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}}},"RevokedApiKey":{"summary":"Revoked API key","value":{"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":true,"revoked_at":"2026-11-13T02:14:00Z","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}}},"KeyStatistics":{"summary":"Traffic in the last 24 hours","value":{"key_id":"key_012345abcdef","window":"24h","transactions":1248,"landed_rate":97.5,"p50_slots_to_land":2,"tips_lamports":3670000000,"last_seen_at":"2026-11-13T02:13:41Z"}},"TransactionList":{"summary":"Landed transaction","value":{"data":[{"signature":"2Zjg5PESjNfkUvSjHAS71SnAcUTs9VEqYK87QzNhyDuAgqK1fBfXfxENuV4JwPFizwFn5tWwLcWFDgGz9q66DwdD","received_at":"2026-11-13T02:13:34.123Z","key_id":"key_012345abcdef","metro":"fra","kind":"tx","bundle_id":null,"paths":["quic","jito"],"outcome":"landed","error":null,"sent_slot":450000123,"landed_slot":450000125,"slots_to_land":2,"tip_lamports":2000000,"token_tips":[{"mint":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","symbol":"USDC","amount":250000}],"token_tip_lamports":1250000,"priority_fee_lamports":50000}],"next_cursor":null}},"PrometheusMetrics":{"summary":"One complete UTC minute","value":"# HELP zerocopy_key_info Key name, customer and state; value 1.\n# TYPE zerocopy_key_info gauge\nzerocopy_key_info{key_id=\"key_012345abcdef\",name=\"Primary sender\",customer=\"example-client\",state=\"active\"} 1 1794536040000\nzerocopy_key_info{key_id=\"key_89abcdef0123\",name=\"Research sender\",customer=\"example-research\",state=\"active\"} 1 1794536040000\n# HELP zerocopy_swqos_transactions Transactions by outcome in the minute. Data is 3 minutes behind.\n# TYPE zerocopy_swqos_transactions gauge\nzerocopy_swqos_transactions{key_id=\"key_012345abcdef\",metro=\"fra\",outcome=\"landed\"} 3 1794536040000\nzerocopy_swqos_transactions{key_id=\"key_89abcdef0123\",metro=\"fra\",outcome=\"expired\"} 1 1794536040000\nzerocopy_swqos_transactions{key_id=\"key_89abcdef0123\",metro=\"lon\",outcome=\"failed\"} 1 1794536040000\n# HELP zerocopy_swqos_slots_to_land Slots from send to successful landing, landed transactions only. Data is 3 minutes behind.\n# TYPE zerocopy_swqos_slots_to_land gauge\nzerocopy_swqos_slots_to_land{key_id=\"key_012345abcdef\",metro=\"fra\",quantile=\"0.5\"} 2 1794536040000\nzerocopy_swqos_slots_to_land{key_id=\"key_012345abcdef\",metro=\"fra\",quantile=\"0.9\"} 2 1794536040000\nzerocopy_swqos_slots_to_land{key_id=\"key_012345abcdef\",metro=\"fra\",quantile=\"0.99\"} 2 1794536040000\n"},"MetricHistory":{"summary":"Three-minute custom window by outcome","value":{"metric":"transactions","unit":"transactions","step_seconds":60,"from":"2026-11-13T02:11:00.000Z","to":"2026-11-13T02:14:00.000Z","series":[{"labels":{"outcome":"landed"},"points":[[1794535860000,17],[1794535920000,21],[1794535980000,19]]},{"labels":{"outcome":"failed"},"points":[[1794535860000,1],[1794535920000,2],[1794535980000,1]]},{"labels":{"outcome":"expired"},"points":[[1794535860000,2],[1794535920000,1],[1794535980000,1]]}]}},"PartnerSettings":{"summary":"Enrolled partner settings","value":{"products":["send"],"share_bps":2500,"tip_account_count":8,"live_tip_account_count":8,"domain_counts":{"pending":1,"awaiting_dns":1,"active":1,"failed":1}}},"TipAccountList":{"summary":"Example live vanity set","value":{"data":[{"address":"ZC11111111111111111111111111111111111111111","status":"live"},{"address":"ZC11111111111111111111111111111111111111112","status":"live"},{"address":"ZC11111111111111111111111111111111111111113","status":"live"},{"address":"ZC11111111111111111111111111111111111111114","status":"live"},{"address":"ZC11111111111111111111111111111111111111115","status":"live"},{"address":"ZC11111111111111111111111111111111111111116","status":"live"},{"address":"ZC11111111111111111111111111111111111111117","status":"live"},{"address":"ZC11111111111111111111111111111111111111118","status":"live"}]}},"DomainList":{"summary":"Domains at different setup stages","value":{"data":[{"hostname":"send.partner.example","target":"sol","products":["send"],"status":"active","acme_dns_fulldomain":"partner-example.acme.zerocopy.sh","not_after":"2027-02-10T09:00:00Z","last_error":null,"created_at":"2026-11-12T09:00:00Z","updated_at":"2026-11-12T09:05:00Z","dns_records":[{"type":"CNAME","name":"send.partner.example","value":"sol.zerocopy.sh"},{"type":"CNAME","name":"_acme-challenge.send.partner.example","value":"partner-example.acme.zerocopy.sh"}]},{"hostname":"backup.partner.example","target":"sol","products":["send"],"status":"pending","acme_dns_fulldomain":null,"not_after":null,"last_error":null,"created_at":"2026-11-12T09:00:00Z","updated_at":"2026-11-12T09:00:00Z","dns_records":[{"type":"CNAME","name":"backup.partner.example","value":"sol.zerocopy.sh"},{"type":"CNAME","name":"_acme-challenge.backup.partner.example","value":null}]},{"hostname":"europe.partner.example","target":"sol","products":["send"],"status":"awaiting_dns","acme_dns_fulldomain":"europe-example.acme.zerocopy.sh","not_after":null,"last_error":null,"created_at":"2026-11-12T09:00:00Z","updated_at":"2026-11-12T09:05:00Z","dns_records":[{"type":"CNAME","name":"europe.partner.example","value":"sol.zerocopy.sh"},{"type":"CNAME","name":"_acme-challenge.europe.partner.example","value":"europe-example.acme.zerocopy.sh"}]},{"hostname":"archive.partner.example","target":"sol","products":["send"],"status":"failed","acme_dns_fulldomain":"archive-example.acme.zerocopy.sh","not_after":null,"last_error":"DNS record does not match the assigned challenge target.","created_at":"2026-11-12T09:00:00Z","updated_at":"2026-11-12T09:05:00Z","dns_records":[{"type":"CNAME","name":"archive.partner.example","value":"sol.zerocopy.sh"},{"type":"CNAME","name":"_acme-challenge.archive.partner.example","value":"archive-example.acme.zerocopy.sh"}]}]}},"PendingDomain":{"summary":"New domain while preparing DNS setup","value":{"hostname":"send.partner.example","target":"sol","products":["send"],"status":"pending","acme_dns_fulldomain":null,"not_after":null,"last_error":null,"created_at":"2026-11-12T09:00:00Z","updated_at":"2026-11-12T09:00:00Z","dns_records":[{"type":"CNAME","name":"send.partner.example","value":"sol.zerocopy.sh"},{"type":"CNAME","name":"_acme-challenge.send.partner.example","value":null}]}},"ActiveDomain":{"summary":"Active domain and DNS records","value":{"hostname":"send.partner.example","target":"sol","products":["send"],"status":"active","acme_dns_fulldomain":"partner-example.acme.zerocopy.sh","not_after":"2027-02-10T09:00:00Z","last_error":null,"created_at":"2026-11-12T09:00:00Z","updated_at":"2026-11-12T09:05:00Z","dns_records":[{"type":"CNAME","name":"send.partner.example","value":"sol.zerocopy.sh"},{"type":"CNAME","name":"_acme-challenge.send.partner.example","value":"partner-example.acme.zerocopy.sh"}]}},"RemovedDomain":{"summary":"Removed domain snapshot","value":{"hostname":"send.partner.example","target":"sol","products":["send"],"status":"active","acme_dns_fulldomain":"partner-example.acme.zerocopy.sh","not_after":"2027-02-10T09:00:00Z","last_error":null,"created_at":"2026-11-12T09:00:00Z","updated_at":"2026-11-12T09:05:00Z","dns_records":[{"type":"CNAME","name":"send.partner.example","value":"sol.zerocopy.sh"},{"type":"CNAME","name":"_acme-challenge.send.partner.example","value":"partner-example.acme.zerocopy.sh"}]}},"CustomerKeyList":{"summary":"Customer keys filtered by exact customer reference","value":{"data":[{"id":"key_012345abcdef","name":"Acme primary","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-123"}],"next_cursor":null}},"CreatedCustomerKey":{"summary":"Customer key and its one-time secret","value":{"key":{"id":"key_012345abcdef","name":"Acme primary","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-123"},"secret":"zc_live_ExampleOnly0123456789abc"}},"RetrievedCustomerKey":{"summary":"Active customer key","value":{"id":"key_012345abcdef","name":"Acme primary","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-123"}},"UpdatedCustomerKey":{"summary":"Renamed customer key with a new reference","value":{"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"}},"RevokedCustomerKey":{"summary":"Permanently revoked customer key","value":{"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"}},"PausedCustomerKey":{"summary":"Paused customer key with its secret unchanged","value":{"id":"key_012345abcdef","name":"Acme primary","products":["send"],"created_at":"2026-11-12T09:00:00Z","expires_at":null,"paused_at":"2026-11-13T02:14:00Z","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-123"}},"ResumedCustomerKey":{"summary":"Resumed customer key","value":{"id":"key_012345abcdef","name":"Acme primary","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-123"}},"CustomerKeyStatistics":{"summary":"Customer-key traffic over seven days","value":{"key_id":"key_012345abcdef","window":"7d","transactions":1248,"landed_rate":97.5,"p50_slots_to_land":2,"tips_lamports":3670000000,"last_seen_at":"2026-11-13T02:13:41Z"}},"CustomerUsage":{"summary":"Per-customer usage, including unassigned keys","value":{"window":"7d","data":[{"customer_ref":"acme-123","live_keys":2,"transactions":1248,"landed_rate":97.5,"p50_slots_to_land":2,"tips_lamports":3670000000,"last_seen_at":"2026-11-13T02:13:41Z"},{"customer_ref":null,"live_keys":1,"transactions":163,"landed_rate":98.2,"p50_slots_to_land":1,"tips_lamports":414000000,"last_seen_at":"2026-11-13T01:42:19Z"}]}},"TipAccountsNotLive":{"summary":"Customer-key creation before vanity accounts are live","value":{"title":"Conflict","status":409,"code":"tip_accounts_not_live","detail":"Vanity tip accounts must be live before creating customer keys.","request_id":"8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"}},"BadRequest":{"summary":"Invalid request","value":{"title":"Bad request","status":400,"code":"invalid_request","detail":"The request does not match the schema.","request_id":"8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"}},"Unauthorized":{"summary":"Unknown, revoked or expired management key","value":{"title":"Unauthorized","status":401,"code":"unauthorized","detail":"The management key is unknown, revoked or expired.","request_id":"8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"}},"ForbiddenIp":{"summary":"IP restriction","value":{"title":"Forbidden","status":403,"code":"forbidden_ip","detail":"This key does not allow requests from this address.","request_id":"8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"}},"NotFound":{"summary":"Unknown route","value":{"title":"Not found","status":404,"code":"not_found","detail":"No such route.","request_id":"8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"}},"IdempotencyKeyReused":{"summary":"Idempotency key reused for a different request","value":{"title":"Conflict","status":409,"code":"idempotency_key_reused","detail":"This Idempotency-Key was used for a different request.","request_id":"8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"}},"HostnameTaken":{"summary":"Domain already registered by this team","value":{"title":"Conflict","status":409,"code":"hostname_taken","detail":"This hostname is already in use.","request_id":"8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"}},"PreconditionFailed":{"summary":"Stale key version","value":{"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"}},"ReadRateLimited":{"summary":"Management read limit","value":{"title":"Too many requests","status":429,"code":"rate_limited","detail":"This key may make 600 such requests a minute.","request_id":"8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"}},"WriteRateLimited":{"summary":"Management write limit","value":{"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"}},"AnalyticsBusy":{"summary":"Concurrent analytics limit","value":{"title":"Too many requests","status":429,"code":"analytics_busy","detail":"This team already has two analytics reads running.","request_id":"8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"}},"BodyTooLarge":{"summary":"Body exceeds the request limit","value":{"title":"Content too large","status":413,"code":"body_too_large","detail":"The request body exceeds 64 KiB.","request_id":"8d4ac3b9-e451-4ca4-9a7f-b3928f0b1672"}}}},"paths":{"/me":{"get":{"summary":"Retrieve the current key","tags":["Account"],"responses":{"200":{"description":"The key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"},"examples":{"CurrentManagementKey":{"$ref":"#/components/examples/CurrentManagementKey"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"}}}}}},"description":"Requires no additional scope. Returns the current management key, its team and its assigned scopes.","operationId":"Identity","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_identity.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/me\")?;\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_identity/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/me\")\n    if err != nil {\n        return err\n    }\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-identity.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/me')\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/keys":{"get":{"summary":"List API keys","tags":["API keys"],"description":"Requires the `keys:read` scope. Returns the authenticated team's own API keys, with cursor pagination. Customer keys are excluded. `limit` is 1 to 100 and defaults to 50. Supply `next_cursor` as the next request's `cursor`; null ends the collection.","parameters":[{"name":"limit","in":"query","required":false,"schema":{"default":50,"type":"integer","minimum":1,"maximum":100}},{"name":"cursor","in":"query","required":false,"schema":{"description":"`next_cursor` from the previous page","type":"string","maxLength":512}}],"responses":{"200":{"description":"A page of keys","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyPage"},"examples":{"ApiKeyList":{"$ref":"#/components/examples/ApiKeyList"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"}}}}}},"operationId":"ListApiKeys","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_list_keys.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let limit: u8 = 50;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/keys\")?;\n    endpoint.query_pairs_mut().append_pair(\"limit\", &limit.to_string());\n    if let Ok(cursor) = std::env::var(\"CURSOR\") {\n        endpoint.query_pairs_mut().append_pair(\"cursor\", &cursor);\n    }\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_list_keys/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n    \"strconv\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    const limit uint8 = 50\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/keys\")\n    if err != nil {\n        return err\n    }\n    query := endpoint.Query()\n    query.Set(\"limit\", strconv.Itoa(int(limit)))\n    if cursor := os.Getenv(\"CURSOR\"); cursor != \"\" {\n        query.Set(\"cursor\", cursor)\n    }\n    endpoint.RawQuery = query.Encode()\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-list-keys.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst limit: number = 50\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/keys')\nendpoint.searchParams.set('limit', String(limit))\nconst cursor: string | undefined = process.env.CURSOR\nif (cursor) endpoint.searchParams.set('cursor', cursor)\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]},"post":{"summary":"Create an API key","tags":["API keys"],"description":"Requires the `keys:write` scope. Creates an own API key and returns its secret once. Use [Create a customer key](/reference/management-api/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.","parameters":[{"name":"Idempotency-Key","in":"header","description":"Makes a retry return the first response instead of creating another key","schema":{"type":"string","minLength":1,"maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyCreate"},"example":{"name":"production","products":["send"],"expires_in_days":30}}}},"responses":{"201":{"description":"The key and its secret, shown once","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyCreated"},"examples":{"CreatedApiKey":{"$ref":"#/components/examples/CreatedApiKey"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"409":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"IdempotencyKeyReused":{"$ref":"#/components/examples/IdempotencyKeyReused"}}}}},"413":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BodyTooLarge":{"$ref":"#/components/examples/BodyTooLarge"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"WriteRateLimited":{"$ref":"#/components/examples/WriteRateLimited"}}}}}},"operationId":"CreateAnApiKey","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_create_key.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\nuse serde::Serialize;\n\n#[derive(Serialize)]\nstruct KeyCreate {\n    name: String,\n    products: [&'static str; 1],\n    expires_in_days: u16,\n}\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let name = required(\"KEY_NAME\")?.trim().to_owned();\n    if !(1..=64).contains(&name.chars().count()) {\n        return Err(\"KEY_NAME must have 1 to 64 characters after trimming\".into());\n    }\n    let payload = KeyCreate { name, products: [\"send\"], expires_in_days: 30 };\n    let endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/keys\")?;\n    let request = reqwest::Client::new()\n        .post(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    // Reuse this key and the same body when retrying this creation attempt.\n    let request = request.header(\"Idempotency-Key\", required(\"KEY_REQUEST_ID\")?);\n    let request = request.json(&payload);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_create_key/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n    \"bytes\"\n    \"encoding/json\"\n    \"strings\"\n    \"unicode/utf8\"\n)\n\ntype KeyCreate struct {\n    Name string `json:\"name\"`\n    Products []string `json:\"products\"`\n    ExpiresInDays uint16 `json:\"expires_in_days\"`\n}\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    // Reuse this key and the same body when retrying this creation attempt.\n    idempotencyKey, err := required(\"KEY_REQUEST_ID\")\n    if err != nil {\n        return err\n    }\n    name, err := required(\"KEY_NAME\")\n    if err != nil {\n        return err\n    }\n    name = strings.TrimSpace(name)\n    if length := utf8.RuneCountInString(name); length < 1 || length > 64 {\n        return fmt.Errorf(\"KEY_NAME must have 1 to 64 characters after trimming\")\n    }\n    payload := KeyCreate{Name: name, Products: []string{\"send\"}, ExpiresInDays: 30}\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/keys\")\n    if err != nil {\n        return err\n    }\n    encoded, err := json.Marshal(payload)\n    if err != nil {\n        return err\n    }\n    request, err := http.NewRequest(http.MethodPost, endpoint.String(), bytes.NewReader(encoded))\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    request.Header.Set(\"Idempotency-Key\", idempotencyKey)\n    request.Header.Set(\"Content-Type\", \"application/json\")\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-create-key.ts\nexport {}\n\ntype KeyCreate = { name: string; products: ['send']; expires_in_days: 30 }\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst name: string = required('KEY_NAME').trim()\nif (Array.from(name).length < 1 || Array.from(name).length > 64) {\n  throw new Error('KEY_NAME must have 1 to 64 characters after trimming')\n}\nconst payload: KeyCreate = { name, products: ['send'], expires_in_days: 30 }\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/keys')\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\n// Reuse this key and the same body when retrying this creation attempt.\nheaders['Idempotency-Key'] = required('KEY_REQUEST_ID')\nheaders['Content-Type'] = 'application/json'\nconst response = await fetch(endpoint, { method: 'POST', headers, body: JSON.stringify(payload) })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/keys/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^key_[0-9a-f]{12}$"},"example":"key_012345abcdef"}],"get":{"summary":"Retrieve an API key","tags":["API keys"],"description":"Requires the `keys:read` scope. Returns one of the authenticated team's own API keys. A customer key id returns `404 not_found`.","responses":{"200":{"description":"The key","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKey"},"examples":{"RetrievedApiKey":{"$ref":"#/components/examples/RetrievedApiKey"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"}}}}}},"operationId":"ReadAnApiKey","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_read_key.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let key_id: String = required(\"KEY_ID\")?;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/keys/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&key_id);\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_read_key/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    keyID, err := required(\"KEY_ID\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/keys/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += keyID\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-read-key.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst keyId: string = required('KEY_ID')\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/keys/')\nendpoint.pathname += encodeURIComponent(keyId)\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]},"patch":{"summary":"Update an API key","tags":["API keys"],"description":"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.","parameters":[{"name":"If-Match","in":"header","required":false,"description":"Change only the key version last read; a stale validator returns 412","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyPatch"},"example":{"name":"production-renamed"}}}},"responses":{"200":{"description":"The key as changed","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKey"},"examples":{"UpdatedApiKey":{"$ref":"#/components/examples/UpdatedApiKey"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"412":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"PreconditionFailed":{"$ref":"#/components/examples/PreconditionFailed"}}}}},"413":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BodyTooLarge":{"$ref":"#/components/examples/BodyTooLarge"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"WriteRateLimited":{"$ref":"#/components/examples/WriteRateLimited"}}}}}},"operationId":"UpdateAnApiKey","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_update_key.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\nuse serde::Serialize;\n\n#[derive(Serialize)]\nstruct KeyPatch {\n    name: String,\n}\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let key_id: String = required(\"KEY_ID\")?;\n    let name = required(\"KEY_NAME\")?.trim().to_owned();\n    if !(1..=64).contains(&name.chars().count()) {\n        return Err(\"KEY_NAME must have 1 to 64 characters after trimming\".into());\n    }\n    let payload = KeyPatch { name };\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/keys/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&key_id);\n    let request = reqwest::Client::new()\n        .patch(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let request = if let Ok(etag) = std::env::var(\"KEY_ETAG\") {\n        request.header(\"If-Match\", etag)\n    } else {\n        request\n    };\n    let request = request.json(&payload);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_update_key/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n    \"bytes\"\n    \"encoding/json\"\n    \"strings\"\n    \"unicode/utf8\"\n)\n\ntype KeyPatch struct {\n    Name string `json:\"name\"`\n}\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    keyID, err := required(\"KEY_ID\")\n    if err != nil {\n        return err\n    }\n    name, err := required(\"KEY_NAME\")\n    if err != nil {\n        return err\n    }\n    name = strings.TrimSpace(name)\n    if length := utf8.RuneCountInString(name); length < 1 || length > 64 {\n        return fmt.Errorf(\"KEY_NAME must have 1 to 64 characters after trimming\")\n    }\n    payload := KeyPatch{Name: name}\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/keys/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += keyID\n    encoded, err := json.Marshal(payload)\n    if err != nil {\n        return err\n    }\n    request, err := http.NewRequest(http.MethodPatch, endpoint.String(), bytes.NewReader(encoded))\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    if etag := os.Getenv(\"KEY_ETAG\"); etag != \"\" {\n        request.Header.Set(\"If-Match\", etag)\n    }\n    request.Header.Set(\"Content-Type\", \"application/json\")\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-update-key.ts\nexport {}\n\ntype KeyPatch = { name: string }\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst keyId: string = required('KEY_ID')\nconst name: string = required('KEY_NAME').trim()\nif (Array.from(name).length < 1 || Array.from(name).length > 64) {\n  throw new Error('KEY_NAME must have 1 to 64 characters after trimming')\n}\nconst payload: KeyPatch = { name }\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/keys/')\nendpoint.pathname += encodeURIComponent(keyId)\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nif (process.env.KEY_ETAG) headers['If-Match'] = process.env.KEY_ETAG\nheaders['Content-Type'] = 'application/json'\nconst response = await fetch(endpoint, { method: 'PATCH', headers, body: JSON.stringify(payload) })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]},"delete":{"summary":"Revoke an API key","tags":["API keys"],"description":"Requires the `keys:write` scope. Revokes an own API key and returns it. An already revoked key returns its current state.","parameters":[{"name":"If-Match","in":"header","required":false,"description":"Change only the key version last read; a stale validator returns 412","schema":{"type":"string"}}],"responses":{"200":{"description":"The revoked key","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKey"},"examples":{"RevokedApiKey":{"$ref":"#/components/examples/RevokedApiKey"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"412":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"PreconditionFailed":{"$ref":"#/components/examples/PreconditionFailed"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"WriteRateLimited":{"$ref":"#/components/examples/WriteRateLimited"}}}}}},"operationId":"RevokeAnApiKey","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_revoke_key.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let key_id: String = required(\"KEY_ID\")?;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/keys/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&key_id);\n    let request = reqwest::Client::new()\n        .delete(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let request = if let Ok(etag) = std::env::var(\"KEY_ETAG\") {\n        request.header(\"If-Match\", etag)\n    } else {\n        request\n    };\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_revoke_key/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    keyID, err := required(\"KEY_ID\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/keys/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += keyID\n    request, err := http.NewRequest(http.MethodDelete, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    if etag := os.Getenv(\"KEY_ETAG\"); etag != \"\" {\n        request.Header.Set(\"If-Match\", etag)\n    }\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-revoke-key.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst keyId: string = required('KEY_ID')\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/keys/')\nendpoint.pathname += encodeURIComponent(keyId)\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nif (process.env.KEY_ETAG) headers['If-Match'] = process.env.KEY_ETAG\nconst response = await fetch(endpoint, { method: 'DELETE', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/keys/{id}/stats":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^key_[0-9a-f]{12}$"},"example":"key_012345abcdef"}],"get":{"summary":"Retrieve key statistics","tags":["API keys"],"description":"Requires the `usage:read` scope. Returns transaction counts, landed rate, median slots and tips for an own key's last 24 hours. Tips are integer lamports of SOL value, token tips included.","responses":{"200":{"description":"Its figures","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyStats"},"examples":{"KeyStatistics":{"$ref":"#/components/examples/KeyStatistics"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"},"AnalyticsBusy":{"$ref":"#/components/examples/AnalyticsBusy"}}}}}},"operationId":"KeyStatistics","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_key_stats.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let key_id: String = required(\"KEY_ID\")?;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/keys/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&key_id);\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?.push(\"stats\");\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_key_stats/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    keyID, err := required(\"KEY_ID\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/keys/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += keyID\n    endpoint.Path += \"/stats\"\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-key-stats.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst keyId: string = required('KEY_ID')\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/keys/')\nendpoint.pathname += encodeURIComponent(keyId)\nendpoint.pathname += '/stats'\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/transactions":{"get":{"summary":"List transactions","tags":["Usage"],"description":"Requires the `usage:read` scope. Returns the team's transaction records, newest first, with cursor pagination. Supply `next_cursor` as the next request's `cursor`; null ends the collection. `tip_lamports` counts lamports transferred to tip accounts; `token_tips` lists token tips in base units and `token_tip_lamports` gives their SOL value when sent.","parameters":[{"name":"limit","in":"query","required":false,"schema":{"default":50,"type":"integer","minimum":1,"maximum":100}},{"name":"cursor","in":"query","required":false,"schema":{"description":"`next_cursor` from the previous page","type":"string","maxLength":512}},{"name":"from","in":"query","required":false,"schema":{"description":"RFC 3339; defaults to 24 hours before `to`","type":"string","format":"date-time"}},{"name":"to","in":"query","required":false,"schema":{"description":"RFC 3339; defaults to now","type":"string","format":"date-time"}},{"name":"key_id","in":"query","required":false,"schema":{"type":"string","pattern":"^key_[0-9a-f]{12}$"}},{"name":"outcome","in":"query","required":false,"schema":{"type":"string","enum":["landed","failed","expired"]}}],"responses":{"200":{"description":"A page of transactions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TransactionPage"},"examples":{"TransactionList":{"$ref":"#/components/examples/TransactionList"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"},"AnalyticsBusy":{"$ref":"#/components/examples/AnalyticsBusy"}}}}}},"operationId":"Transactions","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_transactions.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let limit: u8 = 50;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/transactions\")?;\n    endpoint.query_pairs_mut().append_pair(\"limit\", &limit.to_string());\n    if let Ok(cursor) = std::env::var(\"CURSOR\") {\n        endpoint.query_pairs_mut().append_pair(\"cursor\", &cursor);\n    }\n    // Optional filters; FROM_TIME and TO_TIME must be RFC 3339 timestamps.\n    for (parameter, variable) in [(\"from\", \"FROM_TIME\"), (\"to\", \"TO_TIME\"), (\"key_id\", \"KEY_ID\"), (\"outcome\", \"OUTCOME\")] {\n        if let Ok(value) = std::env::var(variable) {\n            endpoint.query_pairs_mut().append_pair(parameter, &value);\n        }\n    }\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_transactions/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n    \"strconv\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    const limit uint8 = 50\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/transactions\")\n    if err != nil {\n        return err\n    }\n    query := endpoint.Query()\n    query.Set(\"limit\", strconv.Itoa(int(limit)))\n    if cursor := os.Getenv(\"CURSOR\"); cursor != \"\" {\n        query.Set(\"cursor\", cursor)\n    }\n    // Optional filters; FROM_TIME and TO_TIME must be RFC 3339 timestamps.\n    for parameter, variable := range map[string]string{\"from\": \"FROM_TIME\", \"to\": \"TO_TIME\", \"key_id\": \"KEY_ID\", \"outcome\": \"OUTCOME\"} {\n        if value := os.Getenv(variable); value != \"\" {\n            query.Set(parameter, value)\n        }\n    }\n    endpoint.RawQuery = query.Encode()\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-transactions.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst limit: number = 50\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/transactions')\nendpoint.searchParams.set('limit', String(limit))\nconst cursor: string | undefined = process.env.CURSOR\nif (cursor) endpoint.searchParams.set('cursor', cursor)\n// Optional filters; FROM_TIME and TO_TIME must be RFC 3339 timestamps.\nconst filters: Record<string, string | undefined> = {\n  from: process.env.FROM_TIME, to: process.env.TO_TIME,\n  key_id: process.env.KEY_ID, outcome: process.env.OUTCOME,\n}\nfor (const [parameter, value] of Object.entries(filters)) {\n  if (value) endpoint.searchParams.set(parameter, value)\n}\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/metrics":{"get":{"summary":"Retrieve Prometheus metrics","tags":["Metrics"],"description":"Requires the `usage:read` scope. Returns one complete UTC minute of transaction and receiver gauges in Prometheus text format. Data is 3 minutes behind.","responses":{"200":{"description":"Minute gauges with explicit millisecond timestamps. Cache hits do not count toward the team's concurrent query limit.","content":{"text/plain; version=0.0.4; charset=utf-8":{"schema":{"$ref":"#/components/schemas/MetricsText"},"examples":{"PrometheusMetrics":{"$ref":"#/components/examples/PrometheusMetrics"}}}},"headers":{"X-Metrics-Cache":{"description":"hit or miss for the team and minute cache","schema":{"enum":["hit","miss"],"type":"string"}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"},"AnalyticsBusy":{"$ref":"#/components/examples/AnalyticsBusy"}}}}}},"operationId":"PrometheusMetrics","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_metrics.rs\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let response = reqwest::Client::new()\n        .get(\"https://console.zerocopy.sh/api/v1/metrics\")\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?)\n        .send()\n        .await?;\n    let status = response.status();\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}: {body}\").into());\n    }\n    print!(\"{body}\");\n    Ok(())\n}\n"},{"lang":"go","id":"go","label":"Go","source":"// management-metrics/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"log\"\n    \"net/http\"\n\n    swqos \"swqos-examples\"\n)\n\nfunc main() {\n    if err := run(); err != nil {\n        log.Fatal(err)\n    }\n}\n\nfunc run() error {\n    apiKey, err := swqos.Required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    request, err := http.NewRequest(http.MethodGet, \"https://console.zerocopy.sh/api/v1/metrics\", nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return err\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d: %s\", response.StatusCode, body)\n    }\n    fmt.Print(string(body))\n    return nil\n}\n"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-metrics.ts\nconst apiKey = process.env.MANAGEMENT_API_KEY\nif (!apiKey) throw new Error('set MANAGEMENT_API_KEY')\n\nconst response = await fetch('https://console.zerocopy.sh/api/v1/metrics', {\n  headers: { authorization: `Bearer ${apiKey}` },\n})\nconst body = await response.text()\nif (!response.ok) throw new Error(`HTTP ${response.status}: ${body}`)\nconsole.log(body)\n\nexport {}\n"}]}},"/metrics/series":{"get":{"summary":"Retrieve metric history","tags":["Metrics"],"description":"Requires the `usage:read` scope. Returns historical transaction metric buckets over up to 90 days, grouped by one dimension. Repeat filters to select several values.","parameters":[{"name":"metric","in":"query","required":true,"example":"transactions","schema":{"type":"string","enum":["transactions","landed_rate","failed_rate","expired_rate","slots_to_land","edge_time","tips","priority_fees"]}},{"name":"group_by","in":"query","required":false,"schema":{"type":"string","enum":["key","metro","outcome","path","source","kind"]}},{"name":"quantile","in":"query","required":false,"schema":{"default":0.5,"anyOf":[{"type":"number","const":0.5},{"type":"number","const":0.9},{"type":"number","const":0.99}]}},{"name":"range","in":"query","required":false,"schema":{"default":"24h","type":"string","enum":["1h","24h","7d","30d"]}},{"name":"from","in":"query","required":false,"schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","required":false,"schema":{"type":"string","format":"date-time"}},{"name":"key_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","pattern":"^key_[0-9a-f]{12}$"},{"maxItems":100,"type":"array","items":{"type":"string","pattern":"^key_[0-9a-f]{12}$"}}]}},{"name":"metro","in":"query","required":false,"schema":{"anyOf":[{"type":"string","pattern":"^[a-z]{3}$"},{"maxItems":100,"type":"array","items":{"type":"string","pattern":"^[a-z]{3}$"}}]}},{"name":"outcome","in":"query","required":false,"schema":{"anyOf":[{"type":"string","enum":["landed","failed","expired"]},{"maxItems":3,"type":"array","items":{"type":"string","enum":["landed","failed","expired"]}}]}}],"responses":{"200":{"description":"Current transaction history, matching the console Metrics page","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricsSeries"},"examples":{"MetricHistory":{"$ref":"#/components/examples/MetricHistory"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"},"AnalyticsBusy":{"$ref":"#/components/examples/AnalyticsBusy"}}}}}},"operationId":"MetricHistory","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_metric_history.rs\nuse serde_json::Value;\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let response = reqwest::Client::new()\n        .get(\"https://console.zerocopy.sh/api/v1/metrics/series?metric=transactions&range=24h&group_by=outcome\")\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?)\n        .send()\n        .await?;\n    let status = response.status();\n    let body = response.text().await?;\n    let reply: Value = serde_json::from_str(&body)\n        .map_err(|error| format!(\"HTTP {status}: {error}; body: {body}\"))?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}: {reply}\").into());\n    }\n    println!(\"{}\", serde_json::to_string_pretty(&reply)?);\n    Ok(())\n}\n"},{"lang":"go","id":"go","label":"Go","source":"// management-metric-history/main.go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\n\tswqos \"swqos-examples\"\n)\n\nfunc main() {\n\tif err := run(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc run() error {\n\tapiKey, err := swqos.Required(\"MANAGEMENT_API_KEY\")\n\tif err != nil {\n\t\treturn err\n\t}\n\trequest, err := http.NewRequest(http.MethodGet,\n\t\t\"https://console.zerocopy.sh/api/v1/metrics/series?metric=transactions&range=24h&group_by=outcome\", nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n\tresponse, err := http.DefaultClient.Do(request)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer response.Body.Close()\n\tvar reply any\n\tif err := json.NewDecoder(response.Body).Decode(&reply); err != nil {\n\t\treturn fmt.Errorf(\"HTTP %d: %w\", response.StatusCode, err)\n\t}\n\tif response.StatusCode < 200 || response.StatusCode >= 300 {\n\t\treturn fmt.Errorf(\"HTTP %d: %v\", response.StatusCode, reply)\n\t}\n\toutput, err := json.MarshalIndent(reply, \"\", \"  \")\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Println(string(output))\n\treturn nil\n}\n"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-metric-history.ts\nconst apiKey = process.env.MANAGEMENT_API_KEY\nif (!apiKey) throw new Error('set MANAGEMENT_API_KEY')\n\nconst query = new URLSearchParams({\n  metric: 'transactions',\n  range: '24h',\n  group_by: 'outcome',\n})\nconst response = await fetch(\n  `https://console.zerocopy.sh/api/v1/metrics/series?${query}`,\n  { headers: { authorization: `Bearer ${apiKey}` } },\n)\nconst body = await response.text()\nlet reply: unknown\ntry {\n  reply = JSON.parse(body)\n} catch {\n  throw new Error(`HTTP ${response.status}: invalid JSON; body: ${body}`)\n}\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}: ${JSON.stringify(reply)}`)\n}\nconsole.log(JSON.stringify(reply, null, 2))\n\nexport {}\n"}]}},"/partner":{"get":{"summary":"Retrieve partner settings","tags":["White label"],"description":"Requires the `partner:read` scope. Returns the enrolled partner team's products, revenue share, tip account counts and domain status counts. `products` currently contains `send`. `share_bps` is the agreed share of net revenue; divide its integer value by 100 to obtain a percentage. `tip_account_count` includes pending vanity accounts; `live_tip_account_count` counts live accounts. Your own keys keep using company tip accounts until all eight vanity accounts are live. Customer keys can only be created after that switch. Domains can be prepared while waiting. A nonpartner receives HTTP `404`.","responses":{"200":{"description":"Products, share, total and live tip account counts, and domain counts","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Partner"},"examples":{"PartnerSettings":{"$ref":"#/components/examples/PartnerSettings"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"}}}}}},"operationId":"PartnerSummary","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_partner.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/partner\")?;\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_partner/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/partner\")\n    if err != nil {\n        return err\n    }\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-partner.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/partner')\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/partner/tip-accounts":{"get":{"summary":"List tip accounts","tags":["White label"],"description":"Requires the `partner:read` scope. Returns the enrolled partner team's vanity tip accounts and their activation status. The list can be empty while addresses are being generated. Each request generates exactly eight accounts. Use only accounts with `status: live`. ZeroCopy approves the accounts before activation; all eight accounts become live together. Until then, your own keys keep using company tip accounts and customer-key creation is refused. Before sending, discover the accounts accepted for the sending key with [getTipAccounts](/reference/json-rpc/tip-accounts).","responses":{"200":{"description":"Vanity tip accounts with live or pending status; use only live accounts","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerTipAccounts"},"examples":{"TipAccountList":{"$ref":"#/components/examples/TipAccountList"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"}}}}}},"operationId":"TipAccounts","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_partner_tip_accounts.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/partner/tip-accounts\")?;\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_partner_tip_accounts/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/partner/tip-accounts\")\n    if err != nil {\n        return err\n    }\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-partner-tip-accounts.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/partner/tip-accounts')\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/customer-keys":{"get":{"summary":"List customer keys","tags":["White label"],"description":"Requires the `partner:read` scope. Returns the enrolled partner team's customer keys with cursor pagination and an optional exact customer reference. Own keys are excluded. `limit` is 1 to 100 and defaults to 50. Supply `next_cursor` as the next request's `cursor`; null ends the collection.","parameters":[{"name":"limit","in":"query","required":false,"schema":{"default":50,"type":"integer","minimum":1,"maximum":100}},{"name":"cursor","in":"query","required":false,"schema":{"description":"`next_cursor` from the previous page","type":"string","maxLength":512}},{"name":"customer_ref","in":"query","required":false,"description":"Return only this exact customer reference","schema":{"type":"string","minLength":1,"maxLength":100},"example":"acme-123"}],"responses":{"200":{"description":"A page of keys","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerKeyPage"},"examples":{"CustomerKeyList":{"$ref":"#/components/examples/CustomerKeyList"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"}}}}}},"operationId":"ListCustomerKeys","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_list_customer_keys.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let limit: u8 = 50;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/customer-keys\")?;\n    endpoint.query_pairs_mut().append_pair(\"limit\", &limit.to_string());\n    if let Ok(cursor) = std::env::var(\"CURSOR\") {\n        endpoint.query_pairs_mut().append_pair(\"cursor\", &cursor);\n    }\n    if let Ok(customer_ref) = std::env::var(\"CUSTOMER_REF\") {\n        endpoint.query_pairs_mut().append_pair(\"customer_ref\", &customer_ref);\n    }\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_list_customer_keys/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n    \"strconv\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    const limit uint8 = 50\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/customer-keys\")\n    if err != nil {\n        return err\n    }\n    query := endpoint.Query()\n    query.Set(\"limit\", strconv.Itoa(int(limit)))\n    if cursor := os.Getenv(\"CURSOR\"); cursor != \"\" {\n        query.Set(\"cursor\", cursor)\n    }\n    if customerRef := os.Getenv(\"CUSTOMER_REF\"); customerRef != \"\" {\n        query.Set(\"customer_ref\", customerRef)\n    }\n    endpoint.RawQuery = query.Encode()\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-list-customer-keys.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst limit: number = 50\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/customer-keys')\nendpoint.searchParams.set('limit', String(limit))\nconst cursor: string | undefined = process.env.CURSOR\nif (cursor) endpoint.searchParams.set('cursor', cursor)\nif (process.env.CUSTOMER_REF) endpoint.searchParams.set('customer_ref', process.env.CUSTOMER_REF)\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]},"post":{"summary":"Create a customer key","tags":["White label"],"description":"Requires the `partner:write` scope. Creates a customer key and returns its secret once, after all eight vanity tip accounts are live. Before then, creation returns `409 tip_accounts_not_live`. The name is trimmed and must contain 1 to 64 characters. `customer_ref` is optional, trimmed to 1 to 100 characters, or null. Only `name` and `customer_ref` are accepted; products, rules, expiry and send settings cannot be set. Customer keys use `send` and do not count toward the own-key limit.","parameters":[{"name":"Idempotency-Key","in":"header","description":"Makes a retry return the first successful response instead of creating another customer key","schema":{"type":"string","minLength":1,"maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerKeyCreate"},"example":{"name":"Acme primary","customer_ref":"acme-123"}}}},"responses":{"201":{"description":"The key and its secret, shown once","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerKeyCreated"},"examples":{"CreatedCustomerKey":{"$ref":"#/components/examples/CreatedCustomerKey"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"409":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"IdempotencyKeyReused":{"$ref":"#/components/examples/IdempotencyKeyReused"},"TipAccountsNotLive":{"$ref":"#/components/examples/TipAccountsNotLive"}}}}},"413":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BodyTooLarge":{"$ref":"#/components/examples/BodyTooLarge"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"WriteRateLimited":{"$ref":"#/components/examples/WriteRateLimited"}}}}}},"operationId":"CreateCustomerKey","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_create_customer_key.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\nuse serde::Serialize;\n\n#[derive(Serialize)]\nstruct CustomerKeyCreate {\n    name: String,\n    customer_ref: String,\n}\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let name = required(\"KEY_NAME\")?.trim().to_owned();\n    if !(1..=64).contains(&name.chars().count()) {\n        return Err(\"KEY_NAME must have 1 to 64 characters after trimming\".into());\n    }\n    let payload = CustomerKeyCreate { name, customer_ref: required(\"CUSTOMER_REF\")? };\n    let endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/customer-keys\")?;\n    let request = reqwest::Client::new()\n        .post(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    // Reuse this key and the same body when retrying this creation attempt.\n    let request = request.header(\"Idempotency-Key\", required(\"KEY_REQUEST_ID\")?);\n    let request = request.json(&payload);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_create_customer_key/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n    \"bytes\"\n    \"encoding/json\"\n    \"strings\"\n    \"unicode/utf8\"\n)\n\ntype CustomerKeyCreate struct {\n    Name string `json:\"name\"`\n    CustomerRef string `json:\"customer_ref\"`\n}\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    // Reuse this key and the same body when retrying this creation attempt.\n    idempotencyKey, err := required(\"KEY_REQUEST_ID\")\n    if err != nil {\n        return err\n    }\n    name, err := required(\"KEY_NAME\")\n    if err != nil {\n        return err\n    }\n    name = strings.TrimSpace(name)\n    if length := utf8.RuneCountInString(name); length < 1 || length > 64 {\n        return fmt.Errorf(\"KEY_NAME must have 1 to 64 characters after trimming\")\n    }\n    customerRef, err := required(\"CUSTOMER_REF\")\n    if err != nil {\n        return err\n    }\n    payload := CustomerKeyCreate{Name: name, CustomerRef: customerRef}\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/customer-keys\")\n    if err != nil {\n        return err\n    }\n    encoded, err := json.Marshal(payload)\n    if err != nil {\n        return err\n    }\n    request, err := http.NewRequest(http.MethodPost, endpoint.String(), bytes.NewReader(encoded))\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    request.Header.Set(\"Idempotency-Key\", idempotencyKey)\n    request.Header.Set(\"Content-Type\", \"application/json\")\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-create-customer-key.ts\nexport {}\n\ntype CustomerKeyCreate = { name: string; customer_ref: string }\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst name: string = required('KEY_NAME').trim()\nif (Array.from(name).length < 1 || Array.from(name).length > 64) {\n  throw new Error('KEY_NAME must have 1 to 64 characters after trimming')\n}\nconst payload: CustomerKeyCreate = { name, customer_ref: required('CUSTOMER_REF') }\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/customer-keys')\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\n// Reuse this key and the same body when retrying this creation attempt.\nheaders['Idempotency-Key'] = required('KEY_REQUEST_ID')\nheaders['Content-Type'] = 'application/json'\nconst response = await fetch(endpoint, { method: 'POST', headers, body: JSON.stringify(payload) })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/customer-keys/usage":{"get":{"summary":"Retrieve customer usage","tags":["White label"],"description":"Requires the `partner:read` scope. Returns usage grouped by the enrolled partner team's exact customer references for the selected window. Keys without a reference share a null group. `live_keys` counts currently active keys. Landed rate is a percentage; tips are integer lamports from landed transactions. `last_seen_at` can precede the selected window. `range` defaults to `24h`; `customer_ref` optionally selects one exact group. The response is an unpaginated JSON collection.","responses":{"200":{"description":"Its figures","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerUsagePage"},"examples":{"CustomerUsage":{"$ref":"#/components/examples/CustomerUsage"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"},"AnalyticsBusy":{"$ref":"#/components/examples/AnalyticsBusy"}}}}}},"operationId":"CustomerUsage","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_customer_usage.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/customer-keys/usage\")?;\n    endpoint.query_pairs_mut().append_pair(\"range\", \"7d\");\n    if let Ok(customer_ref) = std::env::var(\"CUSTOMER_REF\") {\n        endpoint.query_pairs_mut().append_pair(\"customer_ref\", &customer_ref);\n    }\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_customer_usage/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/customer-keys/usage\")\n    if err != nil {\n        return err\n    }\n    query := endpoint.Query()\n    query.Set(\"range\", \"7d\")\n    if customerRef := os.Getenv(\"CUSTOMER_REF\"); customerRef != \"\" {\n        query.Set(\"customer_ref\", customerRef)\n    }\n    endpoint.RawQuery = query.Encode()\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-customer-usage.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/customer-keys/usage')\nendpoint.searchParams.set('range', '7d')\nif (process.env.CUSTOMER_REF) endpoint.searchParams.set('customer_ref', process.env.CUSTOMER_REF)\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}],"parameters":[{"name":"range","in":"query","required":false,"description":"Trailing analytics window","schema":{"type":"string","enum":["24h","7d","30d"],"default":"24h"},"example":"7d"},{"name":"customer_ref","in":"query","required":false,"description":"Return only this exact customer reference","schema":{"type":"string","minLength":1,"maxLength":100},"example":"acme-123"}]}},"/customer-keys/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^key_[0-9a-f]{12}$"},"example":"key_012345abcdef"}],"get":{"summary":"Retrieve a customer key","tags":["White label"],"description":"Requires the `partner:read` scope. Returns one of the enrolled partner team's customer keys and its current ETag. Own, missing or foreign key IDs return `404 not_found`. The secret is never returned by this endpoint.","responses":{"200":{"description":"The key","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerKey"},"examples":{"RetrievedCustomerKey":{"$ref":"#/components/examples/RetrievedCustomerKey"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"}}}}}},"operationId":"ReadCustomerKey","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_read_customer_key.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let key_id: String = required(\"KEY_ID\")?;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&key_id);\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_read_customer_key/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    keyID, err := required(\"KEY_ID\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += keyID\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-read-customer-key.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst keyId: string = required('KEY_ID')\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/customer-keys/')\nendpoint.pathname += encodeURIComponent(keyId)\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]},"patch":{"summary":"Update a customer key","tags":["White label"],"description":"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`.","parameters":[{"name":"If-Match","in":"header","required":false,"description":"Change only the key version last read; a stale validator returns 412","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerKeyPatch"},"example":{"name":"Acme production","customer_ref":"acme-prod"}}}},"responses":{"200":{"description":"The key as changed","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerKey"},"examples":{"UpdatedCustomerKey":{"$ref":"#/components/examples/UpdatedCustomerKey"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"412":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"PreconditionFailed":{"$ref":"#/components/examples/PreconditionFailed"}}}}},"413":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BodyTooLarge":{"$ref":"#/components/examples/BodyTooLarge"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"WriteRateLimited":{"$ref":"#/components/examples/WriteRateLimited"}}}}}},"operationId":"UpdateCustomerKey","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_update_customer_key.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\nuse serde::Serialize;\n\n#[derive(Serialize)]\nstruct CustomerKeyPatch {\n    name: String,\n}\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let key_id: String = required(\"KEY_ID\")?;\n    let name = required(\"KEY_NAME\")?.trim().to_owned();\n    if !(1..=64).contains(&name.chars().count()) {\n        return Err(\"KEY_NAME must have 1 to 64 characters after trimming\".into());\n    }\n    let payload = CustomerKeyPatch { name };\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&key_id);\n    let request = reqwest::Client::new()\n        .patch(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let request = if let Ok(etag) = std::env::var(\"KEY_ETAG\") {\n        request.header(\"If-Match\", etag)\n    } else {\n        request\n    };\n    let request = request.json(&payload);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_update_customer_key/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n    \"bytes\"\n    \"encoding/json\"\n    \"strings\"\n    \"unicode/utf8\"\n)\n\ntype CustomerKeyPatch struct {\n    Name string `json:\"name\"`\n}\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    keyID, err := required(\"KEY_ID\")\n    if err != nil {\n        return err\n    }\n    name, err := required(\"KEY_NAME\")\n    if err != nil {\n        return err\n    }\n    name = strings.TrimSpace(name)\n    if length := utf8.RuneCountInString(name); length < 1 || length > 64 {\n        return fmt.Errorf(\"KEY_NAME must have 1 to 64 characters after trimming\")\n    }\n    payload := CustomerKeyPatch{Name: name}\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += keyID\n    encoded, err := json.Marshal(payload)\n    if err != nil {\n        return err\n    }\n    request, err := http.NewRequest(http.MethodPatch, endpoint.String(), bytes.NewReader(encoded))\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    if etag := os.Getenv(\"KEY_ETAG\"); etag != \"\" {\n        request.Header.Set(\"If-Match\", etag)\n    }\n    request.Header.Set(\"Content-Type\", \"application/json\")\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-update-customer-key.ts\nexport {}\n\ntype CustomerKeyPatch = { name: string }\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst keyId: string = required('KEY_ID')\nconst name: string = required('KEY_NAME').trim()\nif (Array.from(name).length < 1 || Array.from(name).length > 64) {\n  throw new Error('KEY_NAME must have 1 to 64 characters after trimming')\n}\nconst payload: CustomerKeyPatch = { name }\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/customer-keys/')\nendpoint.pathname += encodeURIComponent(keyId)\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nif (process.env.KEY_ETAG) headers['If-Match'] = process.env.KEY_ETAG\nheaders['Content-Type'] = 'application/json'\nconst response = await fetch(endpoint, { method: 'PATCH', headers, body: JSON.stringify(payload) })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]},"delete":{"summary":"Revoke a customer key","tags":["White label"],"description":"Requires the `partner:write` scope. Permanently revokes a customer key and returns its current fields, including the new ETag. Repeating a revocation returns the already revoked resource. A revoked key cannot be resumed.","parameters":[{"name":"If-Match","in":"header","required":false,"description":"Change only the key version last read; a stale validator returns 412","schema":{"type":"string"}}],"responses":{"200":{"description":"The revoked key","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerKey"},"examples":{"RevokedCustomerKey":{"$ref":"#/components/examples/RevokedCustomerKey"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"412":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"PreconditionFailed":{"$ref":"#/components/examples/PreconditionFailed"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"WriteRateLimited":{"$ref":"#/components/examples/WriteRateLimited"}}}}}},"operationId":"RevokeCustomerKey","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_revoke_customer_key.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let key_id: String = required(\"KEY_ID\")?;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&key_id);\n    let request = reqwest::Client::new()\n        .delete(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let request = if let Ok(etag) = std::env::var(\"KEY_ETAG\") {\n        request.header(\"If-Match\", etag)\n    } else {\n        request\n    };\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_revoke_customer_key/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    keyID, err := required(\"KEY_ID\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += keyID\n    request, err := http.NewRequest(http.MethodDelete, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    if etag := os.Getenv(\"KEY_ETAG\"); etag != \"\" {\n        request.Header.Set(\"If-Match\", etag)\n    }\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-revoke-customer-key.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst keyId: string = required('KEY_ID')\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/customer-keys/')\nendpoint.pathname += encodeURIComponent(keyId)\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nif (process.env.KEY_ETAG) headers['If-Match'] = process.env.KEY_ETAG\nconst response = await fetch(endpoint, { method: 'DELETE', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/customer-keys/{id}/pause":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^key_[0-9a-f]{12}$"},"example":"key_012345abcdef"}],"post":{"summary":"Pause a customer key","tags":["White label"],"description":"Requires the `partner:write` scope. Pauses a customer key without changing its secret and returns the key with its current ETag. Paused keys reject sending requests with `key_paused`. No request body is needed. An already paused key returns `400 invalid_request` unless this request replays a saved idempotent response. A revoked key returns `404 not_found`.","parameters":[{"name":"If-Match","in":"header","required":false,"description":"Change only the key version last read; a stale validator returns 412","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","description":"Makes a retry return the first successful response instead of repeating the state change","schema":{"type":"string","minLength":1,"maxLength":255}}],"responses":{"200":{"description":"The paused customer key","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerKey"},"examples":{"PausedCustomerKey":{"$ref":"#/components/examples/PausedCustomerKey"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"409":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"IdempotencyKeyReused":{"$ref":"#/components/examples/IdempotencyKeyReused"}}}}},"412":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"PreconditionFailed":{"$ref":"#/components/examples/PreconditionFailed"}}}}},"413":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BodyTooLarge":{"$ref":"#/components/examples/BodyTooLarge"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"WriteRateLimited":{"$ref":"#/components/examples/WriteRateLimited"}}}}}},"operationId":"PauseCustomerKey","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_pause_customer_key.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let key_id: String = required(\"KEY_ID\")?;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&key_id);\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?.push(\"pause\");\n    let request = reqwest::Client::new()\n        .post(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let request = if let Ok(etag) = std::env::var(\"KEY_ETAG\") {\n        request.header(\"If-Match\", etag)\n    } else {\n        request\n    };\n    // Reuse this key when retrying the same state change.\n    let request = request.header(\"Idempotency-Key\", required(\"KEY_REQUEST_ID\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_pause_customer_key/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    keyID, err := required(\"KEY_ID\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += keyID\n    endpoint.Path += \"/pause\"\n    request, err := http.NewRequest(http.MethodPost, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    if etag := os.Getenv(\"KEY_ETAG\"); etag != \"\" {\n        request.Header.Set(\"If-Match\", etag)\n    }\n    // Reuse this key when retrying the same state change.\n    idempotencyKey, err := required(\"KEY_REQUEST_ID\")\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Idempotency-Key\", idempotencyKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-pause-customer-key.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst keyId: string = required('KEY_ID')\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/customer-keys/')\nendpoint.pathname += encodeURIComponent(keyId)\nendpoint.pathname += '/pause'\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nif (process.env.KEY_ETAG) headers['If-Match'] = process.env.KEY_ETAG\n// Reuse this key when retrying the same state change.\nheaders['Idempotency-Key'] = required('KEY_REQUEST_ID')\nconst response = await fetch(endpoint, { method: 'POST', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/customer-keys/{id}/resume":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^key_[0-9a-f]{12}$"},"example":"key_012345abcdef"}],"post":{"summary":"Resume a customer key","tags":["White label"],"description":"Requires the `partner:write` scope. Resumes a paused customer key without changing its secret and returns the key with its current ETag. No request body is needed. A key that is not paused returns `400 invalid_request` unless this request replays a saved idempotent response. A revoked key returns `404 not_found`.","parameters":[{"name":"If-Match","in":"header","required":false,"description":"Change only the key version last read; a stale validator returns 412","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","description":"Makes a retry return the first successful response instead of repeating the state change","schema":{"type":"string","minLength":1,"maxLength":255}}],"responses":{"200":{"description":"The resumed customer key","headers":{"ETag":{"description":"Strong validator of the returned key state","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerKey"},"examples":{"ResumedCustomerKey":{"$ref":"#/components/examples/ResumedCustomerKey"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"409":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"IdempotencyKeyReused":{"$ref":"#/components/examples/IdempotencyKeyReused"}}}}},"412":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"PreconditionFailed":{"$ref":"#/components/examples/PreconditionFailed"}}}}},"413":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BodyTooLarge":{"$ref":"#/components/examples/BodyTooLarge"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"WriteRateLimited":{"$ref":"#/components/examples/WriteRateLimited"}}}}}},"operationId":"ResumeCustomerKey","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_resume_customer_key.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let key_id: String = required(\"KEY_ID\")?;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&key_id);\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?.push(\"resume\");\n    let request = reqwest::Client::new()\n        .post(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let request = if let Ok(etag) = std::env::var(\"KEY_ETAG\") {\n        request.header(\"If-Match\", etag)\n    } else {\n        request\n    };\n    // Reuse this key when retrying the same state change.\n    let request = request.header(\"Idempotency-Key\", required(\"KEY_REQUEST_ID\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_resume_customer_key/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    keyID, err := required(\"KEY_ID\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += keyID\n    endpoint.Path += \"/resume\"\n    request, err := http.NewRequest(http.MethodPost, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    if etag := os.Getenv(\"KEY_ETAG\"); etag != \"\" {\n        request.Header.Set(\"If-Match\", etag)\n    }\n    // Reuse this key when retrying the same state change.\n    idempotencyKey, err := required(\"KEY_REQUEST_ID\")\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Idempotency-Key\", idempotencyKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-resume-customer-key.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst keyId: string = required('KEY_ID')\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/customer-keys/')\nendpoint.pathname += encodeURIComponent(keyId)\nendpoint.pathname += '/resume'\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nif (process.env.KEY_ETAG) headers['If-Match'] = process.env.KEY_ETAG\n// Reuse this key when retrying the same state change.\nheaders['Idempotency-Key'] = required('KEY_REQUEST_ID')\nconst response = await fetch(endpoint, { method: 'POST', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/customer-keys/{id}/stats":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^key_[0-9a-f]{12}$"},"example":"key_012345abcdef"}],"get":{"summary":"Retrieve customer key statistics","tags":["White label"],"description":"Requires the `partner:read` scope. Returns transaction counts, landed rate, median slots to land and tips for one customer key over the selected window. `range` accepts `24h`, `7d` or `30d` and defaults to `24h`. Landed rate is a percentage; tips are integer lamports from landed transactions. `last_seen_at` can precede the selected window. Own, missing or foreign key IDs return `404 not_found`.","responses":{"200":{"description":"Its figures","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerKeyStats"},"examples":{"CustomerKeyStatistics":{"$ref":"#/components/examples/CustomerKeyStatistics"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"},"AnalyticsBusy":{"$ref":"#/components/examples/AnalyticsBusy"}}}}}},"operationId":"CustomerKeyStatistics","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_customer_key_stats.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let key_id: String = required(\"KEY_ID\")?;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&key_id);\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?.push(\"stats\");\n    endpoint.query_pairs_mut().append_pair(\"range\", \"7d\");\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_customer_key_stats/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    keyID, err := required(\"KEY_ID\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/customer-keys/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += keyID\n    endpoint.Path += \"/stats\"\n    query := endpoint.Query()\n    query.Set(\"range\", \"7d\")\n    endpoint.RawQuery = query.Encode()\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-customer-key-stats.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst keyId: string = required('KEY_ID')\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/customer-keys/')\nendpoint.pathname += encodeURIComponent(keyId)\nendpoint.pathname += '/stats'\nendpoint.searchParams.set('range', '7d')\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}],"parameters":[{"name":"range","in":"query","required":false,"description":"Trailing analytics window","schema":{"type":"string","enum":["24h","7d","30d"],"default":"24h"},"example":"7d"}]}},"/domains":{"get":{"summary":"List domains","tags":["White label"],"description":"Requires the `partner:read` scope. Returns only the enrolled partner team's domains, ordered by hostname.","responses":{"200":{"description":"Domains and the DNS records to create","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerDomainList"},"examples":{"DomainList":{"$ref":"#/components/examples/DomainList"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"}}}}}},"operationId":"ReadDomains","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_list_domains.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/domains\")?;\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_list_domains/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/domains\")\n    if err != nil {\n        return err\n    }\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-list-domains.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/domains')\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]},"post":{"summary":"Add a domain","tags":["White label"],"description":"Requires the `partner:write` scope. Registers a domain for the enrolled partner team with an initial status of `pending`. Domains can be prepared before the team's vanity tip accounts are live. `hostname` must be a lowercase ASCII DNS name with at least three labels, at most 253 characters overall and at most 63 per label. Names under `zerocopy.sh` are reserved; schemes, ports, paths and wildcard domains are invalid. `target` is required. The domain inherits the team's partner products. The team can have up to 20 domains across all statuses; creation at the limit returns `409 domain_limit`. A duplicate domain within the team returns `409 hostname_taken`. Claims from several teams can coexist until DNS verification. The first team to verify wins the domain; other claims are deleted and subsequently return `404`.","parameters":[{"name":"Idempotency-Key","in":"header","description":"Makes a retry return the first successful response instead of adding another domain","schema":{"type":"string","minLength":1,"maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DomainCreate"},"example":{"hostname":"send.partner.example","target":"sol"}}}},"responses":{"201":{"description":"The domain and its DNS records","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerDomain"},"examples":{"PendingDomain":{"$ref":"#/components/examples/PendingDomain"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"409":{"description":"The team already has this hostname (`hostname_taken`), its 20-domain limit is reached (`domain_limit`), or an idempotency conflict","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"HostnameTaken":{"$ref":"#/components/examples/HostnameTaken"}}}}},"413":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BodyTooLarge":{"$ref":"#/components/examples/BodyTooLarge"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"WriteRateLimited":{"$ref":"#/components/examples/WriteRateLimited"}}}}}},"operationId":"AddADomain","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_create_domain.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\nuse serde::Serialize;\n\n#[derive(Serialize)]\nstruct DomainCreate {\n    hostname: String,\n    target: &'static str,\n}\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let payload = DomainCreate { hostname: required(\"DOMAIN_HOSTNAME\")?, target: \"sol\" };\n    let endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/domains\")?;\n    let request = reqwest::Client::new()\n        .post(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    // Reuse this key and the same body when retrying this creation attempt.\n    let request = request.header(\"Idempotency-Key\", required(\"DOMAIN_REQUEST_ID\")?);\n    let request = request.json(&payload);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_create_domain/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n    \"bytes\"\n    \"encoding/json\"\n)\n\ntype DomainCreate struct {\n    Hostname string `json:\"hostname\"`\n    Target string `json:\"target\"`\n}\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    // Reuse this key and the same body when retrying this creation attempt.\n    idempotencyKey, err := required(\"DOMAIN_REQUEST_ID\")\n    if err != nil {\n        return err\n    }\n    hostname, err := required(\"DOMAIN_HOSTNAME\")\n    if err != nil {\n        return err\n    }\n    payload := DomainCreate{Hostname: hostname, Target: \"sol\"}\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/domains\")\n    if err != nil {\n        return err\n    }\n    encoded, err := json.Marshal(payload)\n    if err != nil {\n        return err\n    }\n    request, err := http.NewRequest(http.MethodPost, endpoint.String(), bytes.NewReader(encoded))\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    request.Header.Set(\"Idempotency-Key\", idempotencyKey)\n    request.Header.Set(\"Content-Type\", \"application/json\")\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-create-domain.ts\nexport {}\n\ntype DomainCreate = { hostname: string; target: 'sol' }\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst payload: DomainCreate = { hostname: required('DOMAIN_HOSTNAME'), target: 'sol' }\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/domains')\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\n// Reuse this key and the same body when retrying this creation attempt.\nheaders['Idempotency-Key'] = required('DOMAIN_REQUEST_ID')\nheaders['Content-Type'] = 'application/json'\nconst response = await fetch(endpoint, { method: 'POST', headers, body: JSON.stringify(payload) })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}},"/domains/{hostname}":{"parameters":[{"name":"hostname","in":"path","required":true,"schema":{"type":"string","maxLength":253,"pattern":"^(?!.*\\.zerocopy\\.sh$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.){2,}[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$"},"example":"send.partner.example"}],"get":{"summary":"Retrieve a domain","tags":["White label"],"description":"Requires the `partner:read` scope. Returns one domain owned by the enrolled partner team and its DNS setup records. A missing or foreign domain returns HTTP `404`. The seven day DNS cleanup applies only before the first certificate exists. Failed renewals keep an existing unexpired certificate in service; read `last_error` and `not_after` to distinguish renewal failure from expiry.","responses":{"200":{"description":"The domain and its DNS records","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerDomain"},"examples":{"ActiveDomain":{"$ref":"#/components/examples/ActiveDomain"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ReadRateLimited":{"$ref":"#/components/examples/ReadRateLimited"}}}}}},"operationId":"ReadADomain","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_read_domain.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let hostname: String = required(\"DOMAIN_HOSTNAME\")?;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/domains/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&hostname);\n    let request = reqwest::Client::new()\n        .get(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_read_domain/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    hostname, err := required(\"DOMAIN_HOSTNAME\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/domains/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += hostname\n    request, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-read-domain.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst hostname: string = required('DOMAIN_HOSTNAME')\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/domains/')\nendpoint.pathname += encodeURIComponent(hostname)\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'GET', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]},"delete":{"summary":"Remove a domain","tags":["White label"],"description":"Requires the `partner:write` scope. Removes one domain from the enrolled partner team and returns its previous fields. A missing domain or another team's domain returns `404`. Update clients before removal. Servers normally apply the removal within 60 seconds. If a server cannot update its hostname policy, the domain stays available there until an update succeeds. Once applied, the domain stops accepting requests, including on existing connections and resumed TLS sessions. HTTPS returns HTTP 421 with plain text; QUIC closes with application code 4. Your keys keep working on the ZeroCopy endpoints. Delete both DNS records at your provider afterwards. Adding the domain again starts a new setup and assigns a new challenge CNAME. Team closure, or ending partner access, also deletes the team's domains and certificates.","responses":{"200":{"description":"The removed domain","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerDomain"},"examples":{"RemovedDomain":{"$ref":"#/components/examples/RemovedDomain"}}}}},"400":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"BadRequest":{"$ref":"#/components/examples/BadRequest"}}}}},"401":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"Unauthorized":{"$ref":"#/components/examples/Unauthorized"}}}}},"403":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"ForbiddenIp":{"$ref":"#/components/examples/ForbiddenIp"}}}}},"404":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"NotFound":{"$ref":"#/components/examples/NotFound"}}}}},"429":{"description":"A refusal; `code` is stable","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"},"examples":{"WriteRateLimited":{"$ref":"#/components/examples/WriteRateLimited"}}}}}},"operationId":"RemoveADomain","x-codeSamples":[{"lang":"rust","id":"rust","label":"Rust","source":"// src/bin/management_remove_domain.rs\n// Builds on the example project (/reference/json-rpc#example-project).\nuse swqos_examples::swqos::{Result, required};\n\n#[tokio::main]\nasync fn main() -> Result<()> {\n    let hostname: String = required(\"DOMAIN_HOSTNAME\")?;\n    let mut endpoint = reqwest::Url::parse(\"https://console.zerocopy.sh/api/v1/domains/\")?;\n    endpoint.path_segments_mut().map_err(|_| \"invalid base URL\")?\n        .pop_if_empty().push(&hostname);\n    let request = reqwest::Client::new()\n        .delete(endpoint)\n        .bearer_auth(required(\"MANAGEMENT_API_KEY\")?);\n    let response = request.send().await?;\n    let status = response.status();\n    let request_id = response.headers().get(\"Request-Id\")\n        .map(|value| value.to_str()).transpose()?.unwrap_or(\"<missing>\").to_owned();\n    if let Some(etag) = response.headers().get(\"ETag\") {\n        eprintln!(\"ETag: {}\", etag.to_str()?);\n    }\n    let body = response.text().await?;\n    if !status.is_success() {\n        return Err(format!(\"HTTP {status}; Request-Id: {request_id}; {body}\").into());\n    }\n    eprintln!(\"Request-Id: {request_id}\");\n    println!(\"{body}\");\n    Ok(())\n}"},{"lang":"go","id":"go","label":"Go","source":"// management_remove_domain/main.go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"net/http\"\n    \"net/url\"\n    \"os\"\n)\n\nfunc required(name string) (string, error) {\n    value := os.Getenv(name)\n    if value == \"\" {\n        return \"\", fmt.Errorf(\"set %s\", name)\n    }\n    return value, nil\n}\n\nfunc run() error {\n    apiKey, err := required(\"MANAGEMENT_API_KEY\")\n    if err != nil {\n        return err\n    }\n    hostname, err := required(\"DOMAIN_HOSTNAME\")\n    if err != nil {\n        return err\n    }\n    endpoint, err := url.Parse(\"https://console.zerocopy.sh/api/v1/domains/\")\n    if err != nil {\n        return err\n    }\n    endpoint.Path += hostname\n    request, err := http.NewRequest(http.MethodDelete, endpoint.String(), nil)\n    if err != nil {\n        return err\n    }\n    request.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n    response, err := http.DefaultClient.Do(request)\n    if err != nil {\n        return err\n    }\n    defer response.Body.Close()\n    requestID := response.Header.Get(\"Request-Id\")\n    body, err := io.ReadAll(response.Body)\n    if err != nil {\n        return fmt.Errorf(\"Request-Id: %s: %w\", requestID, err)\n    }\n    if response.StatusCode < 200 || response.StatusCode >= 300 {\n        return fmt.Errorf(\"HTTP %d; Request-Id: %s; %s\", response.StatusCode, requestID, body)\n    }\n    fmt.Fprintln(os.Stderr, \"Request-Id:\", requestID)\n    if etag := response.Header.Get(\"ETag\"); etag != \"\" {\n        fmt.Fprintln(os.Stderr, \"ETag:\", etag)\n    }\n    fmt.Println(string(body))\n    return nil\n}\n\nfunc main() {\n    if err := run(); err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n}"},{"lang":"ts","id":"ts","label":"TypeScript","source":"// management-remove-domain.ts\nexport {}\n\nfunction required(name: string): string {\n  const value = process.env[name]\n  if (!value) throw new Error(`set ${name}`)\n  return value\n}\n\nconst hostname: string = required('DOMAIN_HOSTNAME')\nconst endpoint = new URL('https://console.zerocopy.sh/api/v1/domains/')\nendpoint.pathname += encodeURIComponent(hostname)\nconst headers: Record<string, string> = {\n  Authorization: `Bearer ${required('MANAGEMENT_API_KEY')}`,\n}\nconst response = await fetch(endpoint, { method: 'DELETE', headers })\nconst requestId = response.headers.get('Request-Id')\nconst body = await response.text()\nif (!response.ok) {\n  throw new Error(`HTTP ${response.status}; Request-Id: ${requestId}; ${body}`)\n}\nconsole.error('Request-Id:', requestId)\nconst etag = response.headers.get('ETag')\nif (etag) console.error('ETag:', etag)\nconsole.log(body)"}]}}}}