{
  "openapi": "3.1.0",
  "info": {
    "title": "Invoice Flow API",
    "version": "1.1.0",
    "summary": "Read the supplier invoices, credit notes and receipts Invoice Flow has processed for a business.",
    "description": "The Invoice Flow API gives read access to a business's own documents: what was read from each supplier invoice, its line items, where it was sent (Xero, QuickBooks, WorkflowMax) and the original file.\n\nEvery key belongs to one business. No endpoint takes a business id, and another business's document is answered with 404, the same as one that doesn't exist.\n\nVersioning: the version is in the path (/v1). Within v1 we only add things (new endpoints, new fields, new status or type values): never rename or remove a field. Anything that would break an integration comes as /v2, with at least six months' notice.",
    "contact": {
      "name": "Invoice Flow developer support",
      "email": "support@goinvoiceflow.com",
      "url": "https://goinvoiceflow.com/developers"
    },
    "termsOfService": "https://goinvoiceflow.com/developers/api-terms"
  },
  "servers": [
    {
      "url": "https://jqrnxvdvcfrzamziofsb.supabase.co/functions/v1/ap-api/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Keys",
      "description": "Check a key."
    },
    {
      "name": "Status",
      "description": "Whether the API is up. No key needed."
    },
    {
      "name": "Documents",
      "description": "Supplier invoices, credit notes, receipts and statements, with their line items and files."
    },
    {
      "name": "Data partners",
      "description": "For approved data partners only (if_feed_ keys): the feed of documents that businesses chose to share with them."
    }
  ],
  "paths": {
    "/ping": {
      "get": {
        "operationId": "ping",
        "tags": [
          "Keys"
        ],
        "summary": "Check a key",
        "description": "Says which business (or partner) the key belongs to, its mode and scopes. A good first call.",
        "responses": {
          "200": {
            "description": "The key is valid.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Request-Id": {
                "$ref": "#/components/headers/Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ping"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/status": {
      "get": {
        "operationId": "getStatus",
        "tags": [
          "Status"
        ],
        "summary": "API status",
        "security": [],
        "description": "Whether the API and its database are answering. No key needed and not counted against any rate limit. Poll it at most once a minute.",
        "responses": {
          "200": {
            "description": "Up.",
            "headers": {
              "Request-Id": {
                "$ref": "#/components/headers/Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          },
          "503": {
            "description": "Not answering properly (`status` is degraded).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          }
        }
      }
    },
    "/documents": {
      "get": {
        "operationId": "listDocuments",
        "tags": [
          "Documents"
        ],
        "summary": "List documents",
        "description": "Newest first. With `updated_since`, documents changed at or after that time, oldest change first, which is the way to keep another system in step: store the time you last asked, and ask again from it. Pages are joined with `cursor`.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "How many to return, 1 to 100.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "The `next_cursor` from the previous page. Keep the other parameters the same.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Only documents with this status.",
            "schema": {
              "type": "string",
              "enum": [
                "reading",
                "to_process",
                "on_hold",
                "duplicate",
                "sending",
                "sent",
                "needs_checking",
                "send_failed",
                "failed",
                "split",
                "deleted"
              ]
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Only documents of this type.",
            "schema": {
              "type": "string",
              "enum": [
                "invoice",
                "credit_note",
                "receipt",
                "statement",
                "other"
              ]
            }
          },
          {
            "name": "updated_since",
            "in": "query",
            "description": "ISO 8601 date and time. Only documents changed at or after it, oldest change first.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-28T00:00:00Z"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of documents (without line items).",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Request-Id": {
                "$ref": "#/components/headers/Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/documents/{id}": {
      "get": {
        "operationId": "getDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Get a document",
        "description": "One document, with its line items.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The document's id (a UUID) or its number, like DOC-10123.",
            "schema": {
              "type": "string"
            },
            "example": "DOC-10123"
          }
        ],
        "responses": {
          "200": {
            "description": "The document.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Request-Id": {
                "$ref": "#/components/headers/Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/documents/{id}/lines": {
      "get": {
        "operationId": "listDocumentLines",
        "tags": [
          "Documents"
        ],
        "summary": "List a document's line items",
        "description": "In order. All of them in one page.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The document's id (a UUID) or its number, like DOC-10123.",
            "schema": {
              "type": "string"
            },
            "example": "DOC-10123"
          }
        ],
        "responses": {
          "200": {
            "description": "The line items.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Request-Id": {
                "$ref": "#/components/headers/Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LineItemList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/documents/{id}/file": {
      "get": {
        "operationId": "getDocumentFile",
        "tags": [
          "Documents"
        ],
        "summary": "Download the original file",
        "description": "A link to the original PDF or image, valid for 5 minutes. Ask again for a new one.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The document's id (a UUID) or its number, like DOC-10123.",
            "schema": {
              "type": "string"
            },
            "example": "DOC-10123"
          }
        ],
        "responses": {
          "200": {
            "description": "A download link.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Request-Id": {
                "$ref": "#/components/headers/Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/File"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/partner/businesses": {
      "get": {
        "operationId": "listPartnerBusinesses",
        "tags": [
          "Data partners"
        ],
        "summary": "Businesses sharing with you",
        "description": "Every business that chose to share with your organisation, including ones that stopped (`sharing` false).",
        "responses": {
          "200": {
            "description": "The businesses.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Request-Id": {
                "$ref": "#/components/headers/Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerBusinessList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/partner/feed": {
      "get": {
        "operationId": "partnerFeed",
        "tags": [
          "Data partners"
        ],
        "summary": "The sharing feed",
        "description": "Changes in order. Start with `after=0`, then pass `next_after` until `has_more` is false; keep the last `next_after` and carry on from it next time. `document` = add or replace by document_id; `document.removed` = delete your copy; `business.sharing_stopped` = the business stopped sharing: delete what you hold for it, as your agreement says.",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "description": "The `next_after` from the last page (0 to start).",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "1 to 500.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of the feed.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Request-Id": {
                "$ref": "#/components/headers/Request-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeedPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "if_live_… / if_test_… / if_feed_…",
        "description": "Send the key as `Authorization: Bearer <key>`. Business admins make keys in Invoice Flow: Settings → Integrations → API keys. Live keys (if_live_) read the business's real documents. Test keys (if_test_) come from the developer portal (goinvoiceflow.com/developers) straight away and only reach the sandbox: a made-up business with fixed documents in every status. Keep keys secret: never put one in a web page or an app people download."
      }
    },
    "headers": {
      "Request-Id": {
        "description": "Unique to this request. Quote it when you contact support.",
        "schema": {
          "type": "string"
        },
        "example": "req_3f9a1c0d5e7b2a4c6d8e0f12"
      },
      "X-RateLimit-Limit": {
        "description": "Requests allowed per minute for this key.",
        "schema": {
          "type": "integer"
        },
        "example": 120
      },
      "X-RateLimit-Remaining": {
        "description": "Requests left this minute.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Reset": {
        "description": "When the count starts again (Unix time, seconds).",
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "The key is missing, wrong or revoked (`invalid_api_key`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The key can't do this: `missing_scope`, `wrong_key_type` (a partner key on a business endpoint or the other way round) or `account_unavailable`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "No such document for this business (`not_found`), or it has no file (`no_file`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Invalid": {
        "description": "A parameter isn't valid. `code` says which, for example `invalid_limit` or `invalid_cursor`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests this minute (`rate_limited`). Wait for `Retry-After` seconds.",
        "headers": {
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/X-RateLimit-Limit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/X-RateLimit-Remaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/X-RateLimit-Reset"
          },
          "Request-Id": {
            "$ref": "#/components/headers/Request-Id"
          },
          "Retry-After": {
            "description": "Seconds to wait.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ServerError": {
        "description": "Something went wrong on our side (`server_error`). Safe to retry; if it keeps happening, send us the request_id.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "request_id"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable, machine-readable. Check this, not the message.",
                "example": "not_found"
              },
              "message": {
                "type": "string",
                "description": "Plain words for a person. May change."
              },
              "request_id": {
                "type": "string",
                "description": "The same as the Request-Id header."
              },
              "docs": {
                "type": "string",
                "description": "Where to read more."
              }
            }
          }
        }
      },
      "Ping": {
        "type": "object",
        "properties": {
          "object": {
            "const": "key"
          },
          "ok": {
            "const": true
          },
          "mode": {
            "type": "string",
            "description": "live or test.",
            "enum": [
              "live",
              "test"
            ]
          },
          "key": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "The name given when it was made."
              },
              "prefix": {
                "type": "string",
                "description": "The key's first characters."
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "example": [
                  "documents:read"
                ]
              }
            }
          },
          "business": {
            "type": [
              "object",
              "null"
            ],
            "description": "For a business key.",
            "properties": {
              "id": {
                "type": "string",
                "description": "The Invoice Flow business ID.",
                "example": "IF-7K3M9Q"
              },
              "name": {
                "type": "string",
                "description": "The business's name."
              },
              "country": {
                "type": "string",
                "description": "AU, NZ or GB."
              },
              "sandbox": {
                "type": "boolean",
                "description": "True for the sandbox (test keys): made-up documents."
              }
            }
          },
          "app": {
            "type": [
              "object",
              "null"
            ],
            "description": "For a developer portal key: the app it belongs to.",
            "properties": {
              "name": {
                "type": "string",
                "description": "The app's name."
              }
            }
          },
          "partner": {
            "type": [
              "object",
              "null"
            ],
            "description": "For a data partner key.",
            "properties": {
              "name": {
                "type": "string",
                "description": "Your organisation."
              }
            }
          }
        }
      },
      "Status": {
        "type": "object",
        "properties": {
          "object": {
            "const": "status"
          },
          "status": {
            "type": "string",
            "description": "ok, or degraded when the database isn't answering.",
            "enum": [
              "ok",
              "degraded"
            ]
          },
          "version": {
            "type": "string",
            "description": "The API version.",
            "example": "v1"
          },
          "checked_at": {
            "type": "string",
            "description": "When this was checked.",
            "format": "date-time"
          },
          "database_ms": {
            "type": [
              "integer",
              "null"
            ],
            "description": "How long the database took to answer, in milliseconds."
          }
        }
      },
      "DocumentList": {
        "type": "object",
        "properties": {
          "object": {
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentSummary"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "True when there's another page."
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass as `cursor` for the next page."
          }
        }
      },
      "DocumentSummary": {
        "type": "object",
        "description": "A document as listed (no line items).",
        "properties": {
          "object": {
            "const": "document"
          },
          "id": {
            "type": "string",
            "description": "Never changes.",
            "format": "uuid"
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Invoice Flow's document number, unique across Invoice Flow.",
            "example": "DOC-10123"
          },
          "type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null while it's still being read.",
            "enum": [
              "invoice",
              "credit_note",
              "receipt",
              "statement",
              "other",
              null
            ]
          },
          "status": {
            "type": "string",
            "description": "Where it is in Invoice Flow:\n- reading: being read\n- to_process: read, waiting for a person to check and send it\n- on_hold: put on hold\n- duplicate: stopped as a duplicate\n- sending: on its way to the accounting system\n- sent: in the accounting system (and job system)\n- needs_checking: sent, but something needs a look (for example the PDF didn't reach the job)\n- send_failed: the accounting system refused it (see problem)\n- failed: couldn't be read (see problem)\n- split: a PDF that held several invoices; each is its own document (split_from)\n- deleted: deleted in Invoice Flow\nNew values may be added within v1.",
            "enum": [
              "reading",
              "to_process",
              "on_hold",
              "duplicate",
              "sending",
              "sent",
              "needs_checking",
              "send_failed",
              "failed",
              "split",
              "deleted"
            ]
          },
          "received_at": {
            "type": "string",
            "description": "When it arrived.",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "description": "When anything about it last changed.",
            "format": "date-time"
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "How it arrived, for example email or upload."
          },
          "file": {
            "type": "object",
            "properties": {
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The file's name."
              },
              "content_type": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "For example application/pdf."
              },
              "pages": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Pages in the file."
              }
            }
          },
          "supplier": {
            "type": "object",
            "properties": {
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The supplier, as matched in the accounting system (else as printed)."
              },
              "printed_name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The name printed on the document."
              },
              "tax_number": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The supplier's ABN, NZ GST number or UK VAT number, as printed."
              }
            }
          },
          "invoice_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "As printed."
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "Purchase order or reference, as printed."
          },
          "invoice_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Date on the document.",
            "format": "date"
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Due date.",
            "format": "date"
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "ISO 4217 code.",
            "example": "AUD"
          },
          "amounts_are": {
            "type": [
              "string",
              "null"
            ],
            "description": "Whether line amounts include tax.",
            "enum": [
              "exclusive",
              "inclusive",
              "no_tax",
              null
            ]
          },
          "subtotal": {
            "type": [
              "number",
              "null"
            ],
            "description": "Total before tax."
          },
          "tax": {
            "type": [
              "number",
              "null"
            ],
            "description": "GST / VAT."
          },
          "total": {
            "type": [
              "number",
              "null"
            ],
            "description": "Total including tax. Credit notes are positive."
          },
          "confidence": {
            "type": [
              "number",
              "null"
            ],
            "description": "How sure the reading was, 0 to 1.",
            "minimum": 0,
            "maximum": 1
          },
          "unsure_fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Fields the reading was unsure of, for example due_date."
          },
          "sent_to": {
            "type": [
              "object",
              "null"
            ],
            "description": "Set once sent.",
            "properties": {
              "accounting": {
                "type": "object",
                "properties": {
                  "system": {
                    "type": "string",
                    "description": "xero or quickbooks.",
                    "enum": [
                      "xero",
                      "quickbooks"
                    ]
                  },
                  "bill_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The bill's id in that system (Xero InvoiceID, QuickBooks Bill or VendorCredit Id)."
                  },
                  "status": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Its status there when sent, in that system's words."
                  },
                  "organisation": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The organisation or company it went to."
                  }
                }
              },
              "job_system": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "workflowmax when job costs were sent too.",
                "enum": [
                  "workflowmax",
                  null
                ]
              },
              "sent_at": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "When it was sent.",
                "format": "date-time"
              }
            }
          },
          "problem": {
            "type": [
              "string",
              "null"
            ],
            "description": "What went wrong, in plain words (failed, send_failed and needs_checking)."
          },
          "split_from": {
            "type": [
              "string",
              "null"
            ],
            "description": "For an invoice split out of a PDF that held several: that PDF's document id.",
            "format": "uuid"
          },
          "deleted_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was deleted.",
            "format": "date-time"
          }
        }
      },
      "Document": {
        "allOf": [
          {
            "$ref": "#/components/schemas/DocumentSummary"
          },
          {
            "type": "object",
            "properties": {
              "lines": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/LineItem"
                }
              }
            }
          }
        ]
      },
      "LineItemList": {
        "type": "object",
        "properties": {
          "object": {
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LineItem"
            }
          },
          "has_more": {
            "const": false
          },
          "next_cursor": {
            "type": "null"
          }
        }
      },
      "LineItem": {
        "type": "object",
        "properties": {
          "object": {
            "const": "line_item"
          },
          "id": {
            "type": "string",
            "description": "The line's id.",
            "format": "uuid"
          },
          "position": {
            "type": [
              "integer",
              "null"
            ],
            "description": "1, 2, 3… in order."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "As sent (or as read, before sending)."
          },
          "quantity": {
            "type": [
              "number",
              "null"
            ],
            "description": "Quantity."
          },
          "unit_price": {
            "type": [
              "number",
              "null"
            ],
            "description": "Price per unit after any discount."
          },
          "list_price": {
            "type": [
              "number",
              "null"
            ],
            "description": "The printed price before a line discount."
          },
          "discount_pct": {
            "type": [
              "number",
              "null"
            ],
            "description": "Line discount, percent."
          },
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "description": "Line amount (with or without tax, see amounts_are)."
          },
          "tax_amount": {
            "type": [
              "number",
              "null"
            ],
            "description": "Tax on the line."
          },
          "account_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "The account chosen (QuickBooks: the account's id)."
          },
          "tax_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "The tax rate chosen, as the accounting system names it."
          },
          "product_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "The product or item code chosen."
          },
          "tracking": {
            "type": "array",
            "description": "Xero tracking, or QuickBooks class and location.",
            "items": {
              "type": "object",
              "properties": {
                "category": {
                  "type": "string",
                  "description": "The category."
                },
                "option": {
                  "type": "string",
                  "description": "The option."
                }
              }
            }
          },
          "job": {
            "type": [
              "object",
              "null"
            ],
            "description": "The WorkflowMax job.",
            "properties": {
              "number": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Job number."
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Job name."
              }
            }
          },
          "cost_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "The WorkflowMax cost code."
          },
          "phase": {
            "type": [
              "string",
              "null"
            ],
            "description": "The WorkflowMax phase."
          },
          "billable_amount": {
            "type": [
              "number",
              "null"
            ],
            "description": "The billable amount with markup (WorkflowMax)."
          }
        }
      },
      "File": {
        "type": "object",
        "properties": {
          "object": {
            "const": "file"
          },
          "document_id": {
            "type": "string",
            "description": "The document.",
            "format": "uuid"
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "File name."
          },
          "content_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "MIME type."
          },
          "url": {
            "type": "string",
            "description": "Download link.",
            "format": "uri"
          },
          "expires_at": {
            "type": "string",
            "description": "The link stops working at this time.",
            "format": "date-time"
          },
          "document_status": {
            "type": "string",
            "description": "The document's status.",
            "enum": [
              "reading",
              "to_process",
              "on_hold",
              "duplicate",
              "sending",
              "sent",
              "needs_checking",
              "send_failed",
              "failed",
              "split",
              "deleted"
            ]
          }
        }
      },
      "PartnerBusinessList": {
        "type": "object",
        "properties": {
          "object": {
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "business_id": {
                  "type": "string",
                  "description": "The Invoice Flow business ID.",
                  "example": "IF-7K3M9Q"
                },
                "member_ref": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Your membership number, as the business typed it."
                },
                "area": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "The business's own words for its area."
                },
                "country": {
                  "type": "string",
                  "description": "AU, NZ or GB."
                },
                "sharing": {
                  "type": "boolean",
                  "description": "False once it stopped."
                },
                "shared_from": {
                  "type": "string",
                  "description": "Documents dated from this day are shared.",
                  "format": "date"
                },
                "since": {
                  "type": "string",
                  "description": "When it started sharing.",
                  "format": "date-time"
                },
                "stopped_at": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "When it stopped.",
                  "format": "date-time"
                }
              }
            }
          },
          "has_more": {
            "const": false
          },
          "next_cursor": {
            "type": "null"
          }
        }
      },
      "FeedPage": {
        "type": "object",
        "properties": {
          "object": {
            "const": "feed_page"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "seq": {
                  "type": "integer",
                  "description": "Order of the change."
                },
                "type": {
                  "type": "string",
                  "description": "What happened.",
                  "enum": [
                    "document",
                    "document.removed",
                    "business.sharing_stopped"
                  ]
                },
                "at": {
                  "type": "string",
                  "description": "When.",
                  "format": "date-time"
                },
                "business_id": {
                  "type": "string",
                  "description": "The Invoice Flow business ID."
                },
                "document_id": {
                  "type": "string",
                  "description": "The document (not on business.sharing_stopped).",
                  "format": "uuid"
                },
                "document": {
                  "type": "object",
                  "description": "On type document: the supplier (name, tax number), invoice number, dates, currency, totals and lines (product_code, description, quantity, unit_price, net_unit_price, discount_pct, amount, tax, pack_size, pack_unit). Never names, addresses, bank details, people or files."
                }
              }
            }
          },
          "next_after": {
            "type": "integer",
            "description": "Pass as `after` next time."
          },
          "has_more": {
            "type": "boolean",
            "description": "True when there's more now."
          }
        }
      }
    }
  }
}