{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/xipfax-com/json-schema/xipfax-com-document-added-schema.json",
  "title": "DocumentAdded",
  "description": "A document added to the draft, and where its bytes go.",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/xipfax-com-openapi.json#/components/schemas/DocumentAdded",
  "type": "object",
  "properties": {
    "document": {
      "$ref": "#/$defs/DraftDocument"
    },
    "upload": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "url": {
              "type": "string"
            },
            "headers": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            }
          },
          "required": [
            "url",
            "headers"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "Where to send its bytes: a PUT to `url` with these `headers`, within a few minutes, as many bytes as `size_bytes` says; then complete it. Null where XipFax fetched it from its link. In an answer given again for a repeated `Idempotency-Key`, a fresh link while the document still uploads, and null once it is ready or removed."
    }
  },
  "required": [
    "document",
    "upload"
  ],
  "$defs": {
    "DraftDocument": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The document."
        },
        "name": {
          "type": "string",
          "description": "Its name, as it was added."
        },
        "size_bytes": {
          "type": "integer",
          "description": "Its size."
        },
        "page_count": {
          "description": "Its pages, once XipFax has read it; null while it uploads.",
          "type": [
            "integer",
            "null"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "uploading",
            "ready"
          ],
          "description": "`uploading` until XipFax has read it back, then `ready`. An open set: read what you know."
        },
        "url": {
          "description": "A link that reads the document for a few minutes, once it is ready; null while it uploads, and in an answer given again for a repeated `Idempotency-Key`.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "name",
        "size_bytes",
        "page_count",
        "status",
        "url"
      ],
      "description": "A document of the draft, in its place in the fax."
    }
  }
}