{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hypamoon-com/json-schema/hypamoon-com-collection-schema.json",
  "title": "Collection",
  "description": "A collection of JSON documents: the data layer of a project.",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hypamoon-com-openapi.json#/components/schemas/Collection",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "The id of the collection. Its name works in the path as well."
    },
    "name": {
      "type": "string",
      "description": "The name, unique in the project. A form posts to it by this name."
    },
    "description": {
      "type": [
        "string",
        "null"
      ],
      "description": "What the collection is for, or null."
    },
    "access": {
      "type": "object",
      "properties": {
        "public_write": {
          "type": "boolean",
          "description": "A form on an allowed origin may add documents, with the public token, a bot check and limits."
        },
        "public_read": {
          "type": "boolean",
          "description": "A page on an allowed origin may read the newest documents (data and created_at) with the public token."
        },
        "assistant_read": {
          "type": "boolean",
          "description": "The assistant gets the newest documents added through the API in its chat instructions."
        }
      },
      "required": [
        "public_write",
        "public_read",
        "assistant_read"
      ],
      "additionalProperties": false,
      "description": "Who may use the collection besides your API key. All false is private."
    },
    "triggers": {
      "type": "object",
      "properties": {
        "email_on_insert": {
          "type": "boolean",
          "description": "Every new document is emailed to the project's billing email address (live only)."
        },
        "webhook_on_insert": {
          "type": "boolean",
          "description": "Every new document sends the webhook document.created."
        }
      },
      "required": [
        "email_on_insert",
        "webhook_on_insert"
      ],
      "additionalProperties": false
    },
    "email_routing": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "to": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Where the email goes when no rule matches. Empty: the billing email address."
        },
        "rules": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "field": {
                "type": "string",
                "description": "A top-level field of the new document."
              },
              "equals": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ],
                "description": "The value that field must have."
              },
              "to": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Where the email goes when this rule matches."
              }
            },
            "required": [
              "field",
              "equals",
              "to"
            ],
            "additionalProperties": false
          },
          "description": "The first rule that matches decides where the email goes."
        },
        "recipients": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "email": {
                "type": "string",
                "description": "The address, in lowercase."
              },
              "status": {
                "type": "string",
                "enum": [
                  "confirmed",
                  "pending"
                ],
                "description": "pending: it gets nothing until someone clicks the link in the confirmation email."
              },
              "confirmed_by": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "billing_email",
                  "member",
                  "domain",
                  "link",
                  null
                ],
                "description": "Why it is confirmed: the billing email, a project member, a domain connected to the project, or the link. null while pending."
              },
              "confirmation_sent_at": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "When the last confirmation email was sent (ISO 8601), or null."
              }
            },
            "required": [
              "email",
              "status",
              "confirmed_by",
              "confirmation_sent_at"
            ],
            "additionalProperties": false
          },
          "description": "Every address in to and rules, with whether it may receive email."
        }
      },
      "required": [
        "to",
        "rules",
        "recipients"
      ],
      "additionalProperties": false,
      "description": "Where the email of email_on_insert goes. null: the billing email address."
    },
    "schema": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {},
      "description": "The JSON Schema every document must match, or null."
    },
    "personal_data": {
      "type": "boolean",
      "description": "true when the collection holds personal data: its schema has fields about people (see personal_data_fields), or it was imported from WordPress (form entries, orders, customers, users, reviews; those always stay private). An editor reads such a collection only when the owner allowed personal data for them."
    },
    "personal_data_fields": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The fields of the schema that are about a person: names like name, email, phone, address or birth date (also naam, e-mail, telefoon, contact_email), or format email. Empty without a schema."
    },
    "document_count": {
      "type": "integer",
      "description": "How many documents the collection has now."
    },
    "app_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "The app that created this collection from its own code; only that app (and its staging) reaches it. null: a collection of the project, closed to every app unless shared through app_access."
    },
    "app_access": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "app_id": {
            "type": "string",
            "description": "The app."
          },
          "app_name": {
            "type": "string",
            "description": "Its name."
          },
          "access": {
            "type": "string",
            "enum": [
              "read",
              "write"
            ],
            "description": "read: the app reads the collection and its documents; write: it may also add, change and delete documents."
          }
        },
        "required": [
          "app_id",
          "app_name",
          "access"
        ],
        "additionalProperties": false
      },
      "description": "The apps this collection of the project is shared with (set with app_access on update_collection). Not shown to the key of an app, and absent on a collection of an app."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the collection was created."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the collection last changed."
    },
    "test": {
      "type": "boolean",
      "description": "true for a collection of a test project."
    }
  },
  "required": [
    "id",
    "name",
    "description",
    "access",
    "triggers",
    "email_routing",
    "schema",
    "document_count",
    "created_at",
    "updated_at",
    "test"
  ],
  "additionalProperties": false
}