Create API key

createApiKey(input: CreateApiKeyInput!): CreateApiKeyPayload!

Arguments

ArgumentTypeRequired
inputCreateApiKeyInput!Yes

Input fields

input

CreateApiKeyInput

FieldTypeRequiredDescription
projectReferenceStringNoProject ID or slug. Creating a project-scoped key requires project.api_keys.manage. Omit for a user-level key; a project-scoped API-key caller retains its enforced project when this field is omitted.
nameString!Yes
scopes[String!]No
expiresAtStringNo

Response

Returns CreateApiKeyPayload!. Open the type for its fields and nested types.

FieldType
idID!
projectIdID
userIdID!
nameString!
keyString!
keyPrefixString!
expiresAtString
createdAtString!

All fields of CreateApiKeyPayload.

Types marked with ! cannot be null. Lists use [Type] notation. The type index lists all published input and response types.

Example

graphql
mutation CreateAPIKey($input: CreateApiKeyInput!) {
  createApiKey(input: $input) {
    id
    projectId
    name
    createdAt
    expiresAt
  }
}
json
{
  "input": {
    "projectReference": "00000000-0000-4000-8000-000000000001",
    "name": "example"
  }
}