{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/tokencanopy-com/json-schema/tokencanopy-com-grant-create-in-schema.json",
  "title": "GrantCreateIn",
  "description": "POST /v0/drives/{id}/grants body.",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/tokencanopy-com-openapi.json#/components/schemas/GrantCreateIn",
  "properties": {
    "principal_type": {
      "type": "string",
      "enum": [
        "agent",
        "user",
        "service",
        "workspace",
        "public"
      ],
      "title": "Principal Type"
    },
    "principal_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Principal Id",
      "description": "Required for `agent`, `user`, `service`, and `workspace`; omitted only for `public`. For `agent`, `user`, and `service` it is checked against that type's id prefix (`tcagt_` / `tcusr_` / `tcsvc_`) and a mismatch is `422 VALIDATION_ERROR`. The prefix is all AgentDrive asserts: these ids are minted by Hub, so their full shape is not AgentDrive's to enforce, and a well-formed id naming a principal that does not exist — or belongs to another workspace — is accepted here and simply never matches a token. The rule is conditional on `principal_type`, so it is enforced at the boundary rather than expressible as one JSON Schema `pattern`."
    },
    "resource_type": {
      "type": "string",
      "enum": [
        "drive",
        "folder",
        "artifact"
      ],
      "title": "Resource Type"
    },
    "resource_id": {
      "type": "string",
      "minLength": 1,
      "title": "Resource Id"
    },
    "role": {
      "type": "string",
      "enum": [
        "viewer",
        "editor",
        "manager"
      ],
      "title": "Role"
    },
    "expires_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Expires At"
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "principal_type",
    "resource_type",
    "resource_id",
    "role"
  ]
}