{
  "openapi": "3.1.0",
  "info": {
    "title": "Somdul Accounting API",
    "version": "2026-11-01",
    "description": "Connect your own systems (POS, online shop, Zapier / Make / n8n) to a company in Somdul Accounting. Make a key in Settings → API (company admins, Business plan and above). Send it as \"Authorization: Bearer sk_live_…\" from your server only. Writes go through the same rules as the app (permissions, closed periods, numbering, the audit trail, which names the key). Money is a string with 2 decimals; dates are YYYY-MM-DD; times are UTC ISO 8601. Lists are newest first, a page at a time (cursor). Limits: 1,200 requests an hour and 20,000 a day per key. Guide: https://help.somdul.app/settings/api-and-webhooks",
    "contact": {
      "name": "Somdul",
      "email": "hello@somdul.app",
      "url": "https://help.somdul.app/settings/api-and-webhooks"
    }
  },
  "servers": [
    {
      "url": "https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "account"
    },
    {
      "name": "contacts"
    },
    {
      "name": "products"
    },
    {
      "name": "invoices"
    },
    {
      "name": "quotes"
    },
    {
      "name": "receipts"
    },
    {
      "name": "bills"
    },
    {
      "name": "stock"
    },
    {
      "name": "accounts"
    }
  ],
  "paths": {
    "/v1/me": {
      "get": {
        "operationId": "me",
        "summary": "The company and key this request is for",
        "tags": [
          "account"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": null,
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Me"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/me\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/contacts": {
      "get": {
        "operationId": "listContacts",
        "summary": "List customers and suppliers",
        "tags": [
          "contacts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "contacts:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/contacts?limit=50\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      },
      "post": {
        "operationId": "createContacts",
        "summary": "Create a customer or supplier",
        "tags": [
          "contacts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "contacts:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_:.-]{1,100}$"
            },
            "description": "Retrying with the same key and body returns the first answer (Idempotent-Replayed: true) for 48 hours."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactInput"
              },
              "example": {
                "type": "customer",
                "name_th": "บริษัท ตัวอย่างลูกค้า จำกัด",
                "name_en": "Sample Customer Co., Ltd.",
                "tax_id": "0105500000001",
                "email": "accounts@customer.example",
                "credit_days": 30
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replayed (same Idempotency-Key)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl -X POST \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/contacts\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: contacts-0001\" \\\n  -d '{\"type\":\"customer\",\"name_th\":\"บริษัท ตัวอย่างลูกค้า จำกัด\",\"name_en\":\"Sample Customer Co., Ltd.\",\"tax_id\":\"0105500000001\",\"email\":\"accounts@customer.example\",\"credit_days\":30}'"
          }
        ]
      }
    },
    "/v1/contacts/{id}": {
      "get": {
        "operationId": "getContacts",
        "summary": "Get a customer or supplier",
        "tags": [
          "contacts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "contacts:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/contacts/00000000-0000-4000-8000-000000000003\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/products": {
      "get": {
        "operationId": "listProducts",
        "summary": "List products and services",
        "tags": [
          "products"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "products:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Product"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/products?limit=50\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      },
      "post": {
        "operationId": "createProducts",
        "summary": "Create a product or service",
        "tags": [
          "products"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "products:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_:.-]{1,100}$"
            },
            "description": "Retrying with the same key and body returns the first answer (Idempotent-Replayed: true) for 48 hours."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProductInput"
              },
              "example": {
                "code": "MUG-01",
                "name_en": "Coffee mug",
                "kind": "stock",
                "unit": "PCS",
                "sale_price": "250.00"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replayed (same Idempotency-Key)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Product"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Product"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl -X POST \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/products\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: products-0001\" \\\n  -d '{\"code\":\"MUG-01\",\"name_en\":\"Coffee mug\",\"kind\":\"stock\",\"unit\":\"PCS\",\"sale_price\":\"250.00\"}'"
          }
        ]
      }
    },
    "/v1/products/{id}": {
      "get": {
        "operationId": "getProducts",
        "summary": "Get a product",
        "tags": [
          "products"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "products:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Product"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/products/00000000-0000-4000-8000-000000000003\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/invoices": {
      "get": {
        "operationId": "listInvoices",
        "summary": "List tax invoices",
        "tags": [
          "invoices"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contact_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "payment_status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Invoice"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/invoices?limit=50\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      },
      "post": {
        "operationId": "createInvoices",
        "summary": "Create a tax invoice (draft, or posted)",
        "tags": [
          "invoices"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:write",
        "description": "Saved as a draft. With \"post\": true (needs sales:post as well) it is posted at once; if that is refused (a closed period, …) nothing is made.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_:.-]{1,100}$"
            },
            "description": "Retrying with the same key and body returns the first answer (Idempotent-Replayed: true) for 48 hours."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceInput"
              },
              "example": {
                "contact_id": "00000000-0000-4000-8000-000000000001",
                "date": "2026-11-01",
                "reference": "ORDER-1001",
                "post": true,
                "lines": [
                  {
                    "product_id": "00000000-0000-4000-8000-000000000002",
                    "qty": "2",
                    "unit_price": "250.00"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replayed (same Idempotency-Key)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Invoice"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Invoice"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl -X POST \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/invoices\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: invoices-0001\" \\\n  -d '{\"contact_id\":\"00000000-0000-4000-8000-000000000001\",\"date\":\"2026-11-01\",\"reference\":\"ORDER-1001\",\"post\":true,\"lines\":[{\"product_id\":\"00000000-0000-4000-8000-000000000002\",\"qty\":\"2\",\"unit_price\":\"250.00\"}]}'"
          }
        ]
      }
    },
    "/v1/invoices/{id}": {
      "get": {
        "operationId": "getInvoices",
        "summary": "Get a tax invoice with its lines and payment status",
        "tags": [
          "invoices"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Invoice"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/invoices/00000000-0000-4000-8000-000000000003\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/invoices/{id}/post": {
      "post": {
        "operationId": "actionInvoicesPost",
        "summary": "Post a draft tax invoice",
        "tags": [
          "invoices"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:post",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_:.-]{1,100}$"
            },
            "description": "Retrying with the same key and body returns the first answer (Idempotent-Replayed: true) for 48 hours."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Invoice"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl -X POST \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/invoices/00000000-0000-4000-8000-000000000003/post\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/invoices/{id}/payments": {
      "get": {
        "operationId": "paymentsInvoices",
        "summary": "Receipts that paid a tax invoice",
        "tags": [
          "invoices"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Payment"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/invoices/00000000-0000-4000-8000-000000000003/payments\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/quotes": {
      "get": {
        "operationId": "listQuotes",
        "summary": "List quotations",
        "tags": [
          "quotes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contact_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Quote"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/quotes?limit=50\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      },
      "post": {
        "operationId": "createQuotes",
        "summary": "Create a quotation (draft, or issued)",
        "tags": [
          "quotes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:write",
        "description": "Saved as a draft. With \"issue\": true (needs sales:post as well) it is issued at once; if that is refused (a closed period, …) nothing is made.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_:.-]{1,100}$"
            },
            "description": "Retrying with the same key and body returns the first answer (Idempotent-Replayed: true) for 48 hours."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteInput"
              },
              "example": {
                "contact_id": "00000000-0000-4000-8000-000000000001",
                "date": "2026-11-01",
                "valid_until": "2026-11-30",
                "lines": [
                  {
                    "product_id": "00000000-0000-4000-8000-000000000002",
                    "qty": "10",
                    "unit_price": "240.00"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replayed (same Idempotency-Key)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl -X POST \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/quotes\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: quotes-0001\" \\\n  -d '{\"contact_id\":\"00000000-0000-4000-8000-000000000001\",\"date\":\"2026-11-01\",\"valid_until\":\"2026-11-30\",\"lines\":[{\"product_id\":\"00000000-0000-4000-8000-000000000002\",\"qty\":\"10\",\"unit_price\":\"240.00\"}]}'"
          }
        ]
      }
    },
    "/v1/quotes/{id}": {
      "get": {
        "operationId": "getQuotes",
        "summary": "Get a quotation with its lines",
        "tags": [
          "quotes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/quotes/00000000-0000-4000-8000-000000000003\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/quotes/{id}/issue": {
      "post": {
        "operationId": "actionQuotesIssue",
        "summary": "Issue a draft quotation",
        "tags": [
          "quotes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:post",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_:.-]{1,100}$"
            },
            "description": "Retrying with the same key and body returns the first answer (Idempotent-Replayed: true) for 48 hours."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl -X POST \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/quotes/00000000-0000-4000-8000-000000000003/issue\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/receipts": {
      "get": {
        "operationId": "listReceipts",
        "summary": "List receipts",
        "tags": [
          "receipts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contact_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Receipt"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/receipts?limit=50\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      },
      "post": {
        "operationId": "createReceipts",
        "summary": "Record a payment received (draft, or posted)",
        "tags": [
          "receipts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:write",
        "description": "Saved as a draft. With \"post\": true (needs sales:post as well) it is posted at once; if that is refused (a closed period, …) nothing is made.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_:.-]{1,100}$"
            },
            "description": "Retrying with the same key and body returns the first answer (Idempotent-Replayed: true) for 48 hours."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReceiptInput"
              },
              "example": {
                "contact_id": "00000000-0000-4000-8000-000000000001",
                "date": "2026-11-03",
                "deposit_account_code": "1121",
                "reference": "PSP-889",
                "post": true,
                "allocations": [
                  {
                    "invoice_id": "00000000-0000-4000-8000-000000000003",
                    "amount": "535.00"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replayed (same Idempotency-Key)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Receipt"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Receipt"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl -X POST \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/receipts\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: receipts-0001\" \\\n  -d '{\"contact_id\":\"00000000-0000-4000-8000-000000000001\",\"date\":\"2026-11-03\",\"deposit_account_code\":\"1121\",\"reference\":\"PSP-889\",\"post\":true,\"allocations\":[{\"invoice_id\":\"00000000-0000-4000-8000-000000000003\",\"amount\":\"535.00\"}]}'"
          }
        ]
      }
    },
    "/v1/receipts/{id}": {
      "get": {
        "operationId": "getReceipts",
        "summary": "Get a receipt with the invoices it paid",
        "tags": [
          "receipts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Receipt"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/receipts/00000000-0000-4000-8000-000000000003\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/receipts/{id}/post": {
      "post": {
        "operationId": "actionReceiptsPost",
        "summary": "Post a draft receipt",
        "tags": [
          "receipts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "sales:post",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_:.-]{1,100}$"
            },
            "description": "Retrying with the same key and body returns the first answer (Idempotent-Replayed: true) for 48 hours."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Receipt"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl -X POST \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/receipts/00000000-0000-4000-8000-000000000003/post\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/bills": {
      "get": {
        "operationId": "listBills",
        "summary": "List supplier bills",
        "tags": [
          "bills"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "purchases:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          },
          {
            "name": "updated_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contact_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Bill"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/bills?limit=50\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      },
      "post": {
        "operationId": "createBills",
        "summary": "Create a supplier bill (always a draft)",
        "tags": [
          "bills"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "purchases:write",
        "description": "Always a draft: a person checks the supplier's bill and posts it in Somdul.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_:.-]{1,100}$"
            },
            "description": "Retrying with the same key and body returns the first answer (Idempotent-Replayed: true) for 48 hours."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillInput"
              },
              "example": {
                "contact_id": "00000000-0000-4000-8000-000000000004",
                "date": "2026-11-02",
                "supplier_invoice_no": "INV-77",
                "lines": [
                  {
                    "account_code": "5260",
                    "description": "Internet, November",
                    "unit_price": "590.00"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replayed (same Idempotency-Key)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Bill"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Bill"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl -X POST \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/bills\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: bills-0001\" \\\n  -d '{\"contact_id\":\"00000000-0000-4000-8000-000000000004\",\"date\":\"2026-11-02\",\"supplier_invoice_no\":\"INV-77\",\"lines\":[{\"account_code\":\"5260\",\"description\":\"Internet, November\",\"unit_price\":\"590.00\"}]}'"
          }
        ]
      }
    },
    "/v1/bills/{id}": {
      "get": {
        "operationId": "getBills",
        "summary": "Get a supplier bill with its lines",
        "tags": [
          "bills"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "purchases:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Bill"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/bills/00000000-0000-4000-8000-000000000003\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/stock": {
      "get": {
        "operationId": "listStock",
        "summary": "Stock on hand by product and warehouse",
        "tags": [
          "stock"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "stock:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          },
          {
            "name": "product_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "warehouse_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "as_at",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Stock"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/stock?limit=50\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    },
    "/v1/accounts": {
      "get": {
        "operationId": "listAccounts",
        "summary": "The chart of accounts",
        "tags": [
          "accounts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-scope": "accounts:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Account"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "curl",
            "source": "curl \"https://avfzzptywwpwgcugvqyu.supabase.co/functions/v1/api/v1/accounts?limit=50\" \\\n  -H \"Authorization: Bearer $SOMDUL_API_KEY\""
          }
        ]
      }
    }
  },
  "webhooks": {
    "invoice.posted": {
      "post": {
        "summary": "invoice.posted (sent to your endpoint)",
        "parameters": [
          {
            "name": "Somdul-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint's secret>. Reject it if t is more than 5 minutes from now."
          },
          {
            "name": "Somdul-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "invoice.posted"
            }
          },
          {
            "name": "Somdul-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The same on retries: use it to ignore repeats."
          },
          {
            "name": "Somdul-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx within 10 seconds counts as delivered; anything else is retried (1 min, 5 min, 30 min, 2 h, 6 h, 12 h, 24 h)."
          }
        }
      }
    },
    "invoice.paid": {
      "post": {
        "summary": "invoice.paid (sent to your endpoint)",
        "parameters": [
          {
            "name": "Somdul-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint's secret>. Reject it if t is more than 5 minutes from now."
          },
          {
            "name": "Somdul-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "invoice.paid"
            }
          },
          {
            "name": "Somdul-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The same on retries: use it to ignore repeats."
          },
          {
            "name": "Somdul-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx within 10 seconds counts as delivered; anything else is retried (1 min, 5 min, 30 min, 2 h, 6 h, 12 h, 24 h)."
          }
        }
      }
    },
    "invoice.cancelled": {
      "post": {
        "summary": "invoice.cancelled (sent to your endpoint)",
        "parameters": [
          {
            "name": "Somdul-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint's secret>. Reject it if t is more than 5 minutes from now."
          },
          {
            "name": "Somdul-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "invoice.cancelled"
            }
          },
          {
            "name": "Somdul-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The same on retries: use it to ignore repeats."
          },
          {
            "name": "Somdul-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx within 10 seconds counts as delivered; anything else is retried (1 min, 5 min, 30 min, 2 h, 6 h, 12 h, 24 h)."
          }
        }
      }
    },
    "receipt.posted": {
      "post": {
        "summary": "receipt.posted (sent to your endpoint)",
        "parameters": [
          {
            "name": "Somdul-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint's secret>. Reject it if t is more than 5 minutes from now."
          },
          {
            "name": "Somdul-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "receipt.posted"
            }
          },
          {
            "name": "Somdul-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The same on retries: use it to ignore repeats."
          },
          {
            "name": "Somdul-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx within 10 seconds counts as delivered; anything else is retried (1 min, 5 min, 30 min, 2 h, 6 h, 12 h, 24 h)."
          }
        }
      }
    },
    "bill.posted": {
      "post": {
        "summary": "bill.posted (sent to your endpoint)",
        "parameters": [
          {
            "name": "Somdul-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint's secret>. Reject it if t is more than 5 minutes from now."
          },
          {
            "name": "Somdul-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "bill.posted"
            }
          },
          {
            "name": "Somdul-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The same on retries: use it to ignore repeats."
          },
          {
            "name": "Somdul-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx within 10 seconds counts as delivered; anything else is retried (1 min, 5 min, 30 min, 2 h, 6 h, 12 h, 24 h)."
          }
        }
      }
    },
    "contact.created": {
      "post": {
        "summary": "contact.created (sent to your endpoint)",
        "parameters": [
          {
            "name": "Somdul-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint's secret>. Reject it if t is more than 5 minutes from now."
          },
          {
            "name": "Somdul-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "contact.created"
            }
          },
          {
            "name": "Somdul-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The same on retries: use it to ignore repeats."
          },
          {
            "name": "Somdul-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx within 10 seconds counts as delivered; anything else is retried (1 min, 5 min, 30 min, 2 h, 6 h, 12 h, 24 h)."
          }
        }
      }
    },
    "stock.low": {
      "post": {
        "summary": "stock.low (sent to your endpoint)",
        "parameters": [
          {
            "name": "Somdul-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint's secret>. Reject it if t is more than 5 minutes from now."
          },
          {
            "name": "Somdul-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "stock.low"
            }
          },
          {
            "name": "Somdul-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The same on retries: use it to ignore repeats."
          },
          {
            "name": "Somdul-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx within 10 seconds counts as delivered; anything else is retried (1 min, 5 min, 30 min, 2 h, 6 h, 12 h, 24 h)."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "A company API key, sk_live_… Scopes: contacts:read, contacts:write, products:read, products:write, sales:read, sales:write, sales:post, purchases:read, purchases:write, stock:read, accounts:read."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "examples": [
                  "ERR_API_INVALID"
                ],
                "description": "The app's error code."
              },
              "status": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              },
              "request_id": {
                "type": "string",
                "format": "uuid"
              },
              "details": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "field": {
                          "type": "string"
                        },
                        "problem": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "field",
                        "problem"
                      ],
                      "additionalProperties": false
                    }
                  }
                ]
              }
            },
            "required": [
              "code",
              "status",
              "message",
              "request_id"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "Contact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "const": "contact"
          },
          "type": {
            "type": "string",
            "enum": [
              "customer",
              "supplier"
            ]
          },
          "code": {
            "type": "string"
          },
          "name_th": {
            "type": "string"
          },
          "name_en": {
            "type": "string"
          },
          "entity_type": {
            "type": "string",
            "enum": [
              "juristic",
              "individual"
            ]
          },
          "tax_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "branch_code": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "address_en": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "contact_name": {
            "type": "string"
          },
          "credit_days": {
            "type": "integer"
          },
          "vat_registered": {
            "type": "boolean"
          },
          "active": {
            "type": "boolean"
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "code",
          "name_th",
          "name_en",
          "entity_type",
          "tax_id",
          "branch_code",
          "address",
          "address_en",
          "phone",
          "email",
          "contact_name",
          "credit_days",
          "vat_registered",
          "active",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false
      },
      "Product": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "const": "product"
          },
          "code": {
            "type": "string"
          },
          "name_th": {
            "type": "string"
          },
          "name_en": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "stock",
              "service",
              "set"
            ]
          },
          "unit": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "code": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "code"
            ],
            "additionalProperties": false
          },
          "sale_price": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "vat_applies": {
            "type": "boolean"
          },
          "vat_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "exempt",
              "zero",
              null
            ]
          },
          "barcode": {
            "type": [
              "string",
              "null"
            ]
          },
          "reorder_level": {
            "type": "string",
            "examples": [
              "2"
            ],
            "description": "A quantity as a string (up to 4 decimals)."
          },
          "active": {
            "type": "boolean"
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          }
        },
        "required": [
          "id",
          "object",
          "code",
          "name_th",
          "name_en",
          "kind",
          "unit",
          "sale_price",
          "vat_applies",
          "vat_type",
          "barcode",
          "reorder_level",
          "active",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false
      },
      "Line": {
        "type": "object",
        "properties": {
          "line_no": {
            "type": "integer"
          },
          "line_type": {
            "type": "string",
            "enum": [
              "stock",
              "expense",
              "receipt"
            ],
            "description": "Supplier bills only."
          },
          "product_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "account_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "description": {
            "type": "string"
          },
          "qty": {
            "type": "string",
            "examples": [
              "2"
            ],
            "description": "A quantity as a string (up to 4 decimals)."
          },
          "unit_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "unit_price": {
            "type": "string"
          },
          "discount": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "vat_applies": {
            "type": "boolean"
          },
          "vat_type": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "line_no",
          "description",
          "qty",
          "unit_price",
          "amount"
        ],
        "additionalProperties": false
      },
      "Invoice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "const": "invoice"
          },
          "doc_no": {
            "type": [
              "string",
              "null"
            ],
            "description": "Given when posted."
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "posted",
              "cancelled"
            ]
          },
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "reference": {
            "type": "string"
          },
          "note": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "fx_rate": {
            "type": "string"
          },
          "vat_mode": {
            "type": "string",
            "enum": [
              "exclusive",
              "inclusive",
              "none"
            ]
          },
          "vat_rate": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "subtotal": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "vat_amount": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "total": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "payment": {
            "type": "object",
            "properties": {
              "status": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "unpaid",
                  "partial",
                  "paid",
                  null
                ],
                "description": "Posted invoices only."
              },
              "paid": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "examples": [
                  "1500.00"
                ],
                "description": "Money as a string with 2 decimals."
              },
              "credited": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "examples": [
                  "1500.00"
                ],
                "description": "Money as a string with 2 decimals."
              },
              "debited": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "examples": [
                  "1500.00"
                ],
                "description": "Money as a string with 2 decimals."
              },
              "due": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "examples": [
                  "1500.00"
                ],
                "description": "Money as a string with 2 decimals."
              }
            },
            "required": [
              "status",
              "paid",
              "credited",
              "debited",
              "due"
            ],
            "additionalProperties": false
          },
          "posted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "cancelled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Line"
            },
            "description": "In single-invoice answers only."
          }
        },
        "required": [
          "id",
          "object",
          "doc_no",
          "status",
          "contact_id",
          "date",
          "total",
          "payment"
        ],
        "additionalProperties": false
      },
      "Quote": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "const": "quote"
          },
          "doc_no": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "issued",
              "accepted",
              "declined"
            ]
          },
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "valid_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "reference": {
            "type": "string"
          },
          "note": {
            "type": "string"
          },
          "vat_mode": {
            "type": "string"
          },
          "vat_rate": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "subtotal": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "vat_amount": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "total": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Line"
            }
          }
        },
        "required": [
          "id",
          "object",
          "status",
          "contact_id",
          "date",
          "total"
        ],
        "additionalProperties": false
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "const": "receipt"
          },
          "doc_no": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "posted",
              "cancelled"
            ]
          },
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "deposit_account_id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "type": "string"
          },
          "note": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "amount_total": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "wht_amount": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "net_received": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "posted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "cancelled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "allocations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "invoice_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "amount": {
                  "type": "string",
                  "pattern": "^\\d+\\.\\d{2}$",
                  "examples": [
                    "1500.00"
                  ],
                  "description": "Money as a string with 2 decimals."
                }
              },
              "required": [
                "invoice_id",
                "amount"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "id",
          "object",
          "status",
          "contact_id",
          "date",
          "amount_total"
        ],
        "additionalProperties": false
      },
      "Bill": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "const": "bill"
          },
          "doc_no": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "posted",
              "cancelled"
            ]
          },
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "supplier_invoice_no": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "note": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "vat_mode": {
            "type": "string"
          },
          "vat_rate": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "subtotal": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "vat_amount": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "total": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "payment": {
            "type": "object",
            "properties": {
              "paid": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "examples": [
                  "1500.00"
                ],
                "description": "Money as a string with 2 decimals."
              },
              "due": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "examples": [
                  "1500.00"
                ],
                "description": "Money as a string with 2 decimals."
              }
            },
            "required": [
              "paid",
              "due"
            ],
            "additionalProperties": false
          },
          "posted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Line"
            }
          }
        },
        "required": [
          "id",
          "object",
          "status",
          "contact_id",
          "date",
          "total"
        ],
        "additionalProperties": false
      },
      "Stock": {
        "type": "object",
        "properties": {
          "object": {
            "const": "stock"
          },
          "product_id": {
            "type": "string",
            "format": "uuid"
          },
          "product_code": {
            "type": "string"
          },
          "warehouse_id": {
            "type": "string",
            "format": "uuid"
          },
          "warehouse_code": {
            "type": "string"
          },
          "qty": {
            "type": "string",
            "examples": [
              "2"
            ],
            "description": "A quantity as a string (up to 4 decimals)."
          },
          "value": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "as_at": {
            "type": "string",
            "format": "date"
          }
        },
        "required": [
          "object",
          "product_id",
          "product_code",
          "warehouse_id",
          "warehouse_code",
          "qty",
          "value",
          "as_at"
        ],
        "additionalProperties": false
      },
      "Account": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "const": "account"
          },
          "code": {
            "type": "string"
          },
          "name_th": {
            "type": "string"
          },
          "name_en": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "asset",
              "liability",
              "equity",
              "revenue",
              "expense"
            ]
          },
          "parent_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "postable": {
            "type": "boolean"
          },
          "active": {
            "type": "boolean"
          },
          "currency": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "code",
          "name_th",
          "name_en",
          "type",
          "parent_id",
          "postable",
          "active",
          "currency"
        ],
        "additionalProperties": false
      },
      "Payment": {
        "type": "object",
        "properties": {
          "object": {
            "const": "payment"
          },
          "receipt_id": {
            "type": "string",
            "format": "uuid"
          },
          "receipt_no": {
            "type": [
              "string",
              "null"
            ]
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "examples": [
              "1500.00"
            ],
            "description": "Money as a string with 2 decimals."
          },
          "status": {
            "type": "string"
          }
        },
        "required": [
          "object",
          "receipt_id",
          "receipt_no",
          "date",
          "amount",
          "status"
        ],
        "additionalProperties": false
      },
      "Me": {
        "type": "object",
        "properties": {
          "company": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name_th": {
                "type": "string"
              },
              "name_en": {
                "type": "string"
              },
              "tax_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "vat_registered": {
                "type": "boolean"
              },
              "vat_rate": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "examples": [
                  "1500.00"
                ],
                "description": "Money as a string with 2 decimals."
              }
            },
            "required": [
              "id",
              "name_th",
              "name_en",
              "tax_id",
              "vat_registered",
              "vat_rate"
            ],
            "additionalProperties": false
          },
          "key": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "prefix": {
                "type": "string"
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "contacts:read",
                    "contacts:write",
                    "products:read",
                    "products:write",
                    "sales:read",
                    "sales:write",
                    "sales:post",
                    "purchases:read",
                    "purchases:write",
                    "stock:read",
                    "accounts:read"
                  ]
                }
              },
              "expires_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time",
                "description": "UTC, ISO 8601."
              }
            },
            "required": [
              "name",
              "prefix",
              "scopes",
              "expires_at"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "company",
          "key"
        ],
        "additionalProperties": false
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "enum": [
              "invoice.posted",
              "invoice.paid",
              "invoice.cancelled",
              "receipt.posted",
              "bill.posted",
              "contact.created",
              "stock.low",
              "ping"
            ]
          },
          "api_version": {
            "const": "2026-11-01"
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "UTC, ISO 8601."
          },
          "company_id": {
            "type": "string",
            "format": "uuid"
          },
          "data": {
            "type": "object",
            "description": "Ids, numbers, dates and amounts only (no names, addresses, tax ids or emails): read the rest with the API."
          }
        },
        "required": [
          "id",
          "type",
          "api_version",
          "created_at",
          "company_id",
          "data"
        ],
        "additionalProperties": false
      },
      "ContactInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "customer",
              "supplier"
            ]
          },
          "code": {
            "type": "string",
            "maxLength": 30,
            "pattern": "^[A-Za-z0-9._-]+$",
            "description": "letters, digits, . _ -"
          },
          "name_th": {
            "type": "string",
            "maxLength": 200
          },
          "name_en": {
            "type": "string",
            "maxLength": 200
          },
          "entity_type": {
            "type": "string",
            "enum": [
              "juristic",
              "individual"
            ]
          },
          "tax_id": {
            "type": "string",
            "maxLength": 13,
            "pattern": "^\\d{13}$",
            "description": "13 digits"
          },
          "branch_code": {
            "type": "string",
            "maxLength": 5,
            "pattern": "^\\d{5}$",
            "description": "5 digits (00000 = head office)"
          },
          "address": {
            "type": "string",
            "maxLength": 500
          },
          "address_en": {
            "type": "string",
            "maxLength": 500
          },
          "phone": {
            "type": "string",
            "maxLength": 50
          },
          "email": {
            "type": "string",
            "maxLength": 254,
            "pattern": "^[^@\\s<>\"]+@[^@\\s<>\"]+\\.[^@\\s<>\"]+$",
            "description": "an email address"
          },
          "contact_name": {
            "type": "string",
            "maxLength": 120
          },
          "credit_days": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365
          },
          "vat_registered": {
            "type": "boolean"
          }
        },
        "required": [
          "type"
        ]
      },
      "ProductInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "code": {
            "type": "string",
            "maxLength": 30,
            "pattern": "^[A-Za-z0-9._-]+$",
            "description": "letters, digits, . _ -"
          },
          "name_th": {
            "type": "string",
            "maxLength": 200
          },
          "name_en": {
            "type": "string",
            "maxLength": 200
          },
          "kind": {
            "type": "string",
            "enum": [
              "stock",
              "service"
            ]
          },
          "unit": {
            "type": "string",
            "maxLength": 20
          },
          "sale_price": {
            "type": "string",
            "pattern": "^\\d{1,12}(\\.\\d{1,2})?$",
            "description": "An amount, at most 2 decimals"
          },
          "vat_applies": {
            "type": "boolean"
          },
          "vat_type": {
            "type": "string",
            "enum": [
              "exempt",
              "zero"
            ]
          },
          "barcode": {
            "type": "string",
            "maxLength": 64,
            "pattern": "^\\S+$",
            "description": "no spaces"
          },
          "reorder_level": {
            "type": "string",
            "pattern": "^\\d{1,10}(\\.\\d{1,4})?$",
            "description": "A quantity, at most 4 decimals"
          },
          "expense_account_code": {
            "type": "string",
            "maxLength": 10,
            "pattern": "^\\d{4,10}$",
            "description": "an account code"
          }
        },
        "required": []
      },
      "InvoiceInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "due_date": {
            "type": "string",
            "format": "date"
          },
          "reference": {
            "type": "string",
            "maxLength": 100
          },
          "note": {
            "type": "string",
            "maxLength": 1000
          },
          "vat_mode": {
            "type": "string",
            "enum": [
              "exclusive",
              "inclusive",
              "none"
            ]
          },
          "currency": {
            "type": "string",
            "maxLength": 3,
            "pattern": "^[A-Z]{3}$",
            "description": "a currency code like THB"
          },
          "fx_rate": {
            "type": "string",
            "pattern": "^\\d{1,10}(\\.\\d{1,4})?$",
            "description": "A number, at most 4 decimals, more than 0"
          },
          "warehouse_id": {
            "type": "string",
            "format": "uuid"
          },
          "lines": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "product_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "description": {
                  "type": "string",
                  "maxLength": 500
                },
                "qty": {
                  "type": "string",
                  "pattern": "^\\d{1,10}(\\.\\d{1,4})?$",
                  "description": "A quantity, at most 4 decimals, more than 0"
                },
                "unit_price": {
                  "type": "string",
                  "pattern": "^\\d{1,10}(\\.\\d{1,4})?$",
                  "description": "A number, at most 4 decimals"
                },
                "discount": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(\\.\\d{1,2})?$",
                  "description": "An amount, at most 2 decimals"
                },
                "vat_applies": {
                  "type": "boolean"
                }
              },
              "required": [
                "product_id",
                "qty",
                "unit_price"
              ]
            }
          },
          "post": {
            "type": "boolean"
          }
        },
        "required": [
          "contact_id",
          "date",
          "lines"
        ]
      },
      "QuoteInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "valid_until": {
            "type": "string",
            "format": "date"
          },
          "reference": {
            "type": "string",
            "maxLength": 100
          },
          "note": {
            "type": "string",
            "maxLength": 1000
          },
          "vat_mode": {
            "type": "string",
            "enum": [
              "exclusive",
              "inclusive",
              "none"
            ]
          },
          "lines": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "product_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "description": {
                  "type": "string",
                  "maxLength": 500
                },
                "qty": {
                  "type": "string",
                  "pattern": "^\\d{1,10}(\\.\\d{1,4})?$",
                  "description": "A quantity, at most 4 decimals, more than 0"
                },
                "unit_price": {
                  "type": "string",
                  "pattern": "^\\d{1,10}(\\.\\d{1,4})?$",
                  "description": "A number, at most 4 decimals"
                },
                "discount": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(\\.\\d{1,2})?$",
                  "description": "An amount, at most 2 decimals"
                },
                "vat_applies": {
                  "type": "boolean"
                }
              },
              "required": [
                "product_id",
                "qty",
                "unit_price"
              ]
            }
          },
          "issue": {
            "type": "boolean"
          }
        },
        "required": [
          "contact_id",
          "date",
          "lines"
        ]
      },
      "ReceiptInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "deposit_account_id": {
            "type": "string",
            "format": "uuid"
          },
          "deposit_account_code": {
            "type": "string",
            "maxLength": 10,
            "pattern": "^\\d{4,10}$",
            "description": "an account code"
          },
          "reference": {
            "type": "string",
            "maxLength": 60
          },
          "note": {
            "type": "string",
            "maxLength": 1000
          },
          "wht_amount": {
            "type": "string",
            "pattern": "^\\d{1,12}(\\.\\d{1,2})?$",
            "description": "An amount, at most 2 decimals"
          },
          "allocations": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "invoice_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "amount": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(\\.\\d{1,2})?$",
                  "description": "An amount, at most 2 decimals, more than 0"
                }
              },
              "required": [
                "invoice_id",
                "amount"
              ]
            }
          },
          "post": {
            "type": "boolean"
          }
        },
        "required": [
          "contact_id",
          "date",
          "allocations"
        ]
      },
      "BillInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "due_date": {
            "type": "string",
            "format": "date"
          },
          "supplier_invoice_no": {
            "type": "string",
            "maxLength": 60
          },
          "vat_mode": {
            "type": "string",
            "enum": [
              "exclusive",
              "inclusive",
              "none"
            ]
          },
          "note": {
            "type": "string",
            "maxLength": 1000
          },
          "warehouse_id": {
            "type": "string",
            "format": "uuid"
          },
          "lines": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "product_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "account_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "account_code": {
                  "type": "string",
                  "maxLength": 10,
                  "pattern": "^\\d{4,10}$",
                  "description": "an account code"
                },
                "description": {
                  "type": "string",
                  "maxLength": 500
                },
                "qty": {
                  "type": "string",
                  "pattern": "^\\d{1,10}(\\.\\d{1,4})?$",
                  "description": "A quantity, at most 4 decimals, more than 0"
                },
                "unit_price": {
                  "type": "string",
                  "pattern": "^\\d{1,10}(\\.\\d{1,6})?$",
                  "description": "A number, at most 6 decimals"
                },
                "discount": {
                  "type": "string",
                  "pattern": "^\\d{1,12}(\\.\\d{1,2})?$",
                  "description": "An amount, at most 2 decimals"
                },
                "vat_applies": {
                  "type": "boolean"
                }
              },
              "required": [
                "unit_price"
              ]
            }
          }
        },
        "required": [
          "contact_id",
          "date",
          "lines"
        ]
      }
    },
    "responses": {
      "E401": {
        "description": "Missing, unknown, revoked or expired key",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E403": {
        "description": "The key lacks the scope, the address is not allowed, the plan has no API, or the public demo",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E404": {
        "description": "Not found (or another company's)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E409": {
        "description": "Conflict: Idempotency-Key reused, duplicate code, document no longer a draft",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E422": {
        "description": "Invalid fields (details lists each) or refused by a business rule (closed period, …)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E429": {
        "description": "Too many requests (Retry-After)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
