{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/onclarity-com/json-schema/onclarity-com-create-collection-request-schema.json",
  "title": "CreateCollectionRequest",
  "description": "User-API request to create a collection. The caller becomes the owning client\n(``owner_id``) — so they, and only they, may later delete it. ``project_id`` comes\nfrom the request context, never from the body.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/onclarity-com-agent-store-api-openapi.yml#/components/schemas/CreateCollectionRequest",
  "properties": {
    "slug": {
      "type": "string",
      "title": "Slug",
      "description": "Kebab-case slug, unique per project."
    },
    "title": {
      "type": "string",
      "title": "Title",
      "description": "Human title."
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Description",
      "description": "Optional description."
    },
    "json_schema": {
      "additionalProperties": true,
      "type": "object",
      "title": "Json Schema",
      "description": "JSON Schema of a record; a property's 'title' becomes its UI label."
    },
    "indexes": {
      "items": {
        "$ref": "#/$defs/IndexSpec"
      },
      "type": "array",
      "title": "Indexes",
      "description": "Indexes for the dynamic table (btree, scalar fields)."
    },
    "ticket_link_field": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ticket Link Field",
      "description": "Field whose value is a ticket unique_id (text or integer field); it makes the collection's other fields available as ticket filters. Omit to auto-link a field named 'ticket_id' / 'unique_id' when present (each joins the same-named ticket field: ticket_id is the source system's id, unique_id the index id); send null to stay unlinked. Indexing it is recommended."
    },
    "ticket_link_es_field": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ticket Link Es Field",
      "description": "ES ticket field the link values are matched against (must be exact-match / keyword). Omit for unique_id. E.g. link_field 'handle' + es_field 'user_name' joins a record to every ticket by that author."
    }
  },
  "type": "object",
  "required": [
    "slug",
    "title",
    "json_schema"
  ],
  "$defs": {
    "IndexSpec": {
      "properties": {
        "fields": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Fields",
          "description": "Schema fields the index covers (1..5)."
        },
        "unique": {
          "type": "boolean",
          "title": "Unique",
          "description": "Create as a UNIQUE index.",
          "default": false
        }
      },
      "type": "object",
      "required": [
        "fields"
      ],
      "title": "IndexSpec",
      "description": "One requested index over the collection's dynamic table (btree, scalar fields)."
    }
  }
}