{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mandala-computer/json-schema/mandala-computer-api-key-schema.json",
  "title": "ApiKey",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mandala-computer-openapi.json#/components/schemas/ApiKey",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "`key-` and twelve hex characters. What an audit entry names as `apikey:<id>`."
    },
    "name": {
      "type": [
        "string",
        "null"
      ],
      "description": "Its label, up to 60 characters, or `null` when it was minted without one. For a hosted-MCP (OAuth) credential, which only `GET /whoami` answers, `Connected app: ` followed by the connected app’s name, up to 100 characters in all."
    },
    "prefix": {
      "type": "string",
      "description": "The first twelve characters of the key and an ellipsis, for recognising it. Not a secret. `oauth` for a hosted-MCP (OAuth) credential, as `GET /whoami` answers it."
    },
    "created_at": {
      "type": "string",
      "description": "RFC 3339 timestamp."
    },
    "last_used_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "RFC 3339 timestamp of its last authenticated request, or `null` until it has one."
    },
    "workspace_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "The workspace it is confined to, or `null` for the whole account."
    },
    "workspace_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "That workspace’s name, or `null` for an account-wide key."
    },
    "manage_keys": {
      "type": "boolean",
      "description": "Whether this key may use `/api-keys`. With it a key lists its holder’s keys; creating and revoking also need the holder to be a member or owner, so a viewer’s key can only list. Set only from the dashboard; no key can set it."
    },
    "minted_by_key_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "The id of the API key that minted this one over the API, or `null` for a key minted from the dashboard. Kept after that key is revoked."
    },
    "expires_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "When this key stops working, RFC 3339, or `null` for a key that works until it is revoked. Past it the key answers `401` with `reason: \"revoked\"` and stays listed, and counted against the account’s 1000 keys, until it is revoked; one expired for 30 days is revoked the next time a key is minted on its account. Nothing it opens outlives it: it cannot add SSH keys, create or change public URLs or webhooks (`403`), computers are answered to it without `vnc` (the desktop and terminal credentials are the computer’s own), it does not open a private public URL, and a browser session it opens must send `lifecycle_version: 2` with a `max_duration_seconds` within its remaining lifetime (`400` otherwise, a `{}` body included). What runs inside a computer is the computer’s own: a command it started keeps running after it expires."
    },
    "computer_ids": {
      "oneOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The computers this key is limited to, or `null` for every computer its scope holds. A limited key may call `GET /whoami`, `GET /computers` (which lists only these) and these computers’ own routes, except deleting, `PATCH`, `clone`, `move`, `workspace`, `PUT secrets`, `POST` and `DELETE credential-gateway` and the hosted agent (`agent`, `agent/runs`); reading a computer’s bound secrets and gateway credentials is allowed. Any other call is a `403`, and another computer’s routes a `404`."
        },
        {
          "type": "null"
        }
      ],
      "description": "The computers this key is limited to, or `null` for every computer its scope holds. A limited key may call `GET /whoami`, `GET /computers` (which lists only these) and these computers’ own routes, except deleting, `PATCH`, `clone`, `move`, `workspace`, `PUT secrets`, `POST` and `DELETE credential-gateway` and the hosted agent (`agent`, `agent/runs`); reading a computer’s bound secrets and gateway credentials is allowed. Any other call is a `403`, and another computer’s routes a `404`."
    }
  },
  "required": [
    "id",
    "name",
    "prefix",
    "created_at",
    "last_used_at",
    "workspace_id",
    "workspace_name",
    "manage_keys",
    "minted_by_key_id",
    "expires_at",
    "computer_ids"
  ]
}