Get or create project API key

Retrieves an existing API key for the project or creates a new one if none exists. This endpoint is useful for ensuring a project always has at least one API key without the risk of creating duplicates. If an API key already exists, it returns the existing key. If no API keys exist for the project, it creates a new one with an automatically generated name.

Path parameters

projectIdstringRequired

Unique identifier (Nano ID) of the project to get or create an API key for

Headers

x-api-keystringRequired

Response

Returned an existing API key. The project already had at least one API key, so no new key was created.
idstring
Database record identifier for the API key
namestring

Name assigned to help identify the key’s purpose. For auto-generated keys, this will be a random name.

keystring
The API key string value that should be included in API requests. This value is only shown once.
created_atdatetime
UTC timestamp indicating when the API key was created
last_used_atdatetime or null
UTC timestamp indicating when the API key was last used for authentication. Will be null for newly created keys.

Errors