Skip to main content
POST
Update an existing API key by ID

Authorizations

Authorization
string
header
required

Personal API key sent as a bearer token.

Body

application/json
keyId
string
required

The id of the Api Key

configId
string

The configuration ID to use for the API key lookup. If not provided, the default configuration will be used.

userId
string

The id of the user which the api key belongs to. server-only. Eg: "some-user-id"

name
string

The name of the key

enabled
boolean

Whether the Api Key is enabled or not

remaining
number

The number of remaining requests

refillAmount
number

The refill amount

refillInterval
number

The refill interval

metadata
any
expiresIn
number | null

Expiration time of the Api Key in seconds

rateLimitEnabled
boolean

Whether the key has rate limiting enabled.

rateLimitTimeWindow
number

The duration in milliseconds where each request is counted. server-only. Eg: 1000

rateLimitMax
number

Maximum amount of requests allowed within a window. Once the maxRequests is reached, the request will be rejected until the timeWindow has passed, at which point the timeWindow will be reset. server-only. Eg: 100

permissions
object | null

Update the permissions on the API Key. server-only.

Response

API key updated successfully

id
string
required

ID

userId
string
required

The owner of the user id

enabled
boolean
default:true
required

Sets if key is enabled or disabled

rateLimitEnabled
boolean
required

Whether the key has rate limiting enabled

requestCount
number
required

The number of requests made within the rate limit time window

createdAt
string<date-time>
required

created at

updatedAt
string<date-time>
required

updated at

name
string | null

The name of the key

start
string | null

Shows the first few characters of the API key, including the prefix. This allows you to show those few characters in the UI to make it easier for users to identify the API key.

prefix
string | null

The API Key prefix. Stored as plain text.

refillInterval
number | null

The interval in milliseconds between refills of the remaining count. Example: 3600000 // refill every hour (3600000ms = 1h)

refillAmount
number | null

The amount to refill

lastRefillAt
string<date-time> | null

The last refill date

rateLimitTimeWindow
number | null

The duration in milliseconds

rateLimitMax
number | null

Maximum amount of requests allowed within a window

remaining
number | null

Remaining requests (every time api key is used this should updated and should be updated on refill as well)

lastRequest
string<date-time> | null

When last request occurred

expiresAt
string<date-time> | null

Expiry date of a key

metadata
object | null

Extra metadata about the apiKey

permissions
string | null

Permissions for the api key (stored as JSON string)