Update an API key

Rename or re-scope an API key, or set its source-IP allowlist.

Rename a key, narrow its scope, or restrict it to a source-IP allowlist — all without rotating the secret.

PATCH /v3/keys/{id}

Body parameters

ParameterTypeRequiredDescription
namestringOptionalNew label (max 255 chars).
scopestringOptionalfull_access, send_only or read_only. Live keys only — test keys always stay full_access and this field is ignored for them.
verify_before_sendboolean or nullOptionalOverride (true/false) or inherit (null) the verify-before-send setting. Live keys only.
test_outcomesobjectOptionalNew simulated outcome mix. Test keys only — ignored for live keys.
ip_allowlistarrayOptionalSource-IP allowlist as [{ "cidr": "203.0.113.0/24", "label": "office" }] (max 50 entries, IPv4/IPv6 CIDRs — bare IPs are normalized to /32//128). Requests from any other IP are rejected with 403 ip_not_allowed. Empty array [] clears the restriction. Applies to both live and test keys.

Responses

StatusDescription
200OK. The updated key. An empty update returns the current key unchanged.
400Validation error — e.g. an invalid CIDR in ip_allowlist (the message names the offending entry).
401Missing or invalid API key.
403Only account owners/admins can change a key's IP allowlist.
404No such key on your account, or it has already been revoked.

Code examples

cURL
curl -X PATCH https://api.wemail.io/v3/keys/{id} \
  -H "Authorization: Bearer afn_live_…" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Production API Key (rotating)", "scope": "send_only" }'
Node.js
const res = await fetch("https://api.wemail.io/v3/keys/{id}", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.WEMAIL_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ "name": "Production API Key (rotating)", "scope": "send_only" }),
});
const data = await res.json();
Python
import os, requests

r = requests.patch(
    "https://api.wemail.io/v3/keys/{id}",
    headers={"Authorization": f"Bearer {os.environ['WEMAIL_API_KEY']}"},
    json={ "name": "Production API Key (rotating)", "scope": "send_only" },
)
data = r.json()