Skip to content

API Keys ​

Create API keys to authenticate your requests. You can rename, rotate, and revoke keys at any time.

MethodPathDescription
GET/v1/store/keysList API keys
POST/v1/store/keysCreate an API key
POST/v1/store/keys/{id}/rollRoll (rotate) an API key
POST/v1/store/keys/{id}/revokeRevoke an API key
PATCH/v1/store/keys/{id}/nameRename an API key
PATCH/v1/store/keys/{id}/permissionsUpdate API key permissions

List API keys

GET /v1/store/keys

Returns all API keys for the store, including revoked keys. Never returns plaintext or hashes.

Request

curl https://api.hydrajs.dev/v1/store/keys \
  -H "Authorization: Bearer sk_YOUR_KEY"

Response 200

{
	"data": []
}

Create an API key

POST /v1/store/keys

Creates a new API key. Optionally restrict permissions to specific resources. The plaintext key is returned once in the response and cannot be retrieved again.

Request body

FieldTypeRequiredDescription
typestringYes Values: secret, publishable
namestringNo
permissionsobject | nullNoResource permissions. Null or omitted = full access (unrestricted).

Request

curl -X POST https://api.hydrajs.dev/v1/store/keys \
  -H "Authorization: Bearer sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "secret"
  }'

Response 201

{
	"data": {}
}

Rename an API key

PATCH /v1/store/keys/{id}/name

Updates the display name of an active API key. Pass null to clear the name.

Path parameters

ParameterTypeDescription
idstring

Request body

FieldTypeRequiredDescription
namestring | nullYesDisplay name for the key. Null to clear.

Request

curl -X PATCH https://api.hydrajs.dev/v1/store/keys/:id/name \
  -H "Authorization: Bearer sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Storefront"
  }'

Response 200

{
	"data": {}
}

Update API key permissions

PATCH /v1/store/keys/{id}/permissions

Sets the resource permissions for an API key. Pass null to grant full access (unrestricted). Only active keys can be updated.

Path parameters

ParameterTypeDescription
idstring

Request body

FieldTypeRequiredDescription
permissionsobject | nullYesResource permissions. Null = full access (unrestricted).

Request

curl -X PATCH https://api.hydrajs.dev/v1/store/keys/:id/permissions \
  -H "Authorization: Bearer sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "permissions": "string_value"
  }'

Response 200

{
	"data": {}
}

Roll (rotate) an API key

POST /v1/store/keys/{id}/roll

Deactivates the target key and generates a new key with the same type and mode. Optionally keeps the old key active for a grace period (0–168 hours). The new plaintext key is returned once.

Path parameters

ParameterTypeDescription
idstring

Request body

FieldTypeRequiredDescription
grace_period_hoursintegerNoHours to keep old key active (0–168). Defaults to 0 (immediate deactivation).
permissionsobject | nullNoPermissions for the new key. Omit to inherit from the old key.

Request

curl -X POST https://api.hydrajs.dev/v1/store/keys/:id/roll \
  -H "Authorization: Bearer sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "grace_period_hours": 24,
    "permissions": "string_value"
  }'

Response 201

{
	"data": {}
}

Revoke an API key

POST /v1/store/keys/{id}/revoke

Permanently deactivates an API key. The key row is preserved for audit trail.

Path parameters

ParameterTypeDescription
idstring

Request

curl -X POST https://api.hydrajs.dev/v1/store/keys/:id/revoke \
  -H "Authorization: Bearer sk_YOUR_KEY"

Response 200

{
	"data": {}
}