Create a new API key for the authenticated account.
const url = 'https://api.siteqwality.com/account/api_key/';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"friendly_name":"example","key_type":"ingest","scopes":["example"],"expires_in_days":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.siteqwality.com/account/api_key/ \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "friendly_name": "example", "key_type": "ingest", "scopes": [ "example" ], "expires_in_days": 1 }'The response contains the full secret. This is the ONLY time it is ever shown: only its SHA-256 is stored, so it cannot be retrieved again, only rotated.
key_type defaults to full when omitted, which is exactly what every
key did before this endpoint grew types. The dashboard sends ingest
explicitly, because a key destined for a log-forwarder config should not
also be able to delete monitors.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”Body for POST /account/api_key.
object
Omitted means full.
This is deliberately NOT the dashboard’s default (which is ingest,
the safer choice). The API default has to preserve the historical
behaviour, because a customer script that has been POSTing
{"friendly_name": "..."} for years must keep getting a key that can
do what its keys have always done.
Optional scope restriction for a full key. Omitted or empty means
unrestricted, which is how every existing key behaves. Must be drawn
from the same read:<family> / write:<family> taxonomy as M2M
clients. Rejected on an ingest key, which never reaches the scope
chokepoint at all.
Optional lifetime in days. Omitted means the key never expires, which matches the Datadog model and is what every existing key does.
Responses
Section titled “ Responses ”Newly minted API key; the secret is only returned once
Response for create and rotate, the ONLY places a full secret ever appears. It is not stored and cannot be retrieved again.
object
One API key in list responses. Never contains the secret: after creation the secret exists only in the customer’s hands.
object
First 8 characters of the secret, kept in plaintext for display.
Last 4 characters of the secret, kept in plaintext for display.
What a customer API key is allowed to do.
Mirrors the Datadog split between an API key (telemetry push) and an application key (full API access), collapsed into one credential with a type so the ingest path and the management path can share a table.
Empty means unrestricted.
Lifecycle state of a key, derived rather than stored so it can never disagree with the timestamps.
The full secret. Shown exactly once; store it now.
Example
{ "api_key": { "key_type": "ingest", "status": "active" }}Invalid name, scopes or expiry, or key cap reached
Missing or invalid authentication
Caller is not an admin
Internal server error