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
projectId
Unique identifier (Nano ID) of the project to get or create an API key for
Headers
x-api-key
Response
Returned an existing API key. The project already had at least one API key, so no new key was created.
id
Database record identifier for the API key
name
Name assigned to help identify the key’s purpose. For auto-generated keys, this will be a random name.
key
The API key string value that should be included in API requests. This value is only shown once.
created_at
UTC timestamp indicating when the API key was created
last_used_at
UTC timestamp indicating when the API key was last used for authentication. Will be null for newly created keys.