{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/couchbase/main/json-schema/couchbase-api-key-create-request-schema.json",
  "title": "ApiKeyCreateRequest",
  "description": "Request to create an API key",
  "x-generated": "2026-10-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/couchbase-api-keys-api-openapi.yml#/components/schemas/ApiKeyCreateRequest",
  "type": "object",
  "required": [
    "name",
    "organizationRoles"
  ],
  "properties": {
    "name": {
      "type": "string",
      "description": "Name for the API key"
    },
    "description": {
      "type": "string",
      "description": "Description of the API key"
    },
    "expiry": {
      "type": "number",
      "description": "Expiry time in days (0 for no expiry)"
    },
    "organizationRoles": {
      "type": "array",
      "description": "Organization-level roles",
      "items": {
        "type": "string",
        "enum": [
          "organizationOwner",
          "organizationMember",
          "projectCreator"
        ]
      }
    },
    "resources": {
      "type": "array",
      "description": "Project-specific role assignments",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Project UUID"
          },
          "roles": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "projectOwner",
                "projectManager",
                "projectViewer",
                "projectDataReaderWriter",
                "projectDataReader"
              ]
            }
          }
        }
      }
    },
    "allowedCIDRs": {
      "type": "array",
      "description": "CIDRs allowed to use this API key",
      "items": {
        "type": "string"
      }
    }
  }
}