{
    "openapi": "3.1.0",
    "info": {
        "title": "QaydTech API",
        "version": "1.0.0",
        "description": "A REST API over HTTPS that speaks JSON. Each business has its own address and creates its own keys."
    },
    "servers": [
        {
            "url": "https://{workspace}.qaydtech.com/api/v1",
            "variables": {
                "workspace": {
                    "default": "your-business",
                    "description": "Your workspace subdomain"
                }
            }
        }
    ],
    "security": [
        {
            "bearer": []
        }
    ],
    "paths": {
        "/me": {
            "get": {
                "operationId": "me",
                "tags": [
                    "reference"
                ],
                "summary": "Key and usage",
                "description": "The key in use, its type and permissions, the business, the user the key acts as, and this month\u2019s requests against the plan\u2019s limit. Handy to test the connection.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "business": {
                                            "name": "\u0645\u0624\u0633\u0633\u0629 \u0627\u0644\u0646\u062e\u0628\u0629",
                                            "host": "your-business.qaydtech.com"
                                        },
                                        "key": {
                                            "name": "\u0645\u062a\u062c\u0631 \u0633\u0644\u0629",
                                            "mode": "live",
                                            "prefix": "a1b2c3d4e5f6",
                                            "scopes": [
                                                "invoices.write",
                                                "customers.write"
                                            ],
                                            "expires_at": null
                                        },
                                        "acting_as": {
                                            "id": 1,
                                            "name": "\u0633\u0627\u0631\u0629 \u0627\u0644\u0639\u062a\u064a\u0628\u064a"
                                        },
                                        "usage": {
                                            "month": "2026-11",
                                            "requests": 1240,
                                            "limit": 50000
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/taxes": {
            "get": {
                "operationId": "taxes",
                "tags": [
                    "reference"
                ],
                "summary": "Tax codes",
                "description": "The available taxes by code. Put the code in an invoice line\u2019s tax field.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "code": "standard",
                                            "name": "\u0627\u0644\u0636\u0631\u064a\u0628\u0629 \u0627\u0644\u0623\u0633\u0627\u0633\u064a\u0629",
                                            "category": "S",
                                            "rate": "15.00"
                                        },
                                        {
                                            "code": "zero",
                                            "name": "\u0646\u0633\u0628\u0629 \u0635\u0641\u0631\u064a\u0629",
                                            "category": "Z",
                                            "rate": "0.00"
                                        },
                                        {
                                            "code": "exempt",
                                            "name": "\u0645\u0639\u0641\u0627\u0629",
                                            "category": "E",
                                            "rate": "0.00"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/regions": {
            "get": {
                "operationId": "regions",
                "tags": [
                    "reference"
                ],
                "summary": "Regions",
                "description": "The regions of Saudi Arabia by number.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 1,
                                            "name": "\u0645\u0646\u0637\u0642\u0629 \u0627\u0644\u0631\u064a\u0627\u0636"
                                        },
                                        {
                                            "id": 2,
                                            "name": "\u0645\u0646\u0637\u0642\u0629 \u0645\u0643\u0629 \u0627\u0644\u0645\u0643\u0631\u0645\u0629"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/cities": {
            "get": {
                "operationId": "cities",
                "tags": [
                    "reference"
                ],
                "summary": "Cities",
                "description": "Cities by number, by region or by name. The city number goes in a customer\u2019s address.city_id.",
                "parameters": [
                    {
                        "name": "region_id",
                        "in": "query",
                        "description": "The region number from GET /regions.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "description": "Text to search for.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "\u0627\u0644\u0631\u064a\u0627\u0636"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 3,
                                            "region_id": 1,
                                            "name": "\u0627\u0644\u0631\u064a\u0627\u0636"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/branches": {
            "get": {
                "operationId": "branches",
                "tags": [
                    "reference"
                ],
                "summary": "Branches",
                "description": "The branches the user the key acts as may work in.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 1,
                                            "code": "B01",
                                            "name": "\u0627\u0644\u0641\u0631\u0639 \u0627\u0644\u0631\u0626\u064a\u0633\u064a",
                                            "is_main": true
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/payment-accounts": {
            "get": {
                "operationId": "paymentAccounts",
                "tags": [
                    "reference"
                ],
                "summary": "Receiving accounts",
                "description": "The ways of paying, the cash boxes and bank accounts money is received into, and the default account for each way when none is named.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "methods": [
                                            "cash",
                                            "bank_transfer",
                                            "card",
                                            "cheque"
                                        ],
                                        "accounts": [
                                            {
                                                "id": 10,
                                                "code": "11101",
                                                "name": "11101 \u2014 \u0627\u0644\u0635\u0646\u062f\u0648\u0642"
                                            },
                                            {
                                                "id": 12,
                                                "code": "11103",
                                                "name": "11103 \u2014 \u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                            }
                                        ],
                                        "defaults": {
                                            "cash": 10,
                                            "bank_transfer": 12,
                                            "card": 12,
                                            "cheque": 12
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/warehouses": {
            "get": {
                "operationId": "warehouses",
                "tags": [
                    "reference"
                ],
                "summary": "Warehouses",
                "description": "Active warehouses. The number goes in an invoice\u2019s warehouse_id.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 1,
                                            "code": "W01",
                                            "name": "\u0627\u0644\u0645\u0633\u062a\u0648\u062f\u0639 \u0627\u0644\u0631\u0626\u064a\u0633\u064a",
                                            "branch_id": 1,
                                            "is_main": true
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/customers": {
            "get": {
                "operationId": "listCustomers",
                "tags": [
                    "customers"
                ],
                "summary": "List customers",
                "description": "Customers page by page, searched by name, code, VAT number or phone, filtered by type, status and last change (to sync only what changed).\n\nScope: `customers.read`",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "description": "Text to search for.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "\u0627\u0644\u0646\u062e\u0628\u0629"
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "description": "The type: individual or business for a customer; product or service for an item; asset, liability, equity, revenue or expense for an account.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "business"
                    },
                    {
                        "name": "active",
                        "in": "query",
                        "description": "true for active only, false for stopped only.",
                        "schema": {
                            "type": "boolean"
                        },
                        "example": true
                    },
                    {
                        "name": "updated_since",
                        "in": "query",
                        "description": "Changed since this date or time (ISO 8601).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-01T00:00:00+03:00"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Customer"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 42,
                                            "code": "C-0042",
                                            "type": "business",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629",
                                            "name_en": "Al Nokhba Trading Co.",
                                            "vat_number": "310123456700003",
                                            "commercial_registration": "1010123456",
                                            "contact_name": "\u0633\u0627\u0631\u0629 \u0627\u0644\u0639\u062a\u064a\u0628\u064a",
                                            "phone": "0551234567",
                                            "email": "accounts@nokhba.sa",
                                            "address": {
                                                "country": "SA",
                                                "region_id": 1,
                                                "region": "\u0645\u0646\u0637\u0642\u0629 \u0627\u0644\u0631\u064a\u0627\u0636",
                                                "city_id": 3,
                                                "city": "\u0627\u0644\u0631\u064a\u0627\u0636",
                                                "district": "\u0627\u0644\u0639\u0644\u064a\u0627",
                                                "street": "\u0637\u0631\u064a\u0642 \u0627\u0644\u0645\u0644\u0643 \u0641\u0647\u062f",
                                                "building_number": "1234",
                                                "postal_code": "12345",
                                                "additional_number": "5678",
                                                "short_address": "RRRD2929"
                                            },
                                            "missing_tax_details": [],
                                            "payment_term_days": 30,
                                            "credit_limit": "50000.00",
                                            "messages_opt_out": false,
                                            "is_active": true,
                                            "created_at": "2026-11-01T09:30:00+03:00",
                                            "updated_at": "2026-11-08T14:05:00+03:00"
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "createCustomer",
                "tags": [
                    "customers"
                ],
                "summary": "Add a customer",
                "description": "Adds an individual or a business. A business is given a tax invoice, so it is added with its full national address (city, district, street, building number and postal code), or the authority accepts its invoices with remarks. A VAT number is never repeated.\n\nScope: `customers.write`",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CustomerInput"
                            },
                            "example": {
                                "type": "business",
                                "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629",
                                "name_en": "Al Nokhba Trading Co.",
                                "vat_number": "310123456700003",
                                "commercial_registration": "1010123456",
                                "contact_name": "\u0633\u0627\u0631\u0629 \u0627\u0644\u0639\u062a\u064a\u0628\u064a",
                                "phone": "0551234567",
                                "email": "accounts@nokhba.sa",
                                "address": {
                                    "city_id": 3,
                                    "district": "\u0627\u0644\u0639\u0644\u064a\u0627",
                                    "street": "\u0637\u0631\u064a\u0642 \u0627\u0644\u0645\u0644\u0643 \u0641\u0647\u062f",
                                    "building_number": "1234",
                                    "postal_code": "12345",
                                    "additional_number": "5678",
                                    "short_address": "RRRD2929"
                                },
                                "payment_term_days": 30,
                                "credit_limit": "50000.00",
                                "messages_opt_out": false,
                                "is_active": true
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Customer"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 42,
                                        "code": "C-0042",
                                        "type": "business",
                                        "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629",
                                        "name_en": "Al Nokhba Trading Co.",
                                        "vat_number": "310123456700003",
                                        "commercial_registration": "1010123456",
                                        "contact_name": "\u0633\u0627\u0631\u0629 \u0627\u0644\u0639\u062a\u064a\u0628\u064a",
                                        "phone": "0551234567",
                                        "email": "accounts@nokhba.sa",
                                        "address": {
                                            "country": "SA",
                                            "region_id": 1,
                                            "region": "\u0645\u0646\u0637\u0642\u0629 \u0627\u0644\u0631\u064a\u0627\u0636",
                                            "city_id": 3,
                                            "city": "\u0627\u0644\u0631\u064a\u0627\u0636",
                                            "district": "\u0627\u0644\u0639\u0644\u064a\u0627",
                                            "street": "\u0637\u0631\u064a\u0642 \u0627\u0644\u0645\u0644\u0643 \u0641\u0647\u062f",
                                            "building_number": "1234",
                                            "postal_code": "12345",
                                            "additional_number": "5678",
                                            "short_address": "RRRD2929"
                                        },
                                        "missing_tax_details": [],
                                        "payment_term_days": 30,
                                        "credit_limit": "50000.00",
                                        "messages_opt_out": false,
                                        "is_active": true,
                                        "created_at": "2026-11-01T09:30:00+03:00",
                                        "updated_at": "2026-11-08T14:05:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/customers/{id}": {
            "get": {
                "operationId": "getCustomer",
                "tags": [
                    "customers"
                ],
                "summary": "Get a customer",
                "description": "A customer by number. missing_tax_details lists what a business customer still lacks for a tax invoice without remarks.\n\nScope: `customers.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Customer"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 42,
                                        "code": "C-0042",
                                        "type": "business",
                                        "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629",
                                        "name_en": "Al Nokhba Trading Co.",
                                        "vat_number": "310123456700003",
                                        "commercial_registration": "1010123456",
                                        "contact_name": "\u0633\u0627\u0631\u0629 \u0627\u0644\u0639\u062a\u064a\u0628\u064a",
                                        "phone": "0551234567",
                                        "email": "accounts@nokhba.sa",
                                        "address": {
                                            "country": "SA",
                                            "region_id": 1,
                                            "region": "\u0645\u0646\u0637\u0642\u0629 \u0627\u0644\u0631\u064a\u0627\u0636",
                                            "city_id": 3,
                                            "city": "\u0627\u0644\u0631\u064a\u0627\u0636",
                                            "district": "\u0627\u0644\u0639\u0644\u064a\u0627",
                                            "street": "\u0637\u0631\u064a\u0642 \u0627\u0644\u0645\u0644\u0643 \u0641\u0647\u062f",
                                            "building_number": "1234",
                                            "postal_code": "12345",
                                            "additional_number": "5678",
                                            "short_address": "RRRD2929"
                                        },
                                        "missing_tax_details": [],
                                        "payment_term_days": 30,
                                        "credit_limit": "50000.00",
                                        "messages_opt_out": false,
                                        "is_active": true,
                                        "created_at": "2026-11-01T09:30:00+03:00",
                                        "updated_at": "2026-11-08T14:05:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "updateCustomer",
                "tags": [
                    "customers"
                ],
                "summary": "Update a customer",
                "description": "Changes only the fields sent, keeping the rest as they are.\n\nScope: `customers.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CustomerInput"
                            },
                            "example": {
                                "phone": "0559990000",
                                "payment_term_days": 45
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Customer"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 42,
                                        "code": "C-0042",
                                        "type": "business",
                                        "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629",
                                        "name_en": "Al Nokhba Trading Co.",
                                        "vat_number": "310123456700003",
                                        "commercial_registration": "1010123456",
                                        "contact_name": "\u0633\u0627\u0631\u0629 \u0627\u0644\u0639\u062a\u064a\u0628\u064a",
                                        "phone": "0559990000",
                                        "email": "accounts@nokhba.sa",
                                        "address": {
                                            "country": "SA",
                                            "region_id": 1,
                                            "region": "\u0645\u0646\u0637\u0642\u0629 \u0627\u0644\u0631\u064a\u0627\u0636",
                                            "city_id": 3,
                                            "city": "\u0627\u0644\u0631\u064a\u0627\u0636",
                                            "district": "\u0627\u0644\u0639\u0644\u064a\u0627",
                                            "street": "\u0637\u0631\u064a\u0642 \u0627\u0644\u0645\u0644\u0643 \u0641\u0647\u062f",
                                            "building_number": "1234",
                                            "postal_code": "12345",
                                            "additional_number": "5678",
                                            "short_address": "RRRD2929"
                                        },
                                        "missing_tax_details": [],
                                        "payment_term_days": 45,
                                        "credit_limit": "50000.00",
                                        "messages_opt_out": false,
                                        "is_active": true,
                                        "created_at": "2026-11-01T09:30:00+03:00",
                                        "updated_at": "2026-11-08T14:05:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/customers/{id}/balance": {
            "get": {
                "operationId": "getCustomerBalance",
                "tags": [
                    "customers"
                ],
                "summary": "Customer balance",
                "description": "What the customer owes now (negative when they hold a credit), what is left on their invoices, and their open invoices oldest first: what your system needs before recording a payment.\n\nScope: `customers.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "balance": "258.75",
                                        "outstanding": "258.75",
                                        "credit_limit": "50000.00",
                                        "open_invoices": [
                                            {
                                                "id": 318,
                                                "number": "INV-2026-00318",
                                                "issue_date": "2026-11-10",
                                                "due_date": "2026-12-10",
                                                "total": "258.75",
                                                "outstanding": "258.75"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/customers/{id}/statement": {
            "get": {
                "operationId": "getCustomerStatement",
                "tags": [
                    "customers"
                ],
                "summary": "Customer statement",
                "description": "The customer\u2019s account between two dates: the opening balance, every invoice, note, receipt and refund with the balance after it, and the closing balance. From the start of the year to today when no period is named.\n\nScope: `customers.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-01-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "from": "2026-01-01",
                                        "to": "2026-11-30",
                                        "opening_balance": "0.00",
                                        "lines": [
                                            {
                                                "date": "2026-11-10",
                                                "reference": "INV-2026-00318",
                                                "source": "sales_invoice",
                                                "description": "\u0641\u0627\u062a\u0648\u0631\u0629 \u0645\u0628\u064a\u0639\u0627\u062a INV-2026-00318",
                                                "debit": "258.75",
                                                "credit": "0.00",
                                                "balance": "258.75"
                                            },
                                            {
                                                "date": "2026-11-12",
                                                "reference": "RV-2026-00512",
                                                "source": "receipt",
                                                "description": "\u0633\u0646\u062f \u0642\u0628\u0636 RV-2026-00512",
                                                "debit": "0.00",
                                                "credit": "258.75",
                                                "balance": "0.00"
                                            }
                                        ],
                                        "closing_balance": "0.00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/customers/{id}/refunds": {
            "post": {
                "operationId": "refundCustomer",
                "tags": [
                    "receipts"
                ],
                "summary": "Refund a customer",
                "description": "Gives back to the customer money the business holds of theirs, such as a return they had paid or an overpayment: all of it unless an amount is named, never more (see refundable in the customer balance). Needs the receipts permission; a test key never refunds.\n\nScope: `receipts.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/PaymentInput"
                            },
                            "example": {
                                "method": "bank_transfer",
                                "amount": "28.75",
                                "reference": "RF-1001"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "id": 77,
                                        "number": "RF-2026-00077",
                                        "status": "posted",
                                        "date": "2026-11-12",
                                        "amount": "28.75",
                                        "method": "bank_transfer",
                                        "account_id": 12,
                                        "reference": "RF-1001",
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/invoices": {
            "get": {
                "operationId": "listInvoices",
                "tags": [
                    "invoices"
                ],
                "summary": "List invoices",
                "description": "Invoices and notes page by page, newest first, filtered by type, status, customer, number, reference, date and authority status. The list gives each invoice\u2019s head; its lines, payments and file are in \u201cGet an invoice\u201d.\n\nScope: `invoices.read`",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "document",
                        "in": "query",
                        "description": "invoice, credit_note or debit_note.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "invoice"
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "For invoices: draft, issued or void. For receipts: posted or cancelled. For journal entries: draft or posted. For webhook deliveries: pending, delivered or failed.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "issued"
                    },
                    {
                        "name": "customer_id",
                        "in": "query",
                        "description": "The customer\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "name": "number",
                        "in": "query",
                        "description": "The invoice number as it is.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "INV-2026-00318"
                    },
                    {
                        "name": "reference",
                        "in": "query",
                        "description": "Your reference, such as your store\u2019s order number, up to 60 characters. Searchable later.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "ORDER-10045"
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    },
                    {
                        "name": "einvoicing",
                        "in": "query",
                        "description": "The authority status: unsent, pending, reported, cleared or rejected.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "cleared"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Invoice"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 318,
                                            "number": "INV-2026-00318",
                                            "document": "invoice",
                                            "type": "standard",
                                            "status": "issued",
                                            "customer": {
                                                "id": 42,
                                                "code": "C-0042",
                                                "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                            },
                                            "original_invoice_id": null,
                                            "reason": null,
                                            "issue_date": "2026-11-10",
                                            "supply_date": "2026-11-10",
                                            "due_date": "2026-12-10",
                                            "reference": "ORDER-10045",
                                            "notes": null,
                                            "currency": "SAR",
                                            "prices_include_vat": false,
                                            "totals": {
                                                "subtotal": "225.00",
                                                "discount": "0.00",
                                                "tax": "33.75",
                                                "total": "258.75",
                                                "paid": null,
                                                "outstanding": null
                                            },
                                            "einvoicing": {
                                                "status": "cleared",
                                                "qr": "AQ1Pc2VzdGEgTW9tZW50\u2026",
                                                "messages": [],
                                                "sent_at": "2026-11-10T10:15:04+03:00"
                                            },
                                            "pdf_url": null,
                                            "issued_at": "2026-11-10T10:15:02+03:00",
                                            "created_at": "2026-11-10T10:15:01+03:00",
                                            "updated_at": "2026-11-10T10:15:04+03:00"
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "createInvoice",
                "tags": [
                    "invoices"
                ],
                "summary": "Create an invoice",
                "description": "Saved as a draft, or issued at once with issue: true \u2014 numbered, entered in the books and sent to the authority. A line names an item (item_id) to take its name, price and tax, or a description and a price. Issuing is asked the business\u2019s sales policy as the pages ask it, and if refused nothing of the invoice is kept. The invoice type (standard or simplified) follows the customer\u2019s type.\n\nScope: `invoices.write`",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/InvoiceInput"
                            },
                            "example": {
                                "customer_id": 42,
                                "reference": "ORDER-10045",
                                "issue": true,
                                "lines": [
                                    {
                                        "item_id": 7,
                                        "quantity": 2
                                    },
                                    {
                                        "description": "\u062a\u0648\u0635\u064a\u0644",
                                        "quantity": 1,
                                        "unit_price": "25.00",
                                        "tax": "standard"
                                    }
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Invoice"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 318,
                                        "number": "INV-2026-00318",
                                        "document": "invoice",
                                        "type": "standard",
                                        "status": "issued",
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "original_invoice_id": null,
                                        "reason": null,
                                        "issue_date": "2026-11-10",
                                        "supply_date": "2026-11-10",
                                        "due_date": "2026-12-10",
                                        "reference": "ORDER-10045",
                                        "notes": null,
                                        "currency": "SAR",
                                        "prices_include_vat": false,
                                        "totals": {
                                            "subtotal": "225.00",
                                            "discount": "0.00",
                                            "tax": "33.75",
                                            "total": "258.75",
                                            "paid": "0.00",
                                            "outstanding": "258.75"
                                        },
                                        "lines": [
                                            {
                                                "item_id": 7,
                                                "unit_id": 1,
                                                "description": "\u0627\u0633\u062a\u0634\u0627\u0631\u0629",
                                                "quantity": "2.000",
                                                "unit_price": "100.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "30.00"
                                                },
                                                "net": "200.00",
                                                "total": "230.00"
                                            },
                                            {
                                                "item_id": null,
                                                "unit_id": null,
                                                "description": "\u062a\u0648\u0635\u064a\u0644",
                                                "quantity": "1.000",
                                                "unit_price": "25.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "3.75"
                                                },
                                                "net": "25.00",
                                                "total": "28.75"
                                            }
                                        ],
                                        "einvoicing": {
                                            "status": "cleared",
                                            "qr": "AQ1Pc2VzdGEgTW9tZW50\u2026",
                                            "messages": [],
                                            "sent_at": "2026-11-10T10:15:04+03:00"
                                        },
                                        "pdf_url": "https://your-business.qaydtech.com/shared/i/Xk9\u2026/INV-2026-00318.pdf",
                                        "issued_at": "2026-11-10T10:15:02+03:00",
                                        "created_at": "2026-11-10T10:15:01+03:00",
                                        "updated_at": "2026-11-10T10:15:04+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/invoices/{id}": {
            "get": {
                "operationId": "getInvoice",
                "tags": [
                    "invoices"
                ],
                "summary": "Get an invoice",
                "description": "The whole invoice: its lines and totals, what was paid, its status at the Fatoora platform with its remarks, its QR code, and a PDF link valid for a month.\n\nScope: `invoices.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Invoice"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 318,
                                        "number": "INV-2026-00318",
                                        "document": "invoice",
                                        "type": "standard",
                                        "status": "issued",
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "original_invoice_id": null,
                                        "reason": null,
                                        "issue_date": "2026-11-10",
                                        "supply_date": "2026-11-10",
                                        "due_date": "2026-12-10",
                                        "reference": "ORDER-10045",
                                        "notes": null,
                                        "currency": "SAR",
                                        "prices_include_vat": false,
                                        "totals": {
                                            "subtotal": "225.00",
                                            "discount": "0.00",
                                            "tax": "33.75",
                                            "total": "258.75",
                                            "paid": "0.00",
                                            "outstanding": "258.75"
                                        },
                                        "lines": [
                                            {
                                                "item_id": 7,
                                                "unit_id": 1,
                                                "description": "\u0627\u0633\u062a\u0634\u0627\u0631\u0629",
                                                "quantity": "2.000",
                                                "unit_price": "100.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "30.00"
                                                },
                                                "net": "200.00",
                                                "total": "230.00"
                                            },
                                            {
                                                "item_id": null,
                                                "unit_id": null,
                                                "description": "\u062a\u0648\u0635\u064a\u0644",
                                                "quantity": "1.000",
                                                "unit_price": "25.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "3.75"
                                                },
                                                "net": "25.00",
                                                "total": "28.75"
                                            }
                                        ],
                                        "einvoicing": {
                                            "status": "cleared",
                                            "qr": "AQ1Pc2VzdGEgTW9tZW50\u2026",
                                            "messages": [],
                                            "sent_at": "2026-11-10T10:15:04+03:00"
                                        },
                                        "pdf_url": "https://your-business.qaydtech.com/shared/i/Xk9\u2026/INV-2026-00318.pdf",
                                        "issued_at": "2026-11-10T10:15:02+03:00",
                                        "created_at": "2026-11-10T10:15:01+03:00",
                                        "updated_at": "2026-11-10T10:15:04+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "updateInvoice",
                "tags": [
                    "invoices"
                ],
                "summary": "Update a draft",
                "description": "Changes a draft invoice: only what is sent changes, the rest stays, and its lines stay as they are unless lines are sent, which then replace them all. Issued at once with issue: true. An issued invoice is never changed.\n\nScope: `invoices.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/InvoiceInput"
                            },
                            "example": {
                                "reference": "ORDER-10045-B",
                                "due_date": "2026-12-20"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Invoice"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 318,
                                        "number": null,
                                        "document": "invoice",
                                        "type": "standard",
                                        "status": "draft",
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "original_invoice_id": null,
                                        "reason": null,
                                        "issue_date": "2026-11-10",
                                        "supply_date": "2026-11-10",
                                        "due_date": "2026-12-10",
                                        "reference": "ORDER-10045-B",
                                        "notes": null,
                                        "currency": "SAR",
                                        "prices_include_vat": false,
                                        "totals": {
                                            "subtotal": "225.00",
                                            "discount": "0.00",
                                            "tax": "33.75",
                                            "total": "258.75",
                                            "paid": "0.00",
                                            "outstanding": "258.75"
                                        },
                                        "lines": [
                                            {
                                                "item_id": 7,
                                                "unit_id": 1,
                                                "description": "\u0627\u0633\u062a\u0634\u0627\u0631\u0629",
                                                "quantity": "2.000",
                                                "unit_price": "100.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "30.00"
                                                },
                                                "net": "200.00",
                                                "total": "230.00"
                                            },
                                            {
                                                "item_id": null,
                                                "unit_id": null,
                                                "description": "\u062a\u0648\u0635\u064a\u0644",
                                                "quantity": "1.000",
                                                "unit_price": "25.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "3.75"
                                                },
                                                "net": "25.00",
                                                "total": "28.75"
                                            }
                                        ],
                                        "einvoicing": {
                                            "status": "cleared",
                                            "qr": "AQ1Pc2VzdGEgTW9tZW50\u2026",
                                            "messages": [],
                                            "sent_at": "2026-11-10T10:15:04+03:00"
                                        },
                                        "pdf_url": "https://your-business.qaydtech.com/shared/i/Xk9\u2026/INV-2026-00318.pdf",
                                        "issued_at": "2026-11-10T10:15:02+03:00",
                                        "created_at": "2026-11-10T10:15:01+03:00",
                                        "updated_at": "2026-11-10T10:15:04+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "deleteInvoice",
                "tags": [
                    "invoices"
                ],
                "summary": "Delete a draft",
                "description": "Deletes a draft. An issued invoice is never deleted: it is corrected by a credit note.\n\nScope: `invoices.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "204": {
                        "description": "Deleted"
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/invoices/{id}/payments": {
            "post": {
                "operationId": "payInvoice",
                "tags": [
                    "invoices"
                ],
                "summary": "Record a payment on an invoice",
                "description": "Records a receipt settling the invoice: all that is left on it unless an amount is named, never more. The key needs receipts (receipts.write) as well as invoices. A test key never records payments.\n\nScope: `invoices.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/PaymentInput"
                            },
                            "example": {
                                "method": "card",
                                "reference": "PAY-88231"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Receipt"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 512,
                                        "number": "RV-2026-00512",
                                        "status": "posted",
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "date": "2026-11-10",
                                        "amount": "258.75",
                                        "method": "card",
                                        "account": {
                                            "id": 12,
                                            "code": "11103",
                                            "name": "11103 \u2014 \u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                        },
                                        "reference": "PAY-88231",
                                        "notes": null,
                                        "invoices": [
                                            {
                                                "id": 318,
                                                "number": "INV-2026-00318",
                                                "amount": "258.75"
                                            }
                                        ],
                                        "unallocated": "0.00",
                                        "cancelled_at": null,
                                        "created_at": "2026-11-10T10:16:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/invoices/{id}/issue": {
            "post": {
                "operationId": "issueInvoice",
                "tags": [
                    "invoices"
                ],
                "summary": "Issue a draft",
                "description": "Issues an existing draft: numbered, entered in the books and sent to the authority, after asking the sales policy. A test key never issues.\n\nScope: `invoices.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Invoice"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 318,
                                        "number": "INV-2026-00318",
                                        "document": "invoice",
                                        "type": "standard",
                                        "status": "issued",
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "original_invoice_id": null,
                                        "reason": null,
                                        "issue_date": "2026-11-10",
                                        "supply_date": "2026-11-10",
                                        "due_date": "2026-12-10",
                                        "reference": "ORDER-10045",
                                        "notes": null,
                                        "currency": "SAR",
                                        "prices_include_vat": false,
                                        "totals": {
                                            "subtotal": "225.00",
                                            "discount": "0.00",
                                            "tax": "33.75",
                                            "total": "258.75",
                                            "paid": "0.00",
                                            "outstanding": "258.75"
                                        },
                                        "lines": [
                                            {
                                                "item_id": 7,
                                                "unit_id": 1,
                                                "description": "\u0627\u0633\u062a\u0634\u0627\u0631\u0629",
                                                "quantity": "2.000",
                                                "unit_price": "100.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "30.00"
                                                },
                                                "net": "200.00",
                                                "total": "230.00"
                                            },
                                            {
                                                "item_id": null,
                                                "unit_id": null,
                                                "description": "\u062a\u0648\u0635\u064a\u0644",
                                                "quantity": "1.000",
                                                "unit_price": "25.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "3.75"
                                                },
                                                "net": "25.00",
                                                "total": "28.75"
                                            }
                                        ],
                                        "einvoicing": {
                                            "status": "cleared",
                                            "qr": "AQ1Pc2VzdGEgTW9tZW50\u2026",
                                            "messages": [],
                                            "sent_at": "2026-11-10T10:15:04+03:00"
                                        },
                                        "pdf_url": "https://your-business.qaydtech.com/shared/i/Xk9\u2026/INV-2026-00318.pdf",
                                        "issued_at": "2026-11-10T10:15:02+03:00",
                                        "created_at": "2026-11-10T10:15:01+03:00",
                                        "updated_at": "2026-11-10T10:15:04+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/invoices/{id}/credit-notes": {
            "post": {
                "operationId": "createCreditNote",
                "tags": [
                    "invoices"
                ],
                "summary": "Credit note (return)",
                "description": "A credit note on an issued invoice, never more than it may still take back. Returns stock by default, and is issued at once with issue: true.\n\nScope: `invoices.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CreditNoteInput"
                            },
                            "example": {
                                "reason": "\u0645\u0631\u062a\u062c\u0639 \u062c\u0632\u0626\u064a",
                                "issue": true,
                                "lines": [
                                    {
                                        "item_id": 7,
                                        "quantity": 1
                                    }
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Invoice"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 319,
                                        "number": "CN-2026-00012",
                                        "document": "credit_note",
                                        "type": "standard",
                                        "status": "issued",
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "original_invoice_id": 318,
                                        "reason": "\u0645\u0631\u062a\u062c\u0639 \u062c\u0632\u0626\u064a",
                                        "issue_date": "2026-11-10",
                                        "supply_date": "2026-11-10",
                                        "due_date": "2026-12-10",
                                        "reference": "ORDER-10045",
                                        "notes": null,
                                        "currency": "SAR",
                                        "prices_include_vat": false,
                                        "totals": {
                                            "subtotal": "225.00",
                                            "discount": "0.00",
                                            "tax": "33.75",
                                            "total": "258.75",
                                            "paid": "0.00",
                                            "outstanding": "258.75"
                                        },
                                        "lines": [
                                            {
                                                "item_id": 7,
                                                "unit_id": 1,
                                                "description": "\u0627\u0633\u062a\u0634\u0627\u0631\u0629",
                                                "quantity": "2.000",
                                                "unit_price": "100.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "30.00"
                                                },
                                                "net": "200.00",
                                                "total": "230.00"
                                            },
                                            {
                                                "item_id": null,
                                                "unit_id": null,
                                                "description": "\u062a\u0648\u0635\u064a\u0644",
                                                "quantity": "1.000",
                                                "unit_price": "25.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "3.75"
                                                },
                                                "net": "25.00",
                                                "total": "28.75"
                                            }
                                        ],
                                        "einvoicing": {
                                            "status": "cleared",
                                            "qr": "AQ1Pc2VzdGEgTW9tZW50\u2026",
                                            "messages": [],
                                            "sent_at": "2026-11-10T10:15:04+03:00"
                                        },
                                        "pdf_url": "https://your-business.qaydtech.com/shared/i/Xk9\u2026/INV-2026-00318.pdf",
                                        "issued_at": "2026-11-10T10:15:02+03:00",
                                        "created_at": "2026-11-10T10:15:01+03:00",
                                        "updated_at": "2026-11-10T10:15:04+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/invoices/{id}/debit-notes": {
            "post": {
                "operationId": "createDebitNote",
                "tags": [
                    "invoices"
                ],
                "summary": "Debit note",
                "description": "A debit note on an issued invoice for what it charged too little, such as a price difference. Issued at once with issue: true.\n\nScope: `invoices.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CreditNoteInput"
                            },
                            "example": {
                                "reason": "\u0641\u0631\u0642 \u0633\u0639\u0631",
                                "issue": true,
                                "lines": [
                                    {
                                        "description": "\u0641\u0631\u0642 \u0633\u0639\u0631",
                                        "quantity": 1,
                                        "unit_price": "20.00"
                                    }
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Invoice"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 320,
                                        "number": "DN-2026-00003",
                                        "document": "debit_note",
                                        "type": "standard",
                                        "status": "issued",
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "original_invoice_id": 318,
                                        "reason": "\u0641\u0631\u0642 \u0633\u0639\u0631",
                                        "issue_date": "2026-11-10",
                                        "supply_date": "2026-11-10",
                                        "due_date": "2026-12-10",
                                        "reference": "ORDER-10045",
                                        "notes": null,
                                        "currency": "SAR",
                                        "prices_include_vat": false,
                                        "totals": {
                                            "subtotal": "225.00",
                                            "discount": "0.00",
                                            "tax": "33.75",
                                            "total": "258.75",
                                            "paid": "0.00",
                                            "outstanding": "258.75"
                                        },
                                        "lines": [
                                            {
                                                "item_id": 7,
                                                "unit_id": 1,
                                                "description": "\u0627\u0633\u062a\u0634\u0627\u0631\u0629",
                                                "quantity": "2.000",
                                                "unit_price": "100.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "30.00"
                                                },
                                                "net": "200.00",
                                                "total": "230.00"
                                            },
                                            {
                                                "item_id": null,
                                                "unit_id": null,
                                                "description": "\u062a\u0648\u0635\u064a\u0644",
                                                "quantity": "1.000",
                                                "unit_price": "25.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "3.75"
                                                },
                                                "net": "25.00",
                                                "total": "28.75"
                                            }
                                        ],
                                        "einvoicing": {
                                            "status": "cleared",
                                            "qr": "AQ1Pc2VzdGEgTW9tZW50\u2026",
                                            "messages": [],
                                            "sent_at": "2026-11-10T10:15:04+03:00"
                                        },
                                        "pdf_url": "https://your-business.qaydtech.com/shared/i/Xk9\u2026/INV-2026-00318.pdf",
                                        "issued_at": "2026-11-10T10:15:02+03:00",
                                        "created_at": "2026-11-10T10:15:01+03:00",
                                        "updated_at": "2026-11-10T10:15:04+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/receipts": {
            "get": {
                "operationId": "listReceipts",
                "tags": [
                    "receipts"
                ],
                "summary": "List receipts",
                "description": "Receipts page by page, newest first, filtered by customer, the invoice a receipt settled, status, reference and date.\n\nScope: `receipts.read`",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "customer_id",
                        "in": "query",
                        "description": "The customer\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "name": "invoice_id",
                        "in": "query",
                        "description": "Receipts that settled this invoice.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 318
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "For invoices: draft, issued or void. For receipts: posted or cancelled. For journal entries: draft or posted. For webhook deliveries: pending, delivered or failed.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "posted"
                    },
                    {
                        "name": "reference",
                        "in": "query",
                        "description": "Your reference, such as your store\u2019s order number, up to 60 characters. Searchable later.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "PAY-88231"
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Receipt"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 512,
                                            "number": "RV-2026-00512",
                                            "status": "posted",
                                            "customer": {
                                                "id": 42,
                                                "code": "C-0042",
                                                "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                            },
                                            "date": "2026-11-10",
                                            "amount": "258.75",
                                            "method": "card",
                                            "account": {
                                                "id": 12,
                                                "code": "11103",
                                                "name": "11103 \u2014 \u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                            },
                                            "reference": "PAY-88231",
                                            "notes": null,
                                            "invoices": [
                                                {
                                                    "id": 318,
                                                    "number": "INV-2026-00318",
                                                    "amount": "258.75"
                                                }
                                            ],
                                            "unallocated": "0.00",
                                            "cancelled_at": null,
                                            "created_at": "2026-11-10T10:16:00+03:00"
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "createReceipt",
                "tags": [
                    "receipts"
                ],
                "summary": "Record a receipt",
                "description": "Records money received from a customer: it settles the invoices named in invoices, or their open invoices oldest first with allocate: auto. Whatever settles no invoice stays to the customer\u2019s credit. Entered in the books at once; a test key never records one.\n\nScope: `receipts.write`",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ReceiptInput"
                            },
                            "example": {
                                "customer_id": 42,
                                "amount": "500.00",
                                "method": "bank_transfer",
                                "reference": "TRX-55102",
                                "allocate": "auto"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Receipt"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 512,
                                        "number": "RV-2026-00512",
                                        "status": "posted",
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "date": "2026-11-10",
                                        "amount": "500.00",
                                        "method": "bank_transfer",
                                        "account": {
                                            "id": 12,
                                            "code": "11103",
                                            "name": "11103 \u2014 \u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                        },
                                        "reference": "TRX-55102",
                                        "notes": null,
                                        "invoices": [
                                            {
                                                "id": 318,
                                                "number": "INV-2026-00318",
                                                "amount": "258.75"
                                            }
                                        ],
                                        "unallocated": "241.25",
                                        "cancelled_at": null,
                                        "created_at": "2026-11-10T10:16:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/receipts/{id}": {
            "get": {
                "operationId": "getReceipt",
                "tags": [
                    "receipts"
                ],
                "summary": "Get a receipt",
                "description": "The receipt: amount and account, the invoices it settled, and what was left of it to the customer\u2019s credit.\n\nScope: `receipts.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Receipt"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 512,
                                        "number": "RV-2026-00512",
                                        "status": "posted",
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "date": "2026-11-10",
                                        "amount": "258.75",
                                        "method": "card",
                                        "account": {
                                            "id": 12,
                                            "code": "11103",
                                            "name": "11103 \u2014 \u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                        },
                                        "reference": "PAY-88231",
                                        "notes": null,
                                        "invoices": [
                                            {
                                                "id": 318,
                                                "number": "INV-2026-00318",
                                                "amount": "258.75"
                                            }
                                        ],
                                        "unallocated": "0.00",
                                        "cancelled_at": null,
                                        "created_at": "2026-11-10T10:16:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/receipts/{id}/cancel": {
            "post": {
                "operationId": "cancelReceipt",
                "tags": [
                    "receipts"
                ],
                "summary": "Cancel a receipt",
                "description": "Reverses the receipt\u2019s entry on the cancellation date, and the invoices it settled are owed again.\n\nScope: `receipts.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Receipt"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 512,
                                        "number": "RV-2026-00512",
                                        "status": "cancelled",
                                        "customer": {
                                            "id": 42,
                                            "code": "C-0042",
                                            "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                        },
                                        "date": "2026-11-10",
                                        "amount": "258.75",
                                        "method": "card",
                                        "account": {
                                            "id": 12,
                                            "code": "11103",
                                            "name": "11103 \u2014 \u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                        },
                                        "reference": "PAY-88231",
                                        "notes": null,
                                        "invoices": [
                                            {
                                                "id": 318,
                                                "number": "INV-2026-00318",
                                                "amount": "258.75"
                                            }
                                        ],
                                        "unallocated": "0.00",
                                        "cancelled_at": "2026-11-12T09:00:00+03:00",
                                        "created_at": "2026-11-10T10:16:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/suppliers": {
            "get": {
                "operationId": "listSuppliers",
                "tags": [
                    "suppliers"
                ],
                "summary": "List suppliers",
                "description": "Suppliers page by page, searched by name, code, VAT number or phone, filtered by type, status and last change.\n\nScope: `suppliers.read`",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "description": "Text to search for.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "\u0627\u0644\u0642\u0647\u0648\u0629"
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "description": "The type: individual or business for a customer; product or service for an item; asset, liability, equity, revenue or expense for an account.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "business"
                    },
                    {
                        "name": "active",
                        "in": "query",
                        "description": "true for active only, false for stopped only.",
                        "schema": {
                            "type": "boolean"
                        },
                        "example": true
                    },
                    {
                        "name": "updated_since",
                        "in": "query",
                        "description": "Changed since this date or time (ISO 8601).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-01"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Customer"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 15,
                                            "code": "S-0015",
                                            "type": "business",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629",
                                            "name_en": null,
                                            "vat_number": "311111111100003",
                                            "commercial_registration": "1010123456",
                                            "contact_name": null,
                                            "phone": "0551234567",
                                            "email": null,
                                            "address": {
                                                "country": "SA",
                                                "region_id": 1,
                                                "region": "\u0645\u0646\u0637\u0642\u0629 \u0627\u0644\u0631\u064a\u0627\u0636",
                                                "city_id": 3,
                                                "city": "\u0627\u0644\u0631\u064a\u0627\u0636",
                                                "district": "\u0627\u0644\u0639\u0644\u064a\u0627",
                                                "street": "\u0637\u0631\u064a\u0642 \u0627\u0644\u0645\u0644\u0643 \u0641\u0647\u062f",
                                                "building_number": "1234",
                                                "postal_code": "12345",
                                                "additional_number": "5678",
                                                "short_address": "RRRD2929"
                                            },
                                            "missing_tax_details": [],
                                            "payment_term_days": 30,
                                            "credit_limit": null,
                                            "messages_opt_out": false,
                                            "is_active": true,
                                            "created_at": "2026-11-01T09:30:00+03:00",
                                            "updated_at": "2026-11-08T14:05:00+03:00"
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "createSupplier",
                "tags": [
                    "suppliers"
                ],
                "summary": "Add a supplier",
                "description": "Adds an individual or a business supplier. No national address is asked; a VAT number is never repeated among suppliers.\n\nScope: `suppliers.write`",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CustomerInput"
                            },
                            "example": {
                                "type": "business",
                                "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629",
                                "vat_number": "311111111100003",
                                "phone": "0501234567",
                                "payment_term_days": 30
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Customer"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 15,
                                        "code": "S-0015",
                                        "type": "business",
                                        "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629",
                                        "name_en": null,
                                        "vat_number": "311111111100003",
                                        "commercial_registration": "1010123456",
                                        "contact_name": null,
                                        "phone": "0551234567",
                                        "email": null,
                                        "address": {
                                            "country": "SA",
                                            "region_id": 1,
                                            "region": "\u0645\u0646\u0637\u0642\u0629 \u0627\u0644\u0631\u064a\u0627\u0636",
                                            "city_id": 3,
                                            "city": "\u0627\u0644\u0631\u064a\u0627\u0636",
                                            "district": "\u0627\u0644\u0639\u0644\u064a\u0627",
                                            "street": "\u0637\u0631\u064a\u0642 \u0627\u0644\u0645\u0644\u0643 \u0641\u0647\u062f",
                                            "building_number": "1234",
                                            "postal_code": "12345",
                                            "additional_number": "5678",
                                            "short_address": "RRRD2929"
                                        },
                                        "missing_tax_details": [],
                                        "payment_term_days": 30,
                                        "credit_limit": null,
                                        "messages_opt_out": false,
                                        "is_active": true,
                                        "created_at": "2026-11-01T09:30:00+03:00",
                                        "updated_at": "2026-11-08T14:05:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/suppliers/{id}": {
            "get": {
                "operationId": "getSupplier",
                "tags": [
                    "suppliers"
                ],
                "summary": "Get a supplier",
                "description": "A supplier by number.\n\nScope: `suppliers.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Customer"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 15,
                                        "code": "S-0015",
                                        "type": "business",
                                        "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629",
                                        "name_en": null,
                                        "vat_number": "311111111100003",
                                        "commercial_registration": "1010123456",
                                        "contact_name": null,
                                        "phone": "0551234567",
                                        "email": null,
                                        "address": {
                                            "country": "SA",
                                            "region_id": 1,
                                            "region": "\u0645\u0646\u0637\u0642\u0629 \u0627\u0644\u0631\u064a\u0627\u0636",
                                            "city_id": 3,
                                            "city": "\u0627\u0644\u0631\u064a\u0627\u0636",
                                            "district": "\u0627\u0644\u0639\u0644\u064a\u0627",
                                            "street": "\u0637\u0631\u064a\u0642 \u0627\u0644\u0645\u0644\u0643 \u0641\u0647\u062f",
                                            "building_number": "1234",
                                            "postal_code": "12345",
                                            "additional_number": "5678",
                                            "short_address": "RRRD2929"
                                        },
                                        "missing_tax_details": [],
                                        "payment_term_days": 30,
                                        "credit_limit": null,
                                        "messages_opt_out": false,
                                        "is_active": true,
                                        "created_at": "2026-11-01T09:30:00+03:00",
                                        "updated_at": "2026-11-08T14:05:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "updateSupplier",
                "tags": [
                    "suppliers"
                ],
                "summary": "Update a supplier",
                "description": "Changes only the fields sent.\n\nScope: `suppliers.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CustomerInput"
                            },
                            "example": {
                                "payment_term_days": 45
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Customer"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 15,
                                        "code": "S-0015",
                                        "type": "business",
                                        "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629",
                                        "name_en": null,
                                        "vat_number": "311111111100003",
                                        "commercial_registration": "1010123456",
                                        "contact_name": null,
                                        "phone": "0551234567",
                                        "email": null,
                                        "address": {
                                            "country": "SA",
                                            "region_id": 1,
                                            "region": "\u0645\u0646\u0637\u0642\u0629 \u0627\u0644\u0631\u064a\u0627\u0636",
                                            "city_id": 3,
                                            "city": "\u0627\u0644\u0631\u064a\u0627\u0636",
                                            "district": "\u0627\u0644\u0639\u0644\u064a\u0627",
                                            "street": "\u0637\u0631\u064a\u0642 \u0627\u0644\u0645\u0644\u0643 \u0641\u0647\u062f",
                                            "building_number": "1234",
                                            "postal_code": "12345",
                                            "additional_number": "5678",
                                            "short_address": "RRRD2929"
                                        },
                                        "missing_tax_details": [],
                                        "payment_term_days": 45,
                                        "credit_limit": null,
                                        "messages_opt_out": false,
                                        "is_active": true,
                                        "created_at": "2026-11-01T09:30:00+03:00",
                                        "updated_at": "2026-11-08T14:05:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/suppliers/{id}/balance": {
            "get": {
                "operationId": "getSupplierBalance",
                "tags": [
                    "suppliers"
                ],
                "summary": "Supplier balance",
                "description": "What the business owes the supplier now (positive = owed by the business), what is left on their purchase invoices, and their open invoices oldest first.\n\nScope: `suppliers.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "supplier": {
                                            "id": 15,
                                            "code": "S-0015",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                        },
                                        "balance": "200.00",
                                        "outstanding": "200.00",
                                        "credit_limit": null,
                                        "refundable": "0.00",
                                        "open_invoices": [
                                            {
                                                "id": 77,
                                                "number": "PUR-2026-00077",
                                                "issue_date": "2026-11-02",
                                                "due_date": "2026-12-02",
                                                "total": "230.00",
                                                "outstanding": "200.00"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/suppliers/{id}/statement": {
            "get": {
                "operationId": "getSupplierStatement",
                "tags": [
                    "suppliers"
                ],
                "summary": "Supplier statement",
                "description": "The supplier\u2019s account between two dates with the balance after each line, told as what the business owes them.\n\nScope: `suppliers.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-01-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "supplier": {
                                            "id": 15,
                                            "code": "S-0015",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                        },
                                        "from": "2026-01-01",
                                        "to": "2026-11-30",
                                        "opening_balance": "0.00",
                                        "lines": [
                                            {
                                                "date": "2026-11-02",
                                                "reference": "PUR-2026-00077",
                                                "source": "purchase_invoice",
                                                "description": "\u0641\u0627\u062a\u0648\u0631\u0629 \u0645\u0634\u062a\u0631\u064a\u0627\u062a PUR-2026-00077",
                                                "debit": "0.00",
                                                "credit": "230.00",
                                                "balance": "230.00"
                                            }
                                        ],
                                        "closing_balance": "230.00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/purchases": {
            "get": {
                "operationId": "listPurchases",
                "tags": [
                    "purchases"
                ],
                "summary": "List purchase invoices",
                "description": "Purchase invoices and returns page by page, newest first, filtered by type, status, supplier, number, the supplier\u2019s invoice number and date.\n\nScope: `purchases.read`",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "document",
                        "in": "query",
                        "description": "invoice, credit_note or debit_note.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "invoice"
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "For invoices: draft, issued or void. For receipts: posted or cancelled. For journal entries: draft or posted. For webhook deliveries: pending, delivered or failed.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "posted"
                    },
                    {
                        "name": "supplier_id",
                        "in": "query",
                        "description": "The supplier\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 15
                    },
                    {
                        "name": "number",
                        "in": "query",
                        "description": "The invoice number as it is.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "PUR-2026-00077"
                    },
                    {
                        "name": "supplier_invoice_number",
                        "in": "query",
                        "description": "The number on the supplier\u2019s own invoice, up to 60 characters.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "S-1001"
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/PurchaseInvoice"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 77,
                                            "number": "PUR-2026-00077",
                                            "document": "invoice",
                                            "status": "posted",
                                            "supplier": {
                                                "id": 15,
                                                "code": "S-0015",
                                                "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                            },
                                            "supplier_invoice_number": "S-1001",
                                            "original_invoice_id": null,
                                            "reason": null,
                                            "issue_date": "2026-11-02",
                                            "due_date": "2026-12-02",
                                            "notes": null,
                                            "currency": "SAR",
                                            "prices_include_vat": false,
                                            "totals": {
                                                "subtotal": "200.00",
                                                "discount": "0.00",
                                                "tax": "30.00",
                                                "total": "230.00",
                                                "paid": null,
                                                "outstanding": null
                                            },
                                            "posted_at": "2026-11-02T12:00:00+03:00",
                                            "created_at": "2026-11-02T11:58:00+03:00",
                                            "updated_at": "2026-11-02T12:00:00+03:00"
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "createPurchase",
                "tags": [
                    "purchases"
                ],
                "summary": "Create a purchase invoice",
                "description": "Saved as a draft, or posted at once with post: true \u2014 entered in the books and the stock received \u2014 after the purchase policy is asked (such as requiring the supplier\u2019s invoice number and refusing it twice). A line naming an item takes its purchase price and its stock or cost account. Paid as it is posted with payment. A test key creates drafts only.\n\nScope: `purchases.write`",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/PurchaseInput"
                            },
                            "example": {
                                "supplier_id": 15,
                                "supplier_invoice_number": "S-1001",
                                "post": true,
                                "lines": [
                                    {
                                        "item_id": 8,
                                        "quantity": 10
                                    }
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/PurchaseInvoice"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 77,
                                        "number": "PUR-2026-00077",
                                        "document": "invoice",
                                        "status": "posted",
                                        "supplier": {
                                            "id": 15,
                                            "code": "S-0015",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                        },
                                        "supplier_invoice_number": "S-1001",
                                        "original_invoice_id": null,
                                        "reason": null,
                                        "issue_date": "2026-11-02",
                                        "due_date": "2026-12-02",
                                        "notes": null,
                                        "currency": "SAR",
                                        "prices_include_vat": false,
                                        "totals": {
                                            "subtotal": "200.00",
                                            "discount": "0.00",
                                            "tax": "30.00",
                                            "total": "230.00",
                                            "paid": "0.00",
                                            "outstanding": "230.00"
                                        },
                                        "lines": [
                                            {
                                                "item_id": 8,
                                                "unit_id": 1,
                                                "description": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a",
                                                "account_id": 14,
                                                "quantity": "10.000",
                                                "unit_price": "20.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "30.00"
                                                },
                                                "net": "200.00",
                                                "total": "230.00"
                                            }
                                        ],
                                        "posted_at": "2026-11-02T12:00:00+03:00",
                                        "created_at": "2026-11-02T11:58:00+03:00",
                                        "updated_at": "2026-11-02T12:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/purchases/{id}": {
            "get": {
                "operationId": "getPurchase",
                "tags": [
                    "purchases"
                ],
                "summary": "Get a purchase invoice",
                "description": "The invoice with its lines, totals and what was paid.\n\nScope: `purchases.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/PurchaseInvoice"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 77,
                                        "number": "PUR-2026-00077",
                                        "document": "invoice",
                                        "status": "posted",
                                        "supplier": {
                                            "id": 15,
                                            "code": "S-0015",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                        },
                                        "supplier_invoice_number": "S-1001",
                                        "original_invoice_id": null,
                                        "reason": null,
                                        "issue_date": "2026-11-02",
                                        "due_date": "2026-12-02",
                                        "notes": null,
                                        "currency": "SAR",
                                        "prices_include_vat": false,
                                        "totals": {
                                            "subtotal": "200.00",
                                            "discount": "0.00",
                                            "tax": "30.00",
                                            "total": "230.00",
                                            "paid": "0.00",
                                            "outstanding": "230.00"
                                        },
                                        "lines": [
                                            {
                                                "item_id": 8,
                                                "unit_id": 1,
                                                "description": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a",
                                                "account_id": 14,
                                                "quantity": "10.000",
                                                "unit_price": "20.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "30.00"
                                                },
                                                "net": "200.00",
                                                "total": "230.00"
                                            }
                                        ],
                                        "posted_at": "2026-11-02T12:00:00+03:00",
                                        "created_at": "2026-11-02T11:58:00+03:00",
                                        "updated_at": "2026-11-02T12:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "updatePurchase",
                "tags": [
                    "purchases"
                ],
                "summary": "Update a purchase draft",
                "description": "Only what is sent changes; its lines stay unless sent. Posted at once with post: true. A posted invoice is never changed.\n\nScope: `purchases.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/PurchaseInput"
                            },
                            "example": {
                                "notes": "\u062d\u0633\u0628 \u0627\u0644\u0639\u0631\u0636 \u0631\u0642\u0645 12"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/PurchaseInvoice"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 77,
                                        "number": null,
                                        "document": "invoice",
                                        "status": "draft",
                                        "supplier": {
                                            "id": 15,
                                            "code": "S-0015",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                        },
                                        "supplier_invoice_number": "S-1001",
                                        "original_invoice_id": null,
                                        "reason": null,
                                        "issue_date": "2026-11-02",
                                        "due_date": "2026-12-02",
                                        "notes": null,
                                        "currency": "SAR",
                                        "prices_include_vat": false,
                                        "totals": {
                                            "subtotal": "200.00",
                                            "discount": "0.00",
                                            "tax": "30.00",
                                            "total": "230.00",
                                            "paid": "0.00",
                                            "outstanding": "230.00"
                                        },
                                        "lines": [
                                            {
                                                "item_id": 8,
                                                "unit_id": 1,
                                                "description": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a",
                                                "account_id": 14,
                                                "quantity": "10.000",
                                                "unit_price": "20.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "30.00"
                                                },
                                                "net": "200.00",
                                                "total": "230.00"
                                            }
                                        ],
                                        "posted_at": "2026-11-02T12:00:00+03:00",
                                        "created_at": "2026-11-02T11:58:00+03:00",
                                        "updated_at": "2026-11-02T12:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "deletePurchase",
                "tags": [
                    "purchases"
                ],
                "summary": "Delete a purchase draft",
                "description": "Deletes a draft. A posted invoice is never deleted: it is corrected by a return.\n\nScope: `purchases.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "204": {
                        "description": "Deleted"
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/purchases/{id}/post": {
            "post": {
                "operationId": "postPurchase",
                "tags": [
                    "purchases"
                ],
                "summary": "Post a purchase invoice",
                "description": "Posts a draft (or a return): entered in the books and the stock moved. A test key never posts.\n\nScope: `purchases.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/PurchaseInvoice"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 77,
                                        "number": "PUR-2026-00077",
                                        "document": "invoice",
                                        "status": "posted",
                                        "supplier": {
                                            "id": 15,
                                            "code": "S-0015",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                        },
                                        "supplier_invoice_number": "S-1001",
                                        "original_invoice_id": null,
                                        "reason": null,
                                        "issue_date": "2026-11-02",
                                        "due_date": "2026-12-02",
                                        "notes": null,
                                        "currency": "SAR",
                                        "prices_include_vat": false,
                                        "totals": {
                                            "subtotal": "200.00",
                                            "discount": "0.00",
                                            "tax": "30.00",
                                            "total": "230.00",
                                            "paid": "0.00",
                                            "outstanding": "230.00"
                                        },
                                        "lines": [
                                            {
                                                "item_id": 8,
                                                "unit_id": 1,
                                                "description": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a",
                                                "account_id": 14,
                                                "quantity": "10.000",
                                                "unit_price": "20.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "30.00"
                                                },
                                                "net": "200.00",
                                                "total": "230.00"
                                            }
                                        ],
                                        "posted_at": "2026-11-02T12:00:00+03:00",
                                        "created_at": "2026-11-02T11:58:00+03:00",
                                        "updated_at": "2026-11-02T12:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/purchases/{id}/returns": {
            "post": {
                "operationId": "createPurchaseReturn",
                "tags": [
                    "purchases"
                ],
                "summary": "Purchase return",
                "description": "A return on a posted invoice, never more than may still go back. Takes the stock out by default, and is posted at once with post: true.\n\nScope: `purchases.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CreditNoteInput"
                            },
                            "example": {
                                "reason": "\u062a\u0627\u0644\u0641",
                                "post": true,
                                "lines": [
                                    {
                                        "item_id": 8,
                                        "quantity": 2
                                    }
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/PurchaseInvoice"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 78,
                                        "number": "PRT-2026-00004",
                                        "document": "return",
                                        "status": "posted",
                                        "supplier": {
                                            "id": 15,
                                            "code": "S-0015",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                        },
                                        "supplier_invoice_number": "S-1001",
                                        "original_invoice_id": 77,
                                        "reason": "\u062a\u0627\u0644\u0641",
                                        "issue_date": "2026-11-02",
                                        "due_date": "2026-12-02",
                                        "notes": null,
                                        "currency": "SAR",
                                        "prices_include_vat": false,
                                        "totals": {
                                            "subtotal": "200.00",
                                            "discount": "0.00",
                                            "tax": "30.00",
                                            "total": "230.00",
                                            "paid": "0.00",
                                            "outstanding": "230.00"
                                        },
                                        "lines": [
                                            {
                                                "item_id": 8,
                                                "unit_id": 1,
                                                "description": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a",
                                                "account_id": 14,
                                                "quantity": "10.000",
                                                "unit_price": "20.00",
                                                "discount": "0.00",
                                                "tax": {
                                                    "code": "standard",
                                                    "category": "S",
                                                    "rate": "15.00",
                                                    "amount": "30.00"
                                                },
                                                "net": "200.00",
                                                "total": "230.00"
                                            }
                                        ],
                                        "posted_at": "2026-11-02T12:00:00+03:00",
                                        "created_at": "2026-11-02T11:58:00+03:00",
                                        "updated_at": "2026-11-02T12:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/purchases/{id}/payments": {
            "post": {
                "operationId": "payPurchase",
                "tags": [
                    "purchases"
                ],
                "summary": "Pay a purchase invoice",
                "description": "Records a payment voucher settling the invoice: all that is left unless an amount is named, never more. The key needs payments (payments.write) as well as purchases.\n\nScope: `purchases.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/PaymentInput"
                            },
                            "example": {
                                "method": "bank_transfer",
                                "reference": "TRX-9001"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Payment"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 140,
                                        "number": "PV-2026-00140",
                                        "status": "posted",
                                        "supplier": {
                                            "id": 15,
                                            "code": "S-0015",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                        },
                                        "date": "2026-11-12",
                                        "amount": "200.00",
                                        "method": "bank_transfer",
                                        "account": {
                                            "id": 12,
                                            "code": "11103",
                                            "name": "11103 \u2014 \u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                        },
                                        "reference": "TRX-9001",
                                        "notes": null,
                                        "invoices": [
                                            {
                                                "id": 77,
                                                "number": "PUR-2026-00077",
                                                "amount": "200.00"
                                            }
                                        ],
                                        "unallocated": "0.00",
                                        "cancelled_at": null,
                                        "created_at": "2026-11-12T10:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/payments": {
            "get": {
                "operationId": "listPayments",
                "tags": [
                    "payments"
                ],
                "summary": "List payment vouchers",
                "description": "Payments to suppliers page by page, filtered by supplier, invoice, status, reference and date.\n\nScope: `payments.read`",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "supplier_id",
                        "in": "query",
                        "description": "The supplier\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 15
                    },
                    {
                        "name": "invoice_id",
                        "in": "query",
                        "description": "Receipts that settled this invoice.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 77
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "For invoices: draft, issued or void. For receipts: posted or cancelled. For journal entries: draft or posted. For webhook deliveries: pending, delivered or failed.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "posted"
                    },
                    {
                        "name": "reference",
                        "in": "query",
                        "description": "Your reference, such as your store\u2019s order number, up to 60 characters. Searchable later.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "TRX-9001"
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Payment"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 140,
                                            "number": "PV-2026-00140",
                                            "status": "posted",
                                            "supplier": {
                                                "id": 15,
                                                "code": "S-0015",
                                                "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                            },
                                            "date": "2026-11-12",
                                            "amount": "200.00",
                                            "method": "bank_transfer",
                                            "account": {
                                                "id": 12,
                                                "code": "11103",
                                                "name": "11103 \u2014 \u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                            },
                                            "reference": "TRX-9001",
                                            "notes": null,
                                            "invoices": [
                                                {
                                                    "id": 77,
                                                    "number": "PUR-2026-00077",
                                                    "amount": "200.00"
                                                }
                                            ],
                                            "unallocated": "0.00",
                                            "cancelled_at": null,
                                            "created_at": "2026-11-12T10:00:00+03:00"
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "createPayment",
                "tags": [
                    "payments"
                ],
                "summary": "Record a payment voucher",
                "description": "Records money paid to a supplier: it settles the invoices named, or their open invoices oldest first with allocate: auto. Whatever settles no invoice stays as an advance with them. A test key never records one.\n\nScope: `payments.write`",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/PaymentVoucherInput"
                            },
                            "example": {
                                "supplier_id": 15,
                                "amount": "200.00",
                                "method": "bank_transfer",
                                "allocate": "auto"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Payment"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 140,
                                        "number": "PV-2026-00140",
                                        "status": "posted",
                                        "supplier": {
                                            "id": 15,
                                            "code": "S-0015",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                        },
                                        "date": "2026-11-12",
                                        "amount": "200.00",
                                        "method": "bank_transfer",
                                        "account": {
                                            "id": 12,
                                            "code": "11103",
                                            "name": "11103 \u2014 \u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                        },
                                        "reference": "TRX-9001",
                                        "notes": null,
                                        "invoices": [
                                            {
                                                "id": 77,
                                                "number": "PUR-2026-00077",
                                                "amount": "200.00"
                                            }
                                        ],
                                        "unallocated": "0.00",
                                        "cancelled_at": null,
                                        "created_at": "2026-11-12T10:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/payments/{id}": {
            "get": {
                "operationId": "getPayment",
                "tags": [
                    "payments"
                ],
                "summary": "Get a payment voucher",
                "description": "The voucher, its amount and account, and the invoices it settled.\n\nScope: `payments.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Payment"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 140,
                                        "number": "PV-2026-00140",
                                        "status": "posted",
                                        "supplier": {
                                            "id": 15,
                                            "code": "S-0015",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                        },
                                        "date": "2026-11-12",
                                        "amount": "200.00",
                                        "method": "bank_transfer",
                                        "account": {
                                            "id": 12,
                                            "code": "11103",
                                            "name": "11103 \u2014 \u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                        },
                                        "reference": "TRX-9001",
                                        "notes": null,
                                        "invoices": [
                                            {
                                                "id": 77,
                                                "number": "PUR-2026-00077",
                                                "amount": "200.00"
                                            }
                                        ],
                                        "unallocated": "0.00",
                                        "cancelled_at": null,
                                        "created_at": "2026-11-12T10:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/payments/{id}/cancel": {
            "post": {
                "operationId": "cancelPayment",
                "tags": [
                    "payments"
                ],
                "summary": "Cancel a payment voucher",
                "description": "Reverses the voucher\u2019s entry, and the invoices it settled are owed again.\n\nScope: `payments.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Payment"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 140,
                                        "number": "PV-2026-00140",
                                        "status": "cancelled",
                                        "supplier": {
                                            "id": 15,
                                            "code": "S-0015",
                                            "name": "\u0645\u0648\u0631\u062f \u0627\u0644\u0642\u0647\u0648\u0629"
                                        },
                                        "date": "2026-11-12",
                                        "amount": "200.00",
                                        "method": "bank_transfer",
                                        "account": {
                                            "id": 12,
                                            "code": "11103",
                                            "name": "11103 \u2014 \u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                        },
                                        "reference": "TRX-9001",
                                        "notes": null,
                                        "invoices": [
                                            {
                                                "id": 77,
                                                "number": "PUR-2026-00077",
                                                "amount": "200.00"
                                            }
                                        ],
                                        "unallocated": "0.00",
                                        "cancelled_at": "2026-11-13T09:00:00+03:00",
                                        "created_at": "2026-11-12T10:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/items": {
            "get": {
                "operationId": "listItems",
                "tags": [
                    "items"
                ],
                "summary": "List items",
                "description": "Items page by page, searched by name or code, or by barcode (including unit barcodes), filtered by type, status and last change.\n\nScope: `items.read`",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "description": "Text to search for.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "\u0627\u0633\u062a\u0634\u0627\u0631\u0629"
                    },
                    {
                        "name": "barcode",
                        "in": "query",
                        "description": "The first barcode: Latin letters, digits and hyphens, 4 to 40. Made up for a product when the business\u2019s settings say so.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "6281000000017"
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "description": "The type: individual or business for a customer; product or service for an item; asset, liability, equity, revenue or expense for an account.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "product"
                    },
                    {
                        "name": "active",
                        "in": "query",
                        "description": "true for active only, false for stopped only.",
                        "schema": {
                            "type": "boolean"
                        },
                        "example": true
                    },
                    {
                        "name": "updated_since",
                        "in": "query",
                        "description": "Changed since this date or time (ISO 8601).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-01"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Item"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 8,
                                            "code": "PRD-001",
                                            "barcode": "6281000000024",
                                            "type": "product",
                                            "name": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a",
                                            "name_en": "Arabic coffee 500g",
                                            "description": null,
                                            "category": {
                                                "id": 3,
                                                "name": "\u0645\u0634\u0631\u0648\u0628\u0627\u062a"
                                            },
                                            "barcodes": [],
                                            "unit": {
                                                "id": 1,
                                                "name": "\u062d\u0628\u0629"
                                            },
                                            "units": [
                                                {
                                                    "id": 2,
                                                    "factor": "12.000",
                                                    "sale_price": "500.00",
                                                    "barcode": "6281000000031"
                                                }
                                            ],
                                            "sale_price": "45.00",
                                            "tax": "standard",
                                            "tracks_stock": true,
                                            "reorder_level": "10.000",
                                            "is_active": true,
                                            "image": "https://your-business.qaydtech.com/api/v1/items/8/image",
                                            "updated_at": "2026-10-20T11:00:00+03:00"
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "createItem",
                "tags": [
                    "items"
                ],
                "summary": "Add an item",
                "description": "Adds a product (its stock is tracked) or a service. Its code is made up when not sent, and the usual unit and tax are taken when not named. A barcode is never repeated among items or their units.\n\nScope: `items.write`",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ItemInput"
                            },
                            "example": {
                                "type": "product",
                                "code": "PRD-001",
                                "name": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a",
                                "name_en": "Arabic coffee 500g",
                                "unit_id": 1,
                                "category_id": 3,
                                "sale_price": "45.00",
                                "purchase_price": "30.00",
                                "tax": "standard",
                                "barcode": "6281000000024",
                                "units": [
                                    {
                                        "unit_id": 2,
                                        "factor": 12,
                                        "sale_price": "500.00",
                                        "barcode": "6281000000031"
                                    }
                                ],
                                "reorder_level": 10,
                                "is_active": true,
                                "image": "https://cdn.example.sa/products/coffee.jpg"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Item"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 8,
                                        "code": "PRD-001",
                                        "barcode": "6281000000024",
                                        "type": "product",
                                        "name": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a",
                                        "name_en": "Arabic coffee 500g",
                                        "description": null,
                                        "category": {
                                            "id": 3,
                                            "name": "\u0645\u0634\u0631\u0648\u0628\u0627\u062a"
                                        },
                                        "barcodes": [],
                                        "unit": {
                                            "id": 1,
                                            "name": "\u062d\u0628\u0629"
                                        },
                                        "units": [
                                            {
                                                "id": 2,
                                                "factor": "12.000",
                                                "sale_price": "500.00",
                                                "barcode": "6281000000031"
                                            }
                                        ],
                                        "sale_price": "45.00",
                                        "tax": "standard",
                                        "tracks_stock": true,
                                        "reorder_level": "10.000",
                                        "is_active": true,
                                        "image": "https://your-business.qaydtech.com/api/v1/items/8/image",
                                        "updated_at": "2026-10-20T11:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/items/{id}": {
            "get": {
                "operationId": "getItem",
                "tags": [
                    "items"
                ],
                "summary": "Get an item",
                "description": "An item by number: its price, tax, units, barcodes and category.\n\nScope: `items.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Item"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 8,
                                        "code": "PRD-001",
                                        "barcode": "6281000000024",
                                        "type": "product",
                                        "name": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a",
                                        "name_en": "Arabic coffee 500g",
                                        "description": null,
                                        "category": {
                                            "id": 3,
                                            "name": "\u0645\u0634\u0631\u0648\u0628\u0627\u062a"
                                        },
                                        "barcodes": [],
                                        "unit": {
                                            "id": 1,
                                            "name": "\u062d\u0628\u0629"
                                        },
                                        "units": [
                                            {
                                                "id": 2,
                                                "factor": "12.000",
                                                "sale_price": "500.00",
                                                "barcode": "6281000000031"
                                            }
                                        ],
                                        "sale_price": "45.00",
                                        "tax": "standard",
                                        "tracks_stock": true,
                                        "reorder_level": "10.000",
                                        "is_active": true,
                                        "image": "https://your-business.qaydtech.com/api/v1/items/8/image",
                                        "updated_at": "2026-10-20T11:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "updateItem",
                "tags": [
                    "items"
                ],
                "summary": "Update an item",
                "description": "Changes only what is sent. Units or barcodes, when sent, replace the ones it had. An item\u2019s own unit never changes once its stock has moved.\n\nScope: `items.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ItemInput"
                            },
                            "example": {
                                "sale_price": "120.00",
                                "is_active": true
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Item"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 8,
                                        "code": "PRD-001",
                                        "barcode": "6281000000024",
                                        "type": "product",
                                        "name": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a",
                                        "name_en": "Arabic coffee 500g",
                                        "description": null,
                                        "category": {
                                            "id": 3,
                                            "name": "\u0645\u0634\u0631\u0648\u0628\u0627\u062a"
                                        },
                                        "barcodes": [],
                                        "unit": {
                                            "id": 1,
                                            "name": "\u062d\u0628\u0629"
                                        },
                                        "units": [
                                            {
                                                "id": 2,
                                                "factor": "12.000",
                                                "sale_price": "500.00",
                                                "barcode": "6281000000031"
                                            }
                                        ],
                                        "sale_price": "120.00",
                                        "tax": "standard",
                                        "tracks_stock": true,
                                        "reorder_level": "10.000",
                                        "is_active": true,
                                        "image": "https://your-business.qaydtech.com/api/v1/items/8/image",
                                        "updated_at": "2026-10-20T11:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/items/{id}/image": {
            "get": {
                "operationId": "getItemImage",
                "tags": [
                    "items"
                ],
                "summary": "Get an item\u2019s image",
                "description": "The item\u2019s picture bytes (PNG, JPG or WebP), or its small copy with size=thumb. Not found when the item has no picture.\n\nScope: `items.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "name": "size",
                        "in": "query",
                        "description": "thumb for the small copy; otherwise the full picture.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "thumb"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The image bytes",
                        "content": {
                            "image/png": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            },
                            "image/jpeg": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            },
                            "image/webp": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/units": {
            "get": {
                "operationId": "units",
                "tags": [
                    "items"
                ],
                "summary": "Units",
                "description": "The units of measure: their number goes in an item\u2019s unit_id and its units.\n\nScope: `items.read`",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 1,
                                            "key": "piece",
                                            "name": "\u062d\u0628\u0629"
                                        },
                                        {
                                            "id": 2,
                                            "key": "box",
                                            "name": "\u0643\u0631\u062a\u0648\u0646"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/item-categories": {
            "get": {
                "operationId": "itemCategories",
                "tags": [
                    "items"
                ],
                "summary": "Item categories",
                "description": "Item categories by number, for category_id.\n\nScope: `items.read`",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 3,
                                            "name": "\u0645\u0634\u0631\u0648\u0628\u0627\u062a"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/stock": {
            "get": {
                "operationId": "listStock",
                "tags": [
                    "stock"
                ],
                "summary": "Stock levels",
                "description": "Items whose stock is tracked, with how much of each every warehouse holds and all together, their reorder level, and low when it is reached. Made for syncing what your store shows as available. Quantities are in the item\u2019s own unit, up to 3 decimals.\n\nScope: `stock.read`",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "warehouse_id",
                        "in": "query",
                        "description": "The warehouse number from GET /warehouses. Defaults to the main warehouse.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "item_ids",
                        "in": "query",
                        "description": "Item numbers separated by commas, up to 100.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "7,8,9"
                    },
                    {
                        "name": "code",
                        "in": "query",
                        "description": "The item code: Latin letters and digits up to 30, made up when not sent. In stock levels: the item with this code.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "PRD-001"
                    },
                    {
                        "name": "active",
                        "in": "query",
                        "description": "true for active only, false for stopped only.",
                        "schema": {
                            "type": "boolean"
                        },
                        "example": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "item_id": 8,
                                            "code": "PRD-001",
                                            "name": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a",
                                            "quantity": "42.000",
                                            "reorder_level": "10.000",
                                            "low": false,
                                            "warehouses": [
                                                {
                                                    "warehouse_id": 1,
                                                    "warehouse": "\u0627\u0644\u0645\u0633\u062a\u0648\u062f\u0639 \u0627\u0644\u0631\u0626\u064a\u0633\u064a",
                                                    "quantity": "30.000"
                                                },
                                                {
                                                    "warehouse_id": 2,
                                                    "warehouse": "\u0641\u0631\u0639 \u062c\u062f\u0629",
                                                    "quantity": "12.000"
                                                }
                                            ]
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/stock/documents": {
            "get": {
                "operationId": "listStockDocuments",
                "tags": [
                    "stock"
                ],
                "summary": "Stock documents",
                "description": "Stock documents page by page: counts, transfers, receipts and issues, by kind, status, warehouse and date.\n\nScope: `stock.read`",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "kind",
                        "in": "query",
                        "description": "The kind: adjustment (a count: the quantity really there), transfer, receipt or issue. For aging: customers or suppliers.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "adjustment"
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "For invoices: draft, issued or void. For receipts: posted or cancelled. For journal entries: draft or posted. For webhook deliveries: pending, delivered or failed.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "posted"
                    },
                    {
                        "name": "warehouse_id",
                        "in": "query",
                        "description": "The warehouse number from GET /warehouses. Defaults to the main warehouse.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 61,
                                            "number": "ADJ-2026-00061",
                                            "kind": "adjustment",
                                            "status": "posted",
                                            "date": "2026-11-10",
                                            "warehouse": {
                                                "id": 1,
                                                "name": "\u0627\u0644\u0645\u0633\u062a\u0648\u062f\u0639 \u0627\u0644\u0631\u0626\u064a\u0633\u064a"
                                            },
                                            "to_warehouse": null,
                                            "account_id": 31,
                                            "reason": "\u062c\u0631\u062f \u0646\u0647\u0627\u064a\u0629 \u0627\u0644\u0634\u0647\u0631",
                                            "notes": null,
                                            "total": "0.00",
                                            "lines": [
                                                {
                                                    "item": {
                                                        "id": 8,
                                                        "code": "PRD-001",
                                                        "name": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a"
                                                    },
                                                    "quantity": "40.000",
                                                    "unit_cost": null
                                                }
                                            ],
                                            "posted_at": "2026-11-10T18:00:00+03:00",
                                            "created_at": "2026-11-10T17:55:00+03:00"
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "createStockDocument",
                "tags": [
                    "stock"
                ],
                "summary": "Record a stock movement",
                "description": "A count that says what a warehouse really holds so the difference is adjusted, a transfer between two warehouses, goods received, or goods issued, without an invoice. Saved as a draft or posted at once with post: true. Items in their own unit, each once. A test key saves drafts only.\n\nScope: `stock.write`",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/StockDocumentInput"
                            },
                            "example": {
                                "kind": "adjustment",
                                "warehouse_id": 1,
                                "date": "2026-11-10",
                                "reason": "\u062c\u0631\u062f \u0646\u0647\u0627\u064a\u0629 \u0627\u0644\u0634\u0647\u0631",
                                "post": true,
                                "lines": [
                                    {
                                        "item_id": 8,
                                        "quantity": 40
                                    }
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "id": 61,
                                        "number": "ADJ-2026-00061",
                                        "kind": "adjustment",
                                        "status": "posted",
                                        "date": "2026-11-10",
                                        "warehouse": {
                                            "id": 1,
                                            "name": "\u0627\u0644\u0645\u0633\u062a\u0648\u062f\u0639 \u0627\u0644\u0631\u0626\u064a\u0633\u064a"
                                        },
                                        "to_warehouse": null,
                                        "account_id": 31,
                                        "reason": "\u062c\u0631\u062f \u0646\u0647\u0627\u064a\u0629 \u0627\u0644\u0634\u0647\u0631",
                                        "notes": null,
                                        "total": "0.00",
                                        "lines": [
                                            {
                                                "item": {
                                                    "id": 8,
                                                    "code": "PRD-001",
                                                    "name": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a"
                                                },
                                                "quantity": "40.000",
                                                "unit_cost": null
                                            }
                                        ],
                                        "posted_at": "2026-11-10T18:00:00+03:00",
                                        "created_at": "2026-11-10T17:55:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/stock/documents/{id}": {
            "get": {
                "operationId": "getStockDocument",
                "tags": [
                    "stock"
                ],
                "summary": "Get a stock document",
                "description": "A stock document with its lines.\n\nScope: `stock.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "id": 61,
                                        "number": "ADJ-2026-00061",
                                        "kind": "adjustment",
                                        "status": "posted",
                                        "date": "2026-11-10",
                                        "warehouse": {
                                            "id": 1,
                                            "name": "\u0627\u0644\u0645\u0633\u062a\u0648\u062f\u0639 \u0627\u0644\u0631\u0626\u064a\u0633\u064a"
                                        },
                                        "to_warehouse": null,
                                        "account_id": 31,
                                        "reason": "\u062c\u0631\u062f \u0646\u0647\u0627\u064a\u0629 \u0627\u0644\u0634\u0647\u0631",
                                        "notes": null,
                                        "total": "0.00",
                                        "lines": [
                                            {
                                                "item": {
                                                    "id": 8,
                                                    "code": "PRD-001",
                                                    "name": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a"
                                                },
                                                "quantity": "40.000",
                                                "unit_cost": null
                                            }
                                        ],
                                        "posted_at": "2026-11-10T18:00:00+03:00",
                                        "created_at": "2026-11-10T17:55:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "deleteStockDocument",
                "tags": [
                    "stock"
                ],
                "summary": "Delete a stock draft",
                "description": "Deletes a draft. A posted document is never deleted: it is corrected by another one.\n\nScope: `stock.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "204": {
                        "description": "Deleted"
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/stock/documents/{id}/post": {
            "post": {
                "operationId": "postStockDocument",
                "tags": [
                    "stock"
                ],
                "summary": "Post a stock document",
                "description": "Posts a draft: the stock moves, the entry is written and it takes its number. A test key never posts.\n\nScope: `stock.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "id": 61,
                                        "number": "ADJ-2026-00061",
                                        "kind": "adjustment",
                                        "status": "posted",
                                        "date": "2026-11-10",
                                        "warehouse": {
                                            "id": 1,
                                            "name": "\u0627\u0644\u0645\u0633\u062a\u0648\u062f\u0639 \u0627\u0644\u0631\u0626\u064a\u0633\u064a"
                                        },
                                        "to_warehouse": null,
                                        "account_id": 31,
                                        "reason": "\u062c\u0631\u062f \u0646\u0647\u0627\u064a\u0629 \u0627\u0644\u0634\u0647\u0631",
                                        "notes": null,
                                        "total": "0.00",
                                        "lines": [
                                            {
                                                "item": {
                                                    "id": 8,
                                                    "code": "PRD-001",
                                                    "name": "\u0642\u0647\u0648\u0629 \u0639\u0631\u0628\u064a\u0629 500\u063a"
                                                },
                                                "quantity": "40.000",
                                                "unit_cost": null
                                            }
                                        ],
                                        "posted_at": "2026-11-10T18:00:00+03:00",
                                        "created_at": "2026-11-10T17:55:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/items/{id}/movements": {
            "get": {
                "operationId": "itemMovements",
                "tags": [
                    "stock"
                ],
                "summary": "Item movements",
                "description": "Every movement of an item\u2019s stock, latest first: sale, purchase, return, transfer or adjustment, with its warehouse, its quantity (negative going out) and the document that moved it.\n\nScope: `stock.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "warehouse_id",
                        "in": "query",
                        "description": "The warehouse number from GET /warehouses. Defaults to the main warehouse.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 9012,
                                            "date": "2026-11-10",
                                            "kind": "sale",
                                            "warehouse": {
                                                "id": 1,
                                                "name": "\u0627\u0644\u0645\u0633\u062a\u0648\u062f\u0639 \u0627\u0644\u0631\u0626\u064a\u0633\u064a"
                                            },
                                            "quantity": "-2.000",
                                            "source": {
                                                "type": "sales_invoice",
                                                "id": 318
                                            }
                                        },
                                        {
                                            "id": 8990,
                                            "date": "2026-11-02",
                                            "kind": "purchase",
                                            "warehouse": {
                                                "id": 1,
                                                "name": "\u0627\u0644\u0645\u0633\u062a\u0648\u062f\u0639 \u0627\u0644\u0631\u0626\u064a\u0633\u064a"
                                            },
                                            "quantity": "24.000",
                                            "source": {
                                                "type": "purchase_invoice",
                                                "id": 77
                                            }
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/accounts": {
            "get": {
                "operationId": "listAccounts",
                "tags": [
                    "accounts"
                ],
                "summary": "Chart of accounts",
                "description": "Every account in the order of its codes: groups and the posting accounts under them, with each one\u2019s type and normal balance. Filter by type, posting accounts only (posting=true), and status.\n\nScope: `accounts.read`",
                "parameters": [
                    {
                        "name": "type",
                        "in": "query",
                        "description": "The type: individual or business for a customer; product or service for an item; asset, liability, equity, revenue or expense for an account.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "asset"
                    },
                    {
                        "name": "posting",
                        "in": "query",
                        "description": "true for posting accounts only (those entries are written on), false for groups only.",
                        "schema": {
                            "type": "boolean"
                        },
                        "example": true
                    },
                    {
                        "name": "active",
                        "in": "query",
                        "description": "true for active only, false for stopped only.",
                        "schema": {
                            "type": "boolean"
                        },
                        "example": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 12,
                                            "code": "11103",
                                            "name": "\u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a",
                                            "name_en": "Bank - current account",
                                            "type": "asset",
                                            "normal_balance": "debit",
                                            "is_group": false,
                                            "parent_id": 4,
                                            "level": 4,
                                            "system_key": "bank",
                                            "is_active": true
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/accounts/{id}/ledger": {
            "get": {
                "operationId": "accountLedger",
                "tags": [
                    "accounts"
                ],
                "summary": "Account ledger",
                "description": "What was posted on a posting account between two days: the balance before, every line with its entry and the balance after it (debits less credits), and the balance at the end. This year to today when no days are named; up to 5,000 lines. Needs the ledger.view permission.\n\nScope: `accounts.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-01-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "account": {
                                            "id": 12,
                                            "code": "11103",
                                            "name": "\u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a",
                                            "name_en": "Bank - current account",
                                            "type": "asset",
                                            "normal_balance": "debit",
                                            "is_group": false,
                                            "parent_id": 4,
                                            "level": 4,
                                            "system_key": "bank",
                                            "is_active": true
                                        },
                                        "from": "2026-01-01",
                                        "to": "2026-11-30",
                                        "opening_balance": "0.00",
                                        "lines": [
                                            {
                                                "date": "2026-11-10",
                                                "entry_id": 905,
                                                "entry_number": "JE-2026-00905",
                                                "reference": "RV-2026-00512",
                                                "source": "receipt",
                                                "description": "\u0633\u0646\u062f \u0642\u0628\u0636 RV-2026-00512",
                                                "contact_id": 42,
                                                "cost_center_id": null,
                                                "debit": "258.75",
                                                "credit": "0.00",
                                                "balance": "258.75"
                                            }
                                        ],
                                        "closing_balance": "258.75"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/cost-centers": {
            "get": {
                "operationId": "listCostCenters",
                "tags": [
                    "accounts"
                ],
                "summary": "Cost centres",
                "description": "The cost centres journal lines can be spread over, for cost_center_id. Open when the plan includes cost centres.\n\nScope: `accounts.read`",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 2,
                                            "code": "CC-01",
                                            "name": "\u0641\u0631\u0639 \u0627\u0644\u0631\u064a\u0627\u0636",
                                            "is_active": true
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/journal-entries": {
            "get": {
                "operationId": "listJournalEntries",
                "tags": [
                    "journal"
                ],
                "summary": "List journal entries",
                "description": "Every entry in the books, those written by documents and those written by hand, latest first: filtered by status, source (manual, sales_invoice, receipt\u2026), number, reference, an account in its lines and date.\n\nScope: `journal.read`",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "For invoices: draft, issued or void. For receipts: posted or cancelled. For journal entries: draft or posted. For webhook deliveries: pending, delivered or failed.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "posted"
                    },
                    {
                        "name": "source",
                        "in": "query",
                        "description": "What wrote the entry: manual, reversal, opening, sales_invoice, credit_note, receipt, purchase_invoice, payment\u2026",
                        "schema": {
                            "type": "string"
                        },
                        "example": "manual"
                    },
                    {
                        "name": "number",
                        "in": "query",
                        "description": "The invoice number as it is.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "JE-2026-00910"
                    },
                    {
                        "name": "reference",
                        "in": "query",
                        "description": "Your reference, such as your store\u2019s order number, up to 60 characters. Searchable later.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "ACC-77"
                    },
                    {
                        "name": "account_id",
                        "in": "query",
                        "description": "For payments and refunds: the cash box or bank account from GET /payment-accounts, defaulting to the method\u2019s account. For stock documents: the offset account, defaulting to stock adjustments.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 12
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/JournalEntry"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 910,
                                            "number": "JE-2026-00910",
                                            "status": "posted",
                                            "source": "manual",
                                            "date": "2026-11-15",
                                            "description": "\u0625\u062b\u0628\u0627\u062a \u0625\u064a\u062c\u0627\u0631 \u0646\u0648\u0641\u0645\u0628\u0631",
                                            "reference": "ACC-77",
                                            "total": "5000.00",
                                            "is_balanced": true,
                                            "reversal_of_id": null,
                                            "lines": [
                                                {
                                                    "account": {
                                                        "id": 51,
                                                        "code": "5201",
                                                        "name": "\u0627\u0644\u0625\u064a\u062c\u0627\u0631\u0627\u062a"
                                                    },
                                                    "contact_id": null,
                                                    "cost_center_id": null,
                                                    "description": null,
                                                    "debit": "5000.00",
                                                    "credit": "0.00"
                                                },
                                                {
                                                    "account": {
                                                        "id": 12,
                                                        "code": "11103",
                                                        "name": "\u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                                    },
                                                    "contact_id": null,
                                                    "cost_center_id": null,
                                                    "description": null,
                                                    "debit": "0.00",
                                                    "credit": "5000.00"
                                                }
                                            ],
                                            "posted_at": "2026-11-15T09:00:00+03:00",
                                            "created_at": "2026-11-15T09:00:00+03:00"
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "createJournalEntry",
                "tags": [
                    "journal"
                ],
                "summary": "Write a journal entry",
                "description": "A manual entry: saved as a draft \u2014 out of balance if need be \u2014 or posted at once with post: true, which asks that debits equal credits and that the date falls in an open fiscal period. Each line is a debit or a credit on a posting account. Amounts in riyals, up to two decimals. A test key writes drafts only.\n\nScope: `journal.write`",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/JournalEntryInput"
                            },
                            "example": {
                                "date": "2026-11-15",
                                "description": "\u0625\u062b\u0628\u0627\u062a \u0625\u064a\u062c\u0627\u0631 \u0646\u0648\u0641\u0645\u0628\u0631",
                                "reference": "ACC-77",
                                "post": true,
                                "lines": [
                                    {
                                        "account_id": 51,
                                        "debit": "5000.00"
                                    },
                                    {
                                        "account_id": 12,
                                        "credit": "5000.00"
                                    }
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/JournalEntry"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 910,
                                        "number": "JE-2026-00910",
                                        "status": "posted",
                                        "source": "manual",
                                        "date": "2026-11-15",
                                        "description": "\u0625\u062b\u0628\u0627\u062a \u0625\u064a\u062c\u0627\u0631 \u0646\u0648\u0641\u0645\u0628\u0631",
                                        "reference": "ACC-77",
                                        "total": "5000.00",
                                        "is_balanced": true,
                                        "reversal_of_id": null,
                                        "lines": [
                                            {
                                                "account": {
                                                    "id": 51,
                                                    "code": "5201",
                                                    "name": "\u0627\u0644\u0625\u064a\u062c\u0627\u0631\u0627\u062a"
                                                },
                                                "contact_id": null,
                                                "cost_center_id": null,
                                                "description": null,
                                                "debit": "5000.00",
                                                "credit": "0.00"
                                            },
                                            {
                                                "account": {
                                                    "id": 12,
                                                    "code": "11103",
                                                    "name": "\u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                                },
                                                "contact_id": null,
                                                "cost_center_id": null,
                                                "description": null,
                                                "debit": "0.00",
                                                "credit": "5000.00"
                                            }
                                        ],
                                        "posted_at": "2026-11-15T09:00:00+03:00",
                                        "created_at": "2026-11-15T09:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/journal-entries/{id}": {
            "get": {
                "operationId": "getJournalEntry",
                "tags": [
                    "journal"
                ],
                "summary": "Get a journal entry",
                "description": "An entry with its lines: account, debit, credit, customer or supplier and cost centre.\n\nScope: `journal.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/JournalEntry"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 910,
                                        "number": "JE-2026-00910",
                                        "status": "posted",
                                        "source": "manual",
                                        "date": "2026-11-15",
                                        "description": "\u0625\u062b\u0628\u0627\u062a \u0625\u064a\u062c\u0627\u0631 \u0646\u0648\u0641\u0645\u0628\u0631",
                                        "reference": "ACC-77",
                                        "total": "5000.00",
                                        "is_balanced": true,
                                        "reversal_of_id": null,
                                        "lines": [
                                            {
                                                "account": {
                                                    "id": 51,
                                                    "code": "5201",
                                                    "name": "\u0627\u0644\u0625\u064a\u062c\u0627\u0631\u0627\u062a"
                                                },
                                                "contact_id": null,
                                                "cost_center_id": null,
                                                "description": null,
                                                "debit": "5000.00",
                                                "credit": "0.00"
                                            },
                                            {
                                                "account": {
                                                    "id": 12,
                                                    "code": "11103",
                                                    "name": "\u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                                },
                                                "contact_id": null,
                                                "cost_center_id": null,
                                                "description": null,
                                                "debit": "0.00",
                                                "credit": "5000.00"
                                            }
                                        ],
                                        "posted_at": "2026-11-15T09:00:00+03:00",
                                        "created_at": "2026-11-15T09:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "deleteJournalEntry",
                "tags": [
                    "journal"
                ],
                "summary": "Delete a journal draft",
                "description": "Deletes a manual draft. A posted entry is never deleted: it is reversed. Needs journal.delete.\n\nScope: `journal.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "204": {
                        "description": "Deleted"
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/journal-entries/{id}/post": {
            "post": {
                "operationId": "postJournalEntry",
                "tags": [
                    "journal"
                ],
                "summary": "Post a journal entry",
                "description": "Posts a manual draft once its debits equal its credits: it takes its number and reaches the ledger. Needs journal.post. A test key never posts.\n\nScope: `journal.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/JournalEntry"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 910,
                                        "number": "JE-2026-00910",
                                        "status": "posted",
                                        "source": "manual",
                                        "date": "2026-11-15",
                                        "description": "\u0625\u062b\u0628\u0627\u062a \u0625\u064a\u062c\u0627\u0631 \u0646\u0648\u0641\u0645\u0628\u0631",
                                        "reference": "ACC-77",
                                        "total": "5000.00",
                                        "is_balanced": true,
                                        "reversal_of_id": null,
                                        "lines": [
                                            {
                                                "account": {
                                                    "id": 51,
                                                    "code": "5201",
                                                    "name": "\u0627\u0644\u0625\u064a\u062c\u0627\u0631\u0627\u062a"
                                                },
                                                "contact_id": null,
                                                "cost_center_id": null,
                                                "description": null,
                                                "debit": "5000.00",
                                                "credit": "0.00"
                                            },
                                            {
                                                "account": {
                                                    "id": 12,
                                                    "code": "11103",
                                                    "name": "\u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                                },
                                                "contact_id": null,
                                                "cost_center_id": null,
                                                "description": null,
                                                "debit": "0.00",
                                                "credit": "5000.00"
                                            }
                                        ],
                                        "posted_at": "2026-11-15T09:00:00+03:00",
                                        "created_at": "2026-11-15T09:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/journal-entries/{id}/reverse": {
            "post": {
                "operationId": "reverseJournalEntry",
                "tags": [
                    "journal"
                ],
                "summary": "Reverse a journal entry",
                "description": "Undoes a posted manual entry with a posted entry the other way round, on the date sent or today. An entry written by a document is undone with its document. Needs journal.reverse.\n\nScope: `journal.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/JournalEntry"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 911,
                                        "number": "JE-2026-00911",
                                        "status": "posted",
                                        "source": "reversal",
                                        "date": "2026-11-30",
                                        "description": "\u0639\u0643\u0633 \u0642\u064a\u062f JE-2026-00910",
                                        "reference": "ACC-77",
                                        "total": "5000.00",
                                        "is_balanced": true,
                                        "reversal_of_id": 910,
                                        "lines": [
                                            {
                                                "account": {
                                                    "id": 51,
                                                    "code": "5201",
                                                    "name": "\u0627\u0644\u0625\u064a\u062c\u0627\u0631\u0627\u062a"
                                                },
                                                "contact_id": null,
                                                "cost_center_id": null,
                                                "description": null,
                                                "debit": "0.00",
                                                "credit": "5000.00"
                                            },
                                            {
                                                "account": {
                                                    "id": 12,
                                                    "code": "11103",
                                                    "name": "\u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a"
                                                },
                                                "contact_id": null,
                                                "cost_center_id": null,
                                                "description": null,
                                                "debit": "5000.00",
                                                "credit": "0.00"
                                            }
                                        ],
                                        "posted_at": "2026-11-15T09:00:00+03:00",
                                        "created_at": "2026-11-15T09:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/reports/trial-balance": {
            "get": {
                "operationId": "trialBalance",
                "tags": [
                    "reports"
                ],
                "summary": "Trial balance",
                "description": "Every account with its balance before the period, its debits and credits in it, and its balance at the end; a group adds up the accounts under it. Accounts that never moved are left out unless with_empty=true. This year to today by default. Needs reports.accounting and the plan\u2019s financial reports.\n\nScope: `reports.read`",
                "parameters": [
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-01-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    },
                    {
                        "name": "with_empty",
                        "in": "query",
                        "description": "true to include accounts that never moved.",
                        "schema": {
                            "type": "boolean"
                        },
                        "example": false
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "from": "2026-01-01",
                                        "to": "2026-11-30",
                                        "rows": [
                                            {
                                                "account": {
                                                    "id": 12,
                                                    "code": "11103",
                                                    "name": "\u0627\u0644\u0628\u0646\u0643 - \u0627\u0644\u062d\u0633\u0627\u0628 \u0627\u0644\u062c\u0627\u0631\u064a",
                                                    "is_group": false,
                                                    "level": 4
                                                },
                                                "opening_debit": "0.00",
                                                "opening_credit": "0.00",
                                                "debit": "258.75",
                                                "credit": "0.00",
                                                "closing_debit": "258.75",
                                                "closing_credit": "0.00"
                                            }
                                        ],
                                        "totals": {
                                            "opening_debit": "0.00",
                                            "opening_credit": "0.00",
                                            "debit": "258.75",
                                            "credit": "258.75",
                                            "closing_debit": "258.75",
                                            "closing_credit": "258.75"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/reports/income-statement": {
            "get": {
                "operationId": "incomeStatement",
                "tags": [
                    "reports"
                ],
                "summary": "Income statement",
                "description": "Revenue, cost of sales, gross profit, other expenses and net profit for a period, each section by its groups and accounts. Year-closing entries are left out, so a closed year still shows its result.\n\nScope: `reports.read`",
                "parameters": [
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-01-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "from": "2026-01-01",
                                        "to": "2026-11-30",
                                        "revenue": {
                                            "groups": [
                                                {
                                                    "account": {
                                                        "id": 3,
                                                        "code": "41",
                                                        "name": "\u0627\u0644\u0625\u064a\u0631\u0627\u062f\u0627\u062a",
                                                        "is_group": true,
                                                        "level": 2
                                                    },
                                                    "lines": [
                                                        {
                                                            "account": {
                                                                "id": 40,
                                                                "code": "4101",
                                                                "name": "\u0627\u0644\u0645\u0628\u064a\u0639\u0627\u062a",
                                                                "is_group": false,
                                                                "level": 3
                                                            },
                                                            "amount": "225.00"
                                                        }
                                                    ],
                                                    "total": "225.00"
                                                }
                                            ],
                                            "total": "225.00"
                                        },
                                        "cost_of_sales": {
                                            "groups": [
                                                {
                                                    "account": {
                                                        "id": 3,
                                                        "code": "41",
                                                        "name": "\u0627\u0644\u0625\u064a\u0631\u0627\u062f\u0627\u062a",
                                                        "is_group": true,
                                                        "level": 2
                                                    },
                                                    "lines": [
                                                        {
                                                            "account": {
                                                                "id": 40,
                                                                "code": "4101",
                                                                "name": "\u0627\u0644\u0645\u0628\u064a\u0639\u0627\u062a",
                                                                "is_group": false,
                                                                "level": 3
                                                            },
                                                            "amount": "120.00"
                                                        }
                                                    ],
                                                    "total": "120.00"
                                                }
                                            ],
                                            "total": "120.00"
                                        },
                                        "gross_profit": "105.00",
                                        "expenses": {
                                            "groups": [
                                                {
                                                    "account": {
                                                        "id": 3,
                                                        "code": "41",
                                                        "name": "\u0627\u0644\u0625\u064a\u0631\u0627\u062f\u0627\u062a",
                                                        "is_group": true,
                                                        "level": 2
                                                    },
                                                    "lines": [
                                                        {
                                                            "account": {
                                                                "id": 40,
                                                                "code": "4101",
                                                                "name": "\u0627\u0644\u0645\u0628\u064a\u0639\u0627\u062a",
                                                                "is_group": false,
                                                                "level": 3
                                                            },
                                                            "amount": "50.00"
                                                        }
                                                    ],
                                                    "total": "50.00"
                                                }
                                            ],
                                            "total": "50.00"
                                        },
                                        "net_profit": "55.00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/reports/balance-sheet": {
            "get": {
                "operationId": "balanceSheet",
                "tags": [
                    "reports"
                ],
                "summary": "Balance sheet",
                "description": "What the business has, owes and what belongs to its owners at the end of a day, the profit of years not yet closed shown with equity so both sides agree. Today by default.\n\nScope: `reports.read`",
                "parameters": [
                    {
                        "name": "date",
                        "in": "query",
                        "description": "The date; today when not sent.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "date": "2026-11-30",
                                        "assets": {
                                            "groups": [
                                                {
                                                    "account": {
                                                        "id": 3,
                                                        "code": "41",
                                                        "name": "\u0627\u0644\u0625\u064a\u0631\u0627\u062f\u0627\u062a",
                                                        "is_group": true,
                                                        "level": 2
                                                    },
                                                    "lines": [
                                                        {
                                                            "account": {
                                                                "id": 40,
                                                                "code": "4101",
                                                                "name": "\u0627\u0644\u0645\u0628\u064a\u0639\u0627\u062a",
                                                                "is_group": false,
                                                                "level": 3
                                                            },
                                                            "amount": "10055.00"
                                                        }
                                                    ],
                                                    "total": "10055.00"
                                                }
                                            ],
                                            "total": "10055.00"
                                        },
                                        "liabilities": {
                                            "groups": [
                                                {
                                                    "account": {
                                                        "id": 3,
                                                        "code": "41",
                                                        "name": "\u0627\u0644\u0625\u064a\u0631\u0627\u062f\u0627\u062a",
                                                        "is_group": true,
                                                        "level": 2
                                                    },
                                                    "lines": [
                                                        {
                                                            "account": {
                                                                "id": 40,
                                                                "code": "4101",
                                                                "name": "\u0627\u0644\u0645\u0628\u064a\u0639\u0627\u062a",
                                                                "is_group": false,
                                                                "level": 3
                                                            },
                                                            "amount": "0.00"
                                                        }
                                                    ],
                                                    "total": "0.00"
                                                }
                                            ],
                                            "total": "0.00"
                                        },
                                        "equity": {
                                            "groups": [
                                                {
                                                    "account": {
                                                        "id": 3,
                                                        "code": "41",
                                                        "name": "\u0627\u0644\u0625\u064a\u0631\u0627\u062f\u0627\u062a",
                                                        "is_group": true,
                                                        "level": 2
                                                    },
                                                    "lines": [
                                                        {
                                                            "account": {
                                                                "id": 40,
                                                                "code": "4101",
                                                                "name": "\u0627\u0644\u0645\u0628\u064a\u0639\u0627\u062a",
                                                                "is_group": false,
                                                                "level": 3
                                                            },
                                                            "amount": "10000.00"
                                                        }
                                                    ],
                                                    "total": "10000.00"
                                                }
                                            ],
                                            "total": "10000.00"
                                        },
                                        "unclosed_profit": "55.00",
                                        "total_equity": "10055.00",
                                        "total_liabilities_and_equity": "10055.00",
                                        "balanced": true
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/reports/vat-return": {
            "get": {
                "operationId": "vatReturn",
                "tags": [
                    "reports"
                ],
                "summary": "VAT return",
                "description": "The return\u2019s boxes for a period as the return page works them out: sales and purchases at the standard rate, zero-rated and exempt, the tax on each and what is due, checked against the VAT accounts of the ledger. This quarter so far by default. Needs reports.tax and the plan\u2019s VAT return.\n\nScope: `reports.read`",
                "parameters": [
                    {
                        "name": "from",
                        "in": "query",
                        "description": "From issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-10-01"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "To issue date (YYYY-MM-DD).",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-12-31"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "from": "2026-10-01",
                                        "to": "2026-12-31",
                                        "sales": {
                                            "standard": {
                                                "amount": "225.00",
                                                "adjustment": "0.00",
                                                "tax": "33.75"
                                            },
                                            "zero": {
                                                "amount": "0.00",
                                                "adjustment": "0.00",
                                                "tax": "0.00"
                                            },
                                            "exempt": {
                                                "amount": "0.00",
                                                "adjustment": "0.00",
                                                "tax": "0.00"
                                            },
                                            "total": {
                                                "amount": "225.00",
                                                "adjustment": "0.00",
                                                "tax": "33.75"
                                            }
                                        },
                                        "purchases": {
                                            "standard": {
                                                "amount": "200.00",
                                                "adjustment": "0.00",
                                                "tax": "30.00"
                                            },
                                            "zero": {
                                                "amount": "0.00",
                                                "adjustment": "0.00",
                                                "tax": "0.00"
                                            },
                                            "exempt": {
                                                "amount": "0.00",
                                                "adjustment": "0.00",
                                                "tax": "0.00"
                                            },
                                            "total": {
                                                "amount": "200.00",
                                                "adjustment": "0.00",
                                                "tax": "30.00"
                                            }
                                        },
                                        "output_tax": "33.75",
                                        "input_tax": "30.00",
                                        "net_tax": "3.75",
                                        "ledger": {
                                            "output": "33.75",
                                            "input": "30.00"
                                        },
                                        "reconciled": true,
                                        "unverified": {
                                            "expenses": 0,
                                            "tax": "0.00"
                                        },
                                        "documents": {
                                            "invoices": 1,
                                            "credit_notes": 0,
                                            "purchases": 1
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/reports/aging": {
            "get": {
                "operationId": "aging",
                "tags": [
                    "reports"
                ],
                "summary": "Aging",
                "description": "What each customer owes (kind=customers) or what is owed to each supplier (kind=suppliers) on a day, by how long past due: not yet due, 1\u201330, 31\u201360, 61\u201390 and over 90 days, advances apart. Needs reports.customers or reports.suppliers.\n\nScope: `reports.read`",
                "parameters": [
                    {
                        "name": "kind",
                        "in": "query",
                        "description": "The kind: adjustment (a count: the quantity really there), transfer, receipt or issue. For aging: customers or suppliers.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "customers"
                    },
                    {
                        "name": "as_of",
                        "in": "query",
                        "description": "The day the debts are aged on; today when not sent.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "2026-11-30"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "kind": "customers",
                                        "as_of": "2026-11-30",
                                        "rows": [
                                            {
                                                "contact": {
                                                    "id": 42,
                                                    "code": "C-0042",
                                                    "name": "\u0634\u0631\u0643\u0629 \u0627\u0644\u0646\u062e\u0628\u0629 \u0644\u0644\u062a\u062c\u0627\u0631\u0629"
                                                },
                                                "current": "258.75",
                                                "d30": "0.00",
                                                "d60": "0.00",
                                                "d90": "0.00",
                                                "older": "0.00",
                                                "due": "258.75",
                                                "credit": "0.00",
                                                "balance": "258.75",
                                                "invoices": 1,
                                                "oldest_days": 0
                                            }
                                        ],
                                        "totals": {
                                            "overdue": "0.00",
                                            "current": "258.75",
                                            "d30": "0.00",
                                            "d60": "0.00",
                                            "d90": "0.00",
                                            "older": "0.00",
                                            "due": "258.75",
                                            "credit": "0.00",
                                            "balance": "258.75",
                                            "invoices": 1
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/webhooks": {
            "get": {
                "operationId": "listWebhooks",
                "tags": [
                    "webhooks"
                ],
                "summary": "List webhook addresses",
                "description": "Every address the business\u2019s systems are told at, with its events, whether it is on, and how many deliveries failed in a row. The signing secret is never shown here.\n\nScope: `webhooks.read`",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/WebhookEndpoint"
                                        }
                                    }
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 3,
                                            "url": "https://example.com/webhooks/qayd",
                                            "description": "\u0627\u0644\u0645\u062a\u062c\u0631",
                                            "events": [
                                                "invoice.issued",
                                                "payment.received"
                                            ],
                                            "is_active": true,
                                            "failures": 0,
                                            "disabled_at": null,
                                            "created_by": 1,
                                            "created_at": "2026-11-10T09:00:00+03:00"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "createWebhook",
                "tags": [
                    "webhooks"
                ],
                "summary": "Add a webhook address",
                "description": "An https address on port 443 out on the internet, and the events it is told of \u2014 only those the user the key acts as may read. The answer holds its signing secret, shown this once: keep it. Up to 20 addresses. A test key never adds one.\n\nScope: `webhooks.write`",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookInput"
                            },
                            "example": {
                                "url": "https://example.com/webhooks/qayd",
                                "description": "\u0627\u0644\u0645\u062a\u062c\u0631",
                                "events": [
                                    "invoice.issued",
                                    "payment.received"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/WebhookEndpoint"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 3,
                                        "url": "https://example.com/webhooks/qayd",
                                        "description": "\u0627\u0644\u0645\u062a\u062c\u0631",
                                        "events": [
                                            "invoice.issued",
                                            "payment.received"
                                        ],
                                        "is_active": true,
                                        "failures": 0,
                                        "disabled_at": null,
                                        "created_by": 1,
                                        "created_at": "2026-11-10T09:00:00+03:00",
                                        "secret": "whsec_9fK2mQ7xR4tY8uI1oP3aS6dF0gH5jK2lZ7xC4vB9"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/webhooks/{id}": {
            "get": {
                "operationId": "getWebhook",
                "tags": [
                    "webhooks"
                ],
                "summary": "Get a webhook address",
                "description": "One address with its events and state.\n\nScope: `webhooks.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/WebhookEndpoint"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 3,
                                        "url": "https://example.com/webhooks/qayd",
                                        "description": "\u0627\u0644\u0645\u062a\u062c\u0631",
                                        "events": [
                                            "invoice.issued",
                                            "payment.received"
                                        ],
                                        "is_active": true,
                                        "failures": 0,
                                        "disabled_at": null,
                                        "created_by": 1,
                                        "created_at": "2026-11-10T09:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "updateWebhook",
                "tags": [
                    "webhooks"
                ],
                "summary": "Update a webhook address",
                "description": "Changes only what is sent. is_active: true resumes an address paused after failing, its failures forgotten. The address and its events are changed only by a user who may read every event it is told of.\n\nScope: `webhooks.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookInput"
                            },
                            "example": {
                                "events": [
                                    "invoice.issued",
                                    "invoice.paid",
                                    "payment.received"
                                ],
                                "is_active": true
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/WebhookEndpoint"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 3,
                                        "url": "https://example.com/webhooks/qayd",
                                        "description": "\u0627\u0644\u0645\u062a\u062c\u0631",
                                        "events": [
                                            "invoice.issued",
                                            "invoice.paid",
                                            "payment.received"
                                        ],
                                        "is_active": true,
                                        "failures": 0,
                                        "disabled_at": null,
                                        "created_by": 1,
                                        "created_at": "2026-11-10T09:00:00+03:00"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "deleteWebhook",
                "tags": [
                    "webhooks"
                ],
                "summary": "Delete a webhook address",
                "description": "Stops telling the address at once and forgets what was sent to it.\n\nScope: `webhooks.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "204": {
                        "description": "Deleted"
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/webhooks/{id}/rotate-secret": {
            "post": {
                "operationId": "rotateWebhookSecret",
                "tags": [
                    "webhooks"
                ],
                "summary": "Change the signing secret",
                "description": "A new signing secret replaces the old one at once; the answer holds it, shown this once. Messages already waiting are signed with the new one.\n\nScope: `webhooks.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/WebhookEndpoint"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": 3,
                                        "url": "https://example.com/webhooks/qayd",
                                        "description": "\u0627\u0644\u0645\u062a\u062c\u0631",
                                        "events": [
                                            "invoice.issued",
                                            "payment.received"
                                        ],
                                        "is_active": true,
                                        "failures": 0,
                                        "disabled_at": null,
                                        "created_by": 1,
                                        "created_at": "2026-11-10T09:00:00+03:00",
                                        "secret": "whsec_9fK2mQ7xR4tY8uI1oP3aS6dF0gH5jK2lZ7xC4vB9"
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/webhooks/{id}/ping": {
            "post": {
                "operationId": "pingWebhook",
                "tags": [
                    "webhooks"
                ],
                "summary": "Send a test message",
                "description": "Sends the address a ping event, to see it takes messages and checks their signature. Up to 5 a minute.\n\nScope: `webhooks.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    }
                ],
                "responses": {
                    "202": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/WebhookDelivery"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": "3f6d0c1e-8a2b-4c7d-9e1f-2a3b4c5d6e7f",
                                        "event": "ping",
                                        "status": "delivered",
                                        "attempts": 1,
                                        "response_status": 200,
                                        "next_attempt_at": null,
                                        "delivered_at": "2026-11-10T10:15:05+03:00",
                                        "created_at": "2026-11-10T10:15:04+03:00",
                                        "payload": {
                                            "id": "3f6d0c1e-8a2b-4c7d-9e1f-2a3b4c5d6e7f",
                                            "event": "ping",
                                            "created_at": "2026-11-10T10:15:04+03:00",
                                            "data": {
                                                "message": "\u0631\u0633\u0627\u0644\u0629 \u062a\u062c\u0631\u0628\u0629 \u0645\u0646 \u0642\u064a\u062f \u062a\u0643."
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/webhooks/{id}/deliveries": {
            "get": {
                "operationId": "listWebhookDeliveries",
                "tags": [
                    "webhooks"
                ],
                "summary": "Webhook deliveries",
                "description": "What was sent to an address, latest first: the event, whether it was delivered, still being tried or failed, the tries, the address\u2019s answer, and the message \u2014 shown only to a user who may read its event.\n\nScope: `webhooks.read`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The page number, from 1.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 1
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Rows per page, up to 100.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 25
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "For invoices: draft, issued or void. For receipts: posted or cancelled. For journal entries: draft or posted. For webhook deliveries: pending, delivered or failed.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "failed"
                    },
                    {
                        "name": "event",
                        "in": "query",
                        "description": "An event name, such as invoice.issued.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "invoice.issued"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/WebhookDelivery"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": "3f6d0c1e-8a2b-4c7d-9e1f-2a3b4c5d6e7f",
                                            "event": "invoice.issued",
                                            "status": "delivered",
                                            "attempts": 1,
                                            "response_status": 200,
                                            "next_attempt_at": null,
                                            "delivered_at": "2026-11-10T10:15:05+03:00",
                                            "created_at": "2026-11-10T10:15:04+03:00",
                                            "payload": {
                                                "id": "3f6d0c1e-8a2b-4c7d-9e1f-2a3b4c5d6e7f",
                                                "event": "invoice.issued",
                                                "created_at": "2026-11-10T10:15:04+03:00",
                                                "data": {
                                                    "id": 318,
                                                    "number": "INV-2026-00318"
                                                }
                                            }
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/webhooks/{id}/deliveries/{delivery}/retry": {
            "post": {
                "operationId": "retryWebhookDelivery",
                "tags": [
                    "webhooks"
                ],
                "summary": "Send a failed delivery again",
                "description": "Sends again a message that failed after every try, from its first try. One still being tried goes by itself.\n\nScope: `webhooks.write`",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The record\u2019s number.",
                        "schema": {
                            "type": "integer"
                        },
                        "example": 42
                    },
                    {
                        "name": "delivery",
                        "in": "path",
                        "required": true,
                        "description": "The delivery\u2019s id (a UUID), as X-Qayd-Delivery carries it.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "3f6d0c1e-8a2b-4c7d-9e1f-2a3b4c5d6e7f"
                    }
                ],
                "responses": {
                    "202": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/WebhookDelivery"
                                        }
                                    }
                                },
                                "example": {
                                    "data": {
                                        "id": "3f6d0c1e-8a2b-4c7d-9e1f-2a3b4c5d6e7f",
                                        "event": "invoice.issued",
                                        "status": "pending",
                                        "attempts": 0,
                                        "response_status": 200,
                                        "next_attempt_at": null,
                                        "delivered_at": null,
                                        "created_at": "2026-11-10T10:15:04+03:00",
                                        "payload": {
                                            "id": "3f6d0c1e-8a2b-4c7d-9e1f-2a3b4c5d6e7f",
                                            "event": "invoice.issued",
                                            "created_at": "2026-11-10T10:15:04+03:00",
                                            "data": {
                                                "id": 318,
                                                "number": "INV-2026-00318"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "webhooks": {
        "invoice.issued": {
            "post": {
                "summary": "Invoice issued",
                "parameters": [
                    {
                        "name": "X-Qayd-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "t=<unix time>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>"
                    },
                    {
                        "name": "X-Qayd-Event",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Qayd-Delivery",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Received"
                    }
                }
            }
        },
        "credit_note.issued": {
            "post": {
                "summary": "Credit note (return) issued",
                "parameters": [
                    {
                        "name": "X-Qayd-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "t=<unix time>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>"
                    },
                    {
                        "name": "X-Qayd-Event",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Qayd-Delivery",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Received"
                    }
                }
            }
        },
        "debit_note.issued": {
            "post": {
                "summary": "Debit note issued",
                "parameters": [
                    {
                        "name": "X-Qayd-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "t=<unix time>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>"
                    },
                    {
                        "name": "X-Qayd-Event",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Qayd-Delivery",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Received"
                    }
                }
            }
        },
        "invoice.einvoicing": {
            "post": {
                "summary": "Fatoora platform answer (accepted or rejected)",
                "parameters": [
                    {
                        "name": "X-Qayd-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "t=<unix time>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>"
                    },
                    {
                        "name": "X-Qayd-Event",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Qayd-Delivery",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Received"
                    }
                }
            }
        },
        "invoice.paid": {
            "post": {
                "summary": "Invoice fully paid",
                "parameters": [
                    {
                        "name": "X-Qayd-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "t=<unix time>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>"
                    },
                    {
                        "name": "X-Qayd-Event",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Qayd-Delivery",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Received"
                    }
                }
            }
        },
        "invoice.voided": {
            "post": {
                "summary": "Invoice voided",
                "parameters": [
                    {
                        "name": "X-Qayd-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "t=<unix time>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>"
                    },
                    {
                        "name": "X-Qayd-Event",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Qayd-Delivery",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Received"
                    }
                }
            }
        },
        "payment.received": {
            "post": {
                "summary": "Payment received from a customer",
                "parameters": [
                    {
                        "name": "X-Qayd-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "t=<unix time>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>"
                    },
                    {
                        "name": "X-Qayd-Event",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Qayd-Delivery",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Received"
                    }
                }
            }
        },
        "customer.created": {
            "post": {
                "summary": "Customer added",
                "parameters": [
                    {
                        "name": "X-Qayd-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "t=<unix time>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>"
                    },
                    {
                        "name": "X-Qayd-Event",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Qayd-Delivery",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Received"
                    }
                }
            }
        },
        "customer.updated": {
            "post": {
                "summary": "Customer changed",
                "parameters": [
                    {
                        "name": "X-Qayd-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "t=<unix time>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>"
                    },
                    {
                        "name": "X-Qayd-Event",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Qayd-Delivery",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Received"
                    }
                }
            }
        },
        "item.stock_low": {
            "post": {
                "summary": "Item stock reached its reorder level",
                "parameters": [
                    {
                        "name": "X-Qayd-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "t=<unix time>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>"
                    },
                    {
                        "name": "X-Qayd-Event",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Qayd-Delivery",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Received"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearer": {
                "type": "http",
                "scheme": "bearer",
                "description": "qayd_<prefix><secret>, or qayd_test_<prefix><secret> for a test key (reads and drafts only, never issues)"
            }
        },
        "parameters": {
            "Id": {
                "name": "id",
                "in": "path",
                "required": true,
                "schema": {
                    "type": "integer"
                }
            },
            "Page": {
                "name": "page",
                "in": "query",
                "schema": {
                    "type": "integer",
                    "minimum": 1
                }
            },
            "PerPage": {
                "name": "per_page",
                "in": "query",
                "schema": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "default": 25
                }
            },
            "IdempotencyKey": {
                "name": "Idempotency-Key",
                "in": "header",
                "schema": {
                    "type": "string",
                    "maxLength": 100
                }
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "properties": {
                    "error": {
                        "type": "object",
                        "required": [
                            "code",
                            "message"
                        ],
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            },
                            "fields": {
                                "type": "object",
                                "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "Meta": {
                "type": "object",
                "properties": {
                    "page": {
                        "type": "integer"
                    },
                    "per_page": {
                        "type": "integer"
                    },
                    "total": {
                        "type": "integer"
                    },
                    "last_page": {
                        "type": "integer"
                    }
                }
            },
            "Address": {
                "type": "object",
                "properties": {
                    "city_id": {
                        "type": "integer"
                    },
                    "district": {
                        "type": "string"
                    },
                    "street": {
                        "type": "string"
                    },
                    "building_number": {
                        "type": "string",
                        "pattern": "^\\d{4}$"
                    },
                    "postal_code": {
                        "type": "string",
                        "pattern": "^\\d{5}$"
                    },
                    "additional_number": {
                        "type": "string",
                        "pattern": "^\\d{4}$"
                    },
                    "short_address": {
                        "type": "string",
                        "pattern": "^[A-Z]{4}\\d{4}$"
                    }
                }
            },
            "CustomerInput": {
                "type": "object",
                "required": [
                    "type",
                    "name"
                ],
                "properties": {
                    "type": {
                        "type": "string",
                        "enum": [
                            "individual",
                            "business"
                        ]
                    },
                    "name": {
                        "type": "string"
                    },
                    "name_en": {
                        "type": "string"
                    },
                    "vat_number": {
                        "type": "string",
                        "pattern": "^3\\d{13}3$"
                    },
                    "commercial_registration": {
                        "type": "string",
                        "pattern": "^\\d{10}$"
                    },
                    "contact_name": {
                        "type": "string"
                    },
                    "phone": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string",
                        "format": "email"
                    },
                    "address": {
                        "$ref": "#/components/schemas/Address"
                    },
                    "payment_term_days": {
                        "type": "integer"
                    },
                    "credit_limit": {
                        "oneOf": [
                            {
                                "type": "number"
                            },
                            {
                                "type": "string"
                            }
                        ]
                    },
                    "messages_opt_out": {
                        "type": "boolean"
                    },
                    "is_active": {
                        "type": "boolean"
                    },
                    "notes": {
                        "type": "string"
                    }
                }
            },
            "Customer": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "code": {
                        "type": "string"
                    },
                    "type": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "vat_number": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "phone": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "email": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "address": {
                        "$ref": "#/components/schemas/Address"
                    },
                    "missing_tax_details": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "is_active": {
                        "type": "boolean"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            },
            "InvoiceInput": {
                "type": "object",
                "required": [
                    "customer_id",
                    "lines"
                ],
                "properties": {
                    "customer_id": {
                        "type": "integer"
                    },
                    "issue_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "due_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "supply_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "reference": {
                        "type": "string"
                    },
                    "notes": {
                        "type": "string"
                    },
                    "prices_include_vat": {
                        "type": "boolean"
                    },
                    "branch_id": {
                        "type": "integer"
                    },
                    "warehouse_id": {
                        "type": "integer"
                    },
                    "discount": {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": [
                                    "percent",
                                    "amount"
                                ]
                            },
                            "value": {
                                "oneOf": [
                                    {
                                        "type": "number"
                                    },
                                    {
                                        "type": "string"
                                    }
                                ]
                            }
                        }
                    },
                    "issue": {
                        "type": "boolean",
                        "default": false
                    },
                    "payment": {
                        "$ref": "#/components/schemas/PaymentInput"
                    },
                    "lines": {
                        "type": "array",
                        "minItems": 1,
                        "items": {
                            "type": "object",
                            "required": [
                                "quantity"
                            ],
                            "properties": {
                                "item_id": {
                                    "type": [
                                        "integer",
                                        "null"
                                    ]
                                },
                                "unit_id": {
                                    "type": [
                                        "integer",
                                        "null"
                                    ]
                                },
                                "description": {
                                    "type": "string",
                                    "maxLength": 500
                                },
                                "quantity": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "unit_price": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "discount_percent": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "discount_amount": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "tax": {
                                    "type": "string",
                                    "examples": [
                                        "standard",
                                        "zero",
                                        "exempt"
                                    ]
                                },
                                "account_id": {
                                    "type": [
                                        "integer",
                                        "null"
                                    ]
                                }
                            }
                        }
                    }
                }
            },
            "CreditNoteInput": {
                "type": "object",
                "required": [
                    "reason",
                    "lines"
                ],
                "properties": {
                    "reason": {
                        "type": "string"
                    },
                    "issue_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "reference": {
                        "type": "string"
                    },
                    "notes": {
                        "type": "string"
                    },
                    "returns_stock": {
                        "type": "boolean",
                        "default": true
                    },
                    "issue": {
                        "type": "boolean",
                        "default": false
                    },
                    "lines": {
                        "type": "array",
                        "minItems": 1,
                        "items": {
                            "type": "object",
                            "required": [
                                "quantity"
                            ],
                            "properties": {
                                "item_id": {
                                    "type": [
                                        "integer",
                                        "null"
                                    ]
                                },
                                "unit_id": {
                                    "type": [
                                        "integer",
                                        "null"
                                    ]
                                },
                                "description": {
                                    "type": "string",
                                    "maxLength": 500
                                },
                                "quantity": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "unit_price": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "discount_percent": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "discount_amount": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "tax": {
                                    "type": "string",
                                    "examples": [
                                        "standard",
                                        "zero",
                                        "exempt"
                                    ]
                                },
                                "account_id": {
                                    "type": [
                                        "integer",
                                        "null"
                                    ]
                                }
                            }
                        }
                    }
                }
            },
            "Invoice": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "number": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "document": {
                        "type": "string",
                        "enum": [
                            "invoice",
                            "credit_note",
                            "debit_note"
                        ]
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "standard",
                            "simplified"
                        ]
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "draft",
                            "issued",
                            "void"
                        ]
                    },
                    "customer": {
                        "type": "object"
                    },
                    "issue_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "due_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "totals": {
                        "type": "object",
                        "properties": {
                            "subtotal": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            },
                            "discount": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            },
                            "tax": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            },
                            "total": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            },
                            "paid": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            },
                            "outstanding": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            }
                        }
                    },
                    "lines": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "einvoicing": {
                        "type": "object",
                        "properties": {
                            "status": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "enum": [
                                    "unsent",
                                    "pending",
                                    "reported",
                                    "cleared",
                                    "rejected",
                                    null
                                ]
                            },
                            "qr": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "messages": {
                                "type": "array",
                                "items": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "pdf_url": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uri"
                    }
                }
            },
            "Item": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "code": {
                        "type": "string"
                    },
                    "barcode": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "product",
                            "service"
                        ]
                    },
                    "name": {
                        "type": "string"
                    },
                    "unit": {
                        "type": [
                            "object",
                            "null"
                        ]
                    },
                    "units": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "sale_price": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "tax": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "tracks_stock": {
                        "type": "boolean"
                    },
                    "is_active": {
                        "type": "boolean"
                    }
                }
            },
            "PaymentInput": {
                "type": "object",
                "required": [
                    "method"
                ],
                "properties": {
                    "method": {
                        "type": "string",
                        "enum": [
                            "cash",
                            "bank_transfer",
                            "card",
                            "cheque"
                        ]
                    },
                    "account_id": {
                        "type": "integer"
                    },
                    "amount": {
                        "oneOf": [
                            {
                                "type": "number"
                            },
                            {
                                "type": "string"
                            }
                        ]
                    },
                    "date": {
                        "type": "string",
                        "format": "date"
                    },
                    "reference": {
                        "type": "string"
                    }
                }
            },
            "ReceiptInput": {
                "type": "object",
                "required": [
                    "customer_id",
                    "amount",
                    "method"
                ],
                "properties": {
                    "customer_id": {
                        "type": "integer"
                    },
                    "amount": {
                        "oneOf": [
                            {
                                "type": "number"
                            },
                            {
                                "type": "string"
                            }
                        ]
                    },
                    "method": {
                        "type": "string",
                        "enum": [
                            "cash",
                            "bank_transfer",
                            "card",
                            "cheque"
                        ]
                    },
                    "account_id": {
                        "type": "integer"
                    },
                    "date": {
                        "type": "string",
                        "format": "date"
                    },
                    "reference": {
                        "type": "string"
                    },
                    "notes": {
                        "type": "string"
                    },
                    "allocate": {
                        "type": "string",
                        "enum": [
                            "auto",
                            "none"
                        ]
                    },
                    "invoices": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "integer"
                                },
                                "amount": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            },
            "ItemInput": {
                "type": "object",
                "required": [
                    "type",
                    "name"
                ],
                "properties": {
                    "type": {
                        "type": "string",
                        "enum": [
                            "product",
                            "service"
                        ]
                    },
                    "code": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "name_en": {
                        "type": "string"
                    },
                    "description": {
                        "type": "string"
                    },
                    "unit_id": {
                        "type": "integer"
                    },
                    "category_id": {
                        "type": "integer"
                    },
                    "sale_price": {
                        "oneOf": [
                            {
                                "type": "number"
                            },
                            {
                                "type": "string"
                            }
                        ]
                    },
                    "purchase_price": {
                        "oneOf": [
                            {
                                "type": "number"
                            },
                            {
                                "type": "string"
                            }
                        ]
                    },
                    "tax": {
                        "type": "string"
                    },
                    "barcode": {
                        "type": "string"
                    },
                    "barcodes": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "units": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "unit_id": {
                                    "type": "integer"
                                },
                                "factor": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "sale_price": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "barcode": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "reorder_level": {
                        "oneOf": [
                            {
                                "type": "number"
                            },
                            {
                                "type": "string"
                            }
                        ]
                    },
                    "is_active": {
                        "type": "boolean"
                    }
                }
            },
            "StockDocumentInput": {
                "type": "object",
                "required": [
                    "kind",
                    "warehouse_id",
                    "lines"
                ],
                "properties": {
                    "kind": {
                        "type": "string",
                        "enum": [
                            "adjustment",
                            "transfer",
                            "receipt",
                            "issue"
                        ]
                    },
                    "warehouse_id": {
                        "type": "integer"
                    },
                    "to_warehouse_id": {
                        "type": "integer"
                    },
                    "date": {
                        "type": "string",
                        "format": "date"
                    },
                    "account_id": {
                        "type": "integer"
                    },
                    "reason": {
                        "type": "string"
                    },
                    "notes": {
                        "type": "string"
                    },
                    "post": {
                        "type": "boolean"
                    },
                    "lines": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "item_id": {
                                    "type": "integer"
                                },
                                "quantity": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "unit_cost": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            },
            "PurchaseInput": {
                "type": "object",
                "required": [
                    "supplier_id",
                    "lines"
                ],
                "properties": {
                    "supplier_id": {
                        "type": "integer"
                    },
                    "supplier_invoice_number": {
                        "type": "string"
                    },
                    "issue_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "due_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "notes": {
                        "type": "string"
                    },
                    "prices_include_vat": {
                        "type": "boolean"
                    },
                    "branch_id": {
                        "type": "integer"
                    },
                    "warehouse_id": {
                        "type": "integer"
                    },
                    "discount": {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": [
                                    "percent",
                                    "amount"
                                ]
                            },
                            "value": {
                                "oneOf": [
                                    {
                                        "type": "number"
                                    },
                                    {
                                        "type": "string"
                                    }
                                ]
                            }
                        }
                    },
                    "post": {
                        "type": "boolean",
                        "default": false
                    },
                    "payment": {
                        "$ref": "#/components/schemas/PaymentInput"
                    },
                    "lines": {
                        "type": "array",
                        "minItems": 1,
                        "items": {
                            "type": "object",
                            "required": [
                                "quantity"
                            ],
                            "properties": {
                                "item_id": {
                                    "type": [
                                        "integer",
                                        "null"
                                    ]
                                },
                                "unit_id": {
                                    "type": [
                                        "integer",
                                        "null"
                                    ]
                                },
                                "description": {
                                    "type": "string",
                                    "maxLength": 500
                                },
                                "quantity": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "unit_price": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "discount_percent": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "discount_amount": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "tax": {
                                    "type": "string",
                                    "examples": [
                                        "standard",
                                        "zero",
                                        "exempt"
                                    ]
                                },
                                "account_id": {
                                    "type": [
                                        "integer",
                                        "null"
                                    ]
                                }
                            }
                        }
                    }
                }
            },
            "PurchaseInvoice": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "number": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "document": {
                        "type": "string",
                        "enum": [
                            "invoice",
                            "return"
                        ]
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "draft",
                            "posted",
                            "void"
                        ]
                    },
                    "supplier": {
                        "type": "object"
                    },
                    "supplier_invoice_number": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "issue_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "due_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "totals": {
                        "type": "object",
                        "properties": {
                            "subtotal": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            },
                            "discount": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            },
                            "tax": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            },
                            "total": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            },
                            "paid": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            },
                            "outstanding": {
                                "type": "string",
                                "pattern": "^-?\\d+\\.\\d{2}$",
                                "examples": [
                                    "1150.00"
                                ]
                            }
                        }
                    },
                    "lines": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    }
                }
            },
            "PaymentVoucherInput": {
                "type": "object",
                "required": [
                    "supplier_id",
                    "amount",
                    "method"
                ],
                "properties": {
                    "supplier_id": {
                        "type": "integer"
                    },
                    "amount": {
                        "oneOf": [
                            {
                                "type": "number"
                            },
                            {
                                "type": "string"
                            }
                        ]
                    },
                    "method": {
                        "type": "string",
                        "enum": [
                            "cash",
                            "bank_transfer",
                            "card",
                            "cheque"
                        ]
                    },
                    "account_id": {
                        "type": "integer"
                    },
                    "date": {
                        "type": "string",
                        "format": "date"
                    },
                    "reference": {
                        "type": "string"
                    },
                    "notes": {
                        "type": "string"
                    },
                    "allocate": {
                        "type": "string",
                        "enum": [
                            "auto",
                            "none"
                        ]
                    },
                    "invoices": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "integer"
                                },
                                "amount": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            },
            "Payment": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "number": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "posted",
                            "cancelled"
                        ]
                    },
                    "supplier": {
                        "type": "object"
                    },
                    "date": {
                        "type": "string",
                        "format": "date"
                    },
                    "amount": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "examples": [
                            "1150.00"
                        ]
                    },
                    "method": {
                        "type": "string"
                    },
                    "account": {
                        "type": "object"
                    },
                    "invoices": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "unallocated": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "examples": [
                            "1150.00"
                        ]
                    }
                }
            },
            "Receipt": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "number": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "posted",
                            "cancelled"
                        ]
                    },
                    "customer": {
                        "type": "object"
                    },
                    "date": {
                        "type": "string",
                        "format": "date"
                    },
                    "amount": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "examples": [
                            "1150.00"
                        ]
                    },
                    "method": {
                        "type": "string"
                    },
                    "account": {
                        "type": "object"
                    },
                    "invoices": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "unallocated": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "examples": [
                            "1150.00"
                        ]
                    }
                }
            },
            "JournalEntryInput": {
                "type": "object",
                "required": [
                    "description",
                    "lines"
                ],
                "properties": {
                    "date": {
                        "type": "string",
                        "format": "date"
                    },
                    "description": {
                        "type": "string",
                        "maxLength": 255
                    },
                    "reference": {
                        "type": "string",
                        "maxLength": 60
                    },
                    "post": {
                        "type": "boolean",
                        "default": false
                    },
                    "lines": {
                        "type": "array",
                        "minItems": 2,
                        "items": {
                            "type": "object",
                            "required": [
                                "account_id"
                            ],
                            "properties": {
                                "account_id": {
                                    "type": "integer"
                                },
                                "debit": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "credit": {
                                    "oneOf": [
                                        {
                                            "type": "number"
                                        },
                                        {
                                            "type": "string"
                                        }
                                    ]
                                },
                                "contact_id": {
                                    "type": "integer"
                                },
                                "cost_center_id": {
                                    "type": "integer"
                                },
                                "description": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            },
            "JournalEntry": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "number": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "draft",
                            "posted"
                        ]
                    },
                    "source": {
                        "type": "string"
                    },
                    "date": {
                        "type": "string",
                        "format": "date"
                    },
                    "description": {
                        "type": "string"
                    },
                    "reference": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "total": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "examples": [
                            "1150.00"
                        ]
                    },
                    "is_balanced": {
                        "type": "boolean"
                    },
                    "reversal_of_id": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "lines": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    }
                }
            },
            "WebhookInput": {
                "type": "object",
                "properties": {
                    "url": {
                        "type": "string",
                        "format": "uri",
                        "maxLength": 500
                    },
                    "description": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "maxLength": 120
                    },
                    "events": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "enum": [
                                "invoice.issued",
                                "credit_note.issued",
                                "debit_note.issued",
                                "invoice.einvoicing",
                                "invoice.paid",
                                "invoice.voided",
                                "payment.received",
                                "customer.created",
                                "customer.updated",
                                "item.stock_low"
                            ]
                        }
                    },
                    "is_active": {
                        "type": "boolean"
                    }
                }
            },
            "WebhookEndpoint": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "url": {
                        "type": "string"
                    },
                    "description": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "events": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "is_active": {
                        "type": "boolean"
                    },
                    "failures": {
                        "type": "integer"
                    },
                    "disabled_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "secret": {
                        "type": "string",
                        "description": "Only when the address is added or its secret changed."
                    }
                }
            },
            "WebhookDelivery": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "event": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "delivered",
                            "failed"
                        ]
                    },
                    "attempts": {
                        "type": "integer"
                    },
                    "response_status": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "payload": {
                        "type": [
                            "object",
                            "null"
                        ]
                    }
                }
            },
            "WebhookEvent": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "event": {
                        "type": "string"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "data": {
                        "type": "object"
                    }
                }
            }
        }
    }
}