Skip to content
LogoLogo

Api key schema

See Management API schema for every domain, the endpoint and authentication.

Queries

apiKeys

Lists an organization's API keys, newest first. Revoked keys are left out. Scope: ORGANIZATION_API_KEYS_READ.

apiKeys(input: ApiKeysInput!): [ApiKey!]! @auth

Mutations

apiKeyCreate

Creates an API key and returns the full key, once. A blank name, no scopes, or a scope the caller does not hold or the key cannot carry returns VALIDATION_ERROR. Scope: ORGANIZATION_API_KEYS_CREATE.

apiKeyCreate(input: ApiKeyCreateInput!): ApiKeyCreatePayload! @auth(only: USER)

apiKeyRevoke

Revokes an API key, which then stops authenticating at once. Cannot be undone; an unknown or revoked key returns NOT_FOUND. Scope: ORGANIZATION_API_KEYS_DELETE.

apiKeyRevoke(input: ApiKeyRevokeInput!): Boolean! @auth

Types

ApiKey

"""
A credential for a server-to-server integration. It belongs to an organization, can belong to one
project, and carries scopes. The full key is returned only once, by `apiKeyCreate`.
"""
type ApiKey {
  """The ID of the API key."""
  id: ID!
  """The name of the API key."""
  name: String!
  """
  The first 8 and last 3 characters of the key, to tell keys apart. Safe to display.
  """
  keyPrefix: String!
  """
  The ID of the project the key belongs to. Null when the key covers the whole organization.
  """
  projectId: String
  """
  The name of the project the key belongs to. Null when the key covers the whole organization.
  """
  projectName: String
  """The ID of the user who created the key."""
  createdBy: ID!
  """The email address of the user who created the key."""
  createdByEmail: String!
  """When the key was created."""
  createdAt: String!
  """The scopes the key holds."""
  scopes: [Scope!]!
}

ApiKeyEdge

"""An API key in a page of results."""
type ApiKeyEdge {
  """The cursor of this edge."""
  cursor: String!
  """The API key."""
  node: ApiKey!
}

ApiKeyConnection

"""A page of API keys."""
type ApiKeyConnection {
  """The edges in this page."""
  edges: [ApiKeyEdge!]!
  """Where this page sits in the list."""
  pageInfo: PageInfo!
  """The total number of API keys."""
  totalCount: Int!
}

ApiKeyCreatePayload

"""
The result of `apiKeyCreate`. `apiKey` is the only place the full key appears; later reads return
`keyPrefix` only.
"""
type ApiKeyCreatePayload {
  """The full API key. Returned only here."""
  apiKey: String!
}

ApiKeysInput

"""The input of `apiKeys`."""
input ApiKeysInput {
  """The ID of the organization whose keys to list."""
  organizationId: ID!
}

ApiKeyCreateInput

"""The input of `apiKeyCreate`."""
input ApiKeyCreateInput {
  """The ID of the organization the key belongs to."""
  organizationId: ID!
  """The name of the key. Must not be blank."""
  name: String!
  """
  The ID of the project to restrict the key to. Null for a key that covers the whole organization.
  A project key is refused on any operation outside that project, organization-level ones included.
  """
  projectId: ID
  """
  The scopes the key holds. At least one, each held by the caller and assignable to an organization
  key, or to a project key when `projectId` is set.
  """
  scopes: [Scope!]!
}

ApiKeyRevokeInput

"""The input of `apiKeyRevoke`."""
input ApiKeyRevokeInput {
  """The ID of the API key to revoke."""
  keyId: ID!
  """Not read: the key's own organization applies."""
  organizationId: ID!
}