Create Dataset Api Key
const url = 'https://example.com/datasets/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/api-keys';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"example","expires_at":"2026-04-15T12:00:00Z","scope":"dataset_write"}'};
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://example.com/datasets/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/api-keys \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "example", "expires_at": "2026-04-15T12:00:00Z", "scope": "dataset_write" }'Create a key that reaches only this dataset’s features.
A dataset_write key, the default, authenticates the dataset’s feature
routes and OGC API Features items. A dataset_append key authenticates
only POST /datasets/{dataset_id}/features/, so it can add features but
not read, change or delete them. Either is treated as an invalid key
everywhere else. The key acts as the caller, so the caller’s own access
to the dataset still applies to every request it makes. Its feature
writes go through even when the instance has dataset editing switched
off. It must expire within 365 days. Requires write access to the
dataset, the edit_metadata permission the feature writes need, and a
signed-in session. A dataset that can’t take feature edits (no feature
table or no geometry column) gets 422. A dataset holds at most 100 keys
that aren’t revoked, expired ones included; minting past that gets 409
until one is revoked. The raw key is returned only in this response.
Authorizations
Section titled “ Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”Request Bodyrequired
Section titled “ Request Bodyrequired ”object
Human-readable label for the API key
Expiry timestamp (RFC 3339, timezone-aware), in the future and at most 365 days away. Expired keys stop authenticating.
‘dataset_write’ reads and writes the dataset’s features. ‘dataset_append’ only creates features, one or a FeatureCollection per request, and can’t read, change or delete them.
Responses
Section titled “ Responses ”Successful Response
object
The API key secret (shown only once)
Non-secret key identifier (prefix and last four characters)
Privilege scope: ‘full’, ‘read_only’, ‘dataset_write’ (reads and writes the features of the dataset in dataset_id, and nothing else), or ‘dataset_append’ (only creates features in that dataset)
Example generated
{ "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "key": "example", "fingerprint": "example", "name": "example", "expires_at": "2026-04-15T12:00:00Z", "scope": "example", "dataset_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "created_at": "2026-04-15T12:00:00Z"}Bad request — invalid payload
Unauthorized — missing or invalid credentials
Forbidden — caller lacks write access
Not found
Conflict — resource state prevents the operation
Validation error
Too many requests — retry after the advertised interval
Headers
Section titled “ Headers ”Seconds until the request may be retried
Internal server error
Service unavailable — the database could not serve the request