{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/groundmail-dev/json-schema/groundmail-dev-create-api-key-request-schema.json",
  "title": "CreateApiKeyRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/groundmail-dev-api-keys-api-openapi.yml#/components/schemas/CreateApiKeyRequest",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "scopes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ApiScope"
      },
      "description": "What the key may do, e.g. `[\"emails:send\"]` (send only) or `[\"emails:read\", \"domains:read\", \"account:read\"]` (read only). Takes precedence over `scope`.\n"
    },
    "allowed_domains": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Verified domains the key may send from. Needs `emails:send` and cannot be combined with `full`. Sends from other domains get 403 `domain_not_allowed`.\n"
    },
    "scope": {
      "type": "string",
      "enum": [
        "full",
        "sending"
      ],
      "default": "full",
      "description": "Legacy. `sending` means `emails:send` + `emails:read`."
    },
    "test": {
      "type": "boolean",
      "default": false,
      "description": "Create a test key (`gm_test_…`). It has the same scopes and checks as a live key, but its sends are never delivered: they get simulated events and webhooks and do not count toward plan limits, the sending ramp, stats or billing.\n"
    },
    "tenant": {
      "type": "string",
      "description": "Limit the key to one tenant (its `external_id` or `id`). The key sends only as that tenant (naming another gets 403 `forbidden`), sees and manages only that tenant's emails, domains and suppressions, and can read its own tenant (`GET /tenants/{id}`, `/stats`, `/domains`). Every other endpoint (webhooks, templates, received email, deliverability, events, API keys, other tenants, account settings) answers 403 `forbidden`. With a tenant, `allowed_domains` may be combined with `full`. Deleting the tenant revokes its keys.\n"
    }
  },
  "$defs": {
    "ApiScope": {
      "type": "string",
      "description": "A scope for API keys and OAuth tokens. `full` grants everything.",
      "enum": [
        "full",
        "emails:send",
        "emails:read",
        "domains:read",
        "domains:write",
        "webhooks:write",
        "templates:write",
        "suppressions:write",
        "account:read"
      ]
    }
  }
}