Rename a Key, Edit Origins, Budget or Scope
curl -X PATCH https://api.astroway.info/v1/keys/{id} \ -H "X-Api-Key: aw_live_..." \ -H "Content-Type: application/json" \ -d '{ "name": "site-widget", "credits_cap_cycle": 5000, "allowed_endpoints": [ "embed/*" ], "origin_restriction": { "type": "public", "allowed_origins": [ "example.com", "*.example.com" ] } }'const res = await fetch('https://api.astroway.info/v1/keys/{id}', { method: 'PATCH', headers: { 'X-Api-Key': process.env.ASTROWAY_API_KEY, 'Content-Type': 'application/json', }, body: JSON.stringify({ "name": "site-widget", "credits_cap_cycle": 5000, "allowed_endpoints": [ "embed/*" ], "origin_restriction": { "type": "public", "allowed_origins": [ "example.com", "*.example.com" ] } }),});const { ok, data, error } = await res.json();if (!ok) throw new Error(error.message);console.log(data);import os, requests
r = requests.patch( 'https://api.astroway.info/v1/keys/{id}', headers={'X-Api-Key': os.environ['ASTROWAY_API_KEY'], 'Content-Type': 'application/json'}, json={ 'name': "site-widget", 'credits_cap_cycle': 5000, 'allowed_endpoints': [ "embed/*" ], 'origin_restriction': { 'type': "public", 'allowed_origins': [ "example.com", "*.example.com" ] } },)result = r.json()if not result['ok']: raise RuntimeError(result['error']['message'])print(result['data'])<?phpuse GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://api.astroway.info/v1/']);$r = $client->patch('keys/{id}', [ 'headers' => ['X-Api-Key' => getenv('ASTROWAY_API_KEY')], 'json' => [ 'name' => 'site-widget', 'credits_cap_cycle' => 5000, 'allowed_endpoints' => ['embed/*'], 'origin_restriction' => [ 'type' => 'public', 'allowed_origins' => ['example.com', '*.example.com'], ], ],]);$result = json_decode($r->getBody(), true);if (!$result['ok']) throw new \RuntimeException($result['error']['message']);print_r($result['data']);Rename a key, rewrite the origin list of a publishable key, set a per-key credit budget, limit the key to a subset of endpoints, or any combination. The class is fixed at creation: a pk_ key cannot become server-only, and a secret key cannot be given a list, so either request is refused with 400 rather than quietly rewritten. A new list takes effect at once and the key string does not change. credits_cap_cycle caps what this one key may spend per billing cycle, which credits alone do not, since they pool across the account; null clears it and a call over the cap answers 429 KEY_BUDGET_EXHAUSTED without falling through to overage. allowed_endpoints takes paths under /v1, exact (“chart”) or a namespace (“embed/*”); null removes the limit and a call outside the list answers 403 ENDPOINT_NOT_IN_SCOPE.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”object
object
Example
{ "name": "site-widget", "credits_cap_cycle": 5000, "allowed_endpoints": [ "embed/*" ], "origin_restriction": { "type": "public", "allowed_origins": [ "example.com", "*.example.com" ] }}Responses
Section titled “ Responses ”Successful calculation
object
object
object
Example
{ "ok": true, "data": { "id": 42, "api_key_masked": "pk_live…e5f6", "name": "site-widget", "plan": "free", "rate_limit": 10, "credits_limit": 10000, "credits_used": 0, "created_at": "2026-08-22T21:05:14.335Z", "last_used_at": null, "is_active": true, "origin_restriction": { "type": "public", "allowed_origins": [ "example.com", "*.example.com" ] }, "credits_cap_cycle": 5000, "allowed_endpoints": [ "embed/*" ] }}Validation error
Example
{ "ok": false, "error": { "code": "INVALID_INPUT", "message": "Validation failed: date: Date must be YYYY-MM-DD", "details": [ { "path": "date", "message": "Date must be YYYY-MM-DD" } ] }}Missing or invalid API key
Example
{ "ok": false, "error": { "code": "INVALID_API_KEY", "message": "Invalid API key" }}