{
  "openapi": "3.1.0",
  "info": {
    "title": "counter.lt API",
    "version": "1.0.0",
    "description": "Public API of counter.lt accounting (D-185). Create a key in the app: Settings → API keys (owner or administrator). Send it as `Authorization: Bearer clt_…`. One call = one successful (2xx) request; batches of up to 100 items / contacts count as one call. Limits: 120 requests per minute per key, 600 per organisation. Guide (LT): https://counter.lt/integracijos-api",
    "contact": {
      "name": "counter.lt",
      "email": "pagalba@counter.lt",
      "url": "https://counter.lt/integracijos-api"
    }
  },
  "servers": [
    {
      "url": "https://counter.lt/api"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Reference"
    },
    {
      "name": "Items"
    },
    {
      "name": "Stock"
    },
    {
      "name": "Contacts"
    },
    {
      "name": "Invoices"
    },
    {
      "name": "Documents"
    },
    {
      "name": "Orders"
    }
  ],
  "paths": {
    "/v1/tax-rates": {
      "get": {
        "tags": [
          "Reference"
        ],
        "summary": "VAT codes valid on a date (any key)",
        "operationId": "listTaxRates",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Default — today"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TaxRate"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/warehouses": {
      "get": {
        "tags": [
          "Reference"
        ],
        "summary": "Warehouses (any key)",
        "operationId": "listWarehouses",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Warehouse"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/items": {
      "get": {
        "tags": [
          "Items"
        ],
        "summary": "List items (items.read)",
        "operationId": "listItems",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Search in name / code / barcode"
          },
          {
            "name": "code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact code"
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "service",
                "goods",
                "kit"
              ]
            },
            "description": "Type"
          },
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Item"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `cursor` to get the next page; null — last page."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "post": {
        "tags": [
          "Items"
        ],
        "summary": "Create or update up to 100 items by code — one call (items.write)",
        "operationId": "upsertItems",
        "description": "All or nothing: an error in any item saves nothing (errors as `items.N.field`).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ItemInput"
                    },
                    "minItems": 1,
                    "maxItems": 100
                  }
                },
                "required": [
                  "items"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/UpsertResult"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/stock": {
      "get": {
        "tags": [
          "Stock"
        ],
        "summary": "Stock balances — full list, not paged (stock.read)",
        "operationId": "stockBalances",
        "parameters": [
          {
            "name": "warehouse",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Warehouse code"
          },
          {
            "name": "item_code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Item code"
          },
          {
            "name": "as_of",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Default — now"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/StockBalance"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/stock-documents": {
      "get": {
        "tags": [
          "Stock"
        ],
        "summary": "List stock documents (stock.read)",
        "operationId": "listStockDocuments",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "receipt",
                "write_off",
                "transfer"
              ]
            },
            "description": "Type"
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "From"
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "To"
          },
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/StockDocument"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `cursor` to get the next page; null — last page."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "post": {
        "tags": [
          "Stock"
        ],
        "summary": "Receipt, write-off or transfer — saved and posted in one transaction (stock.write)",
        "operationId": "createStockDocument",
        "description": "Ledger entries as in the app: receipt D stock / K counter account; write-off FIFO D counter account / K stock; transfer — no entries. On error nothing is saved, so a retry with the same `external_id` runs again. Needs the key creator's plan to include accounting.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StockDocumentInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/StockDocument"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "200": {
            "description": "Already created earlier with the same `source` + `external_id` (body is not compared)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/StockDocument"
                    },
                    "duplicate": {
                      "const": true
                    }
                  },
                  "required": [
                    "data",
                    "duplicate"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/stock-documents/{stockDocument}": {
      "get": {
        "tags": [
          "Stock"
        ],
        "summary": "Stock document with lines (stock.read)",
        "operationId": "getStockDocument",
        "parameters": [
          {
            "name": "stockDocument",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/StockDocument"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/contacts": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "List customers and suppliers (contacts.read)",
        "operationId": "listContacts",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Search"
          },
          {
            "name": "code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Company code"
          },
          {
            "name": "vat_code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "VAT code"
          },
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `cursor` to get the next page; null — last page."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "post": {
        "tags": [
          "Contacts"
        ],
        "summary": "Create or update up to 100 contacts — one call (contacts.write)",
        "operationId": "upsertContacts",
        "description": "Matched by `source` + `external_id`, then by `code`, otherwise created. If they point to different contacts — 409, nothing saved.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "pattern": "^[a-z0-9_-]{1,24}$",
                    "default": "api",
                    "description": "Your system's name — together with `external_id` it makes the request idempotent."
                  },
                  "contacts": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ContactInput"
                    },
                    "minItems": 1,
                    "maxItems": 100
                  }
                },
                "required": [
                  "contacts"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/UpsertResult"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/invoices": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "summary": "List sales invoices with payment status (invoices.read)",
        "operationId": "listInvoices",
        "parameters": [
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Issue date from"
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Issue date to"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "issued"
              ]
            },
            "description": "Status"
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "invoice",
                "credit_note"
              ]
            },
            "description": "Type"
          },
          {
            "name": "contact_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Contact"
          },
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Invoice"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `cursor` to get the next page; null — last page."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "post": {
        "tags": [
          "Invoices"
        ],
        "summary": "Create a sales invoice and optionally issue it (invoices.write)",
        "operationId": "createInvoice",
        "description": "Contact, draft and issuing happen in one transaction: on error (missing buyer address, closed period) nothing is saved.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Invoice"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "200": {
            "description": "Already created earlier with the same `source` + `external_id` (body is not compared)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Invoice"
                    },
                    "duplicate": {
                      "const": true
                    }
                  },
                  "required": [
                    "data",
                    "duplicate"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/invoices/{invoice}": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "summary": "Invoice with lines (invoices.read)",
        "operationId": "getInvoice",
        "parameters": [
          {
            "name": "invoice",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Invoice"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/invoices/{invoice}/pdf": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "summary": "Invoice PDF (invoices.read, 30 per minute)",
        "operationId": "getInvoicePdf",
        "parameters": [
          {
            "name": "invoice",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/invoices/{invoice}/issue": {
      "post": {
        "tags": [
          "Invoices"
        ],
        "summary": "Issue a draft (invoices.write)",
        "operationId": "issueInvoice",
        "parameters": [
          {
            "name": "invoice",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Invoice"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/documents": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "Received documents with recognition result and linked purchase invoice (documents.read)",
        "operationId": "listDocuments",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "new",
                "processed",
                "rejected"
              ]
            },
            "description": "Status"
          },
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Document"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `cursor` to get the next page; null — last page."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Upload a received invoice for recognition (documents.write, 20 per minute, 200 files per day)",
        "operationId": "uploadDocument",
        "description": "AI recognition is charged like in the app (counter.lt credit or own key).",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "files[]": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    },
                    "minItems": 1,
                    "maxItems": 10,
                    "description": "PDF, images, XML, office files; up to 20 MB each"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "accounting_month": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}$"
                  },
                  "recognize": {
                    "type": "boolean",
                    "default": true
                  },
                  "source": {
                    "type": "string",
                    "pattern": "^[a-z0-9_-]{1,24}$",
                    "default": "api",
                    "description": "Your system's name — together with `external_id` it makes the request idempotent."
                  },
                  "external_id": {
                    "type": "string",
                    "maxLength": 64,
                    "description": "Optional; makes the upload idempotent"
                  }
                },
                "required": [
                  "files[]"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Document"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "200": {
            "description": "Already created earlier with the same `source` + `external_id` (body is not compared)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Document"
                    },
                    "duplicate": {
                      "const": true
                    }
                  },
                  "required": [
                    "data",
                    "duplicate"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/integrations/orders": {
      "post": {
        "tags": [
          "Orders"
        ],
        "summary": "Web shop / marketplace order → issued invoice (+ payment) (orders)",
        "operationId": "importOrder",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrderInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderResult"
                }
              }
            }
          },
          "200": {
            "description": "Duplicate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/integrations/refunds": {
      "post": {
        "tags": [
          "Orders"
        ],
        "summary": "Refund → credit note (+ money back) (orders)",
        "operationId": "importRefund",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefundInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderResult"
                }
              }
            }
          },
          "200": {
            "description": "Duplicate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "clt_…"
      }
    },
    "parameters": {
      "limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "default": 50
        }
      },
      "cursor": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string"
        },
        "description": "`next_cursor` of the previous page"
      },
      "updated_since": {
        "name": "updated_since",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "format": "date-time"
        },
        "description": "Inclusive (>=). Pages are ordered by (updated_at, id), so syncing never skips records with the same timestamp."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "invalid_key",
              "ability_missing",
              "key_owner_inactive",
              "plan_feature",
              "read_only",
              "subscription_inactive",
              "integration_plan_required",
              "integration_cap_reached",
              "rate_limited",
              "not_found",
              "validation_failed",
              "ledger_error",
              "conflict",
              "method_not_allowed",
              "payload_too_large",
              "http_error"
            ]
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "description": "Field errors (validation_failed, conflict)."
          }
        },
        "required": [
          "message"
        ]
      },
      "TaxRate": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "examples": [
              "PVM1"
            ]
          },
          "rate": {
            "type": [
              "string",
              "null"
            ],
            "description": "Decimal as string, e.g. \"12.34\"",
            "examples": [
              "12.34"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "reverse_charge": {
            "type": "boolean"
          }
        }
      },
      "Warehouse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "examples": [
              "PAGR"
            ]
          },
          "name": {
            "type": "string"
          },
          "is_active": {
            "type": "boolean"
          }
        }
      },
      "Item": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "code": {
            "type": "string",
            "description": "SKU, unique in the company"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "service",
              "goods",
              "kit"
            ]
          },
          "unit": {
            "type": [
              "string",
              "null"
            ]
          },
          "barcode": {
            "type": [
              "string",
              "null"
            ]
          },
          "sale_price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Decimal as string, e.g. \"12.34\"",
            "examples": [
              "12.34"
            ]
          },
          "purchase_price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Decimal as string, e.g. \"12.34\"",
            "examples": [
              "12.34"
            ]
          },
          "tax_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "group": {
            "type": [
              "string",
              "null"
            ],
            "description": "Item posting group code"
          },
          "is_active": {
            "type": "boolean"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ItemInput": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "maxLength": 64
          },
          "name": {
            "type": "string",
            "maxLength": 255
          },
          "type": {
            "type": "string",
            "enum": [
              "service",
              "goods"
            ],
            "description": "Required when creating; cannot be changed."
          },
          "unit": {
            "type": "string",
            "maxLength": 16,
            "default": "vnt."
          },
          "barcode": {
            "type": "string",
            "maxLength": 64
          },
          "sale_price": {
            "type": "number",
            "minimum": 0
          },
          "purchase_price": {
            "type": "number",
            "minimum": 0
          },
          "tax_code": {
            "type": "string",
            "description": "See GET /v1/tax-rates"
          },
          "group": {
            "type": "string",
            "description": "Item posting group code; goods default to the 2040 group"
          },
          "is_active": {
            "type": "boolean"
          }
        },
        "required": [
          "code",
          "name"
        ]
      },
      "UpsertResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "code": {
            "type": [
              "string",
              "null"
            ]
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "created",
              "updated",
              "unchanged"
            ]
          }
        }
      },
      "StockBalance": {
        "type": "object",
        "properties": {
          "item_code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "unit": {
            "type": [
              "string",
              "null"
            ]
          },
          "warehouse": {
            "type": [
              "string",
              "null"
            ]
          },
          "quantity": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "reserved": {
            "type": "string"
          },
          "available": {
            "type": "string"
          }
        }
      },
      "StockDocument": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "type": {
            "type": "string",
            "enum": [
              "receipt",
              "write_off",
              "transfer"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "posted",
              "reversed"
            ]
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "PAJ-2026-0001"
            ]
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "warehouse": {
            "type": "string"
          },
          "to_warehouse": {
            "type": [
              "string",
              "null"
            ]
          },
          "counter_account": {
            "type": [
              "string",
              "null"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "total": {
            "type": [
              "string",
              "null"
            ],
            "description": "Decimal as string, e.g. \"12.34\"",
            "examples": [
              "12.34"
            ]
          },
          "journal_entry_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "item_code": {
                  "type": "string"
                },
                "quantity": {
                  "type": "string"
                },
                "unit_cost": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "amount": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Decimal as string, e.g. \"12.34\"",
                  "examples": [
                    "12.34"
                  ]
                },
                "lot": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "expiry_date": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date"
                }
              }
            }
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "StockDocumentInput": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "pattern": "^[a-z0-9_-]{1,24}$",
            "default": "api",
            "description": "Your system's name — together with `external_id` it makes the request idempotent."
          },
          "external_id": {
            "type": "string",
            "maxLength": 64
          },
          "type": {
            "type": "string",
            "enum": [
              "receipt",
              "write_off",
              "transfer"
            ]
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "warehouse": {
            "type": "string",
            "description": "Warehouse code"
          },
          "to_warehouse": {
            "type": "string",
            "description": "Required for transfer"
          },
          "counter_account": {
            "type": "string",
            "description": "Ledger account; default — stock gain (receipt) / stock loss (write-off) account from settings"
          },
          "reason": {
            "type": "string",
            "maxLength": 255
          },
          "post": {
            "type": "boolean",
            "default": true,
            "description": "false — leave as a draft for review in the app"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "item_code": {
                  "type": "string"
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "unit_cost": {
                  "type": "number",
                  "minimum": 0,
                  "description": "Required for receipt"
                },
                "lot": {
                  "type": "string"
                },
                "expiry_date": {
                  "type": "string",
                  "format": "date"
                }
              },
              "required": [
                "item_code",
                "quantity"
              ]
            },
            "minItems": 1,
            "maxItems": 500
          }
        },
        "required": [
          "external_id",
          "type",
          "date",
          "warehouse",
          "lines"
        ]
      },
      "Contact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "type": {
            "type": "string",
            "enum": [
              "customer",
              "supplier",
              "both",
              "person"
            ]
          },
          "name": {
            "type": "string"
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company code"
          },
          "vat_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "address": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "iban": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ContactInput": {
        "type": "object",
        "properties": {
          "external_id": {
            "type": "string",
            "maxLength": 64
          },
          "code": {
            "type": "string",
            "maxLength": 32
          },
          "name": {
            "type": "string",
            "maxLength": 255
          },
          "type": {
            "type": "string",
            "enum": [
              "customer",
              "supplier",
              "both",
              "person"
            ],
            "default": "customer"
          },
          "vat_code": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2
          },
          "address": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          },
          "iban": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ]
      },
      "Invoice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "type": {
            "type": "string",
            "enum": [
              "invoice",
              "credit_note"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "issued"
            ]
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "SF-00001"
            ]
          },
          "contact": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "code": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "issue_date": {
            "type": "string",
            "format": "date"
          },
          "supply_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "currency": {
            "type": "string"
          },
          "total_net": {
            "type": [
              "string",
              "null"
            ],
            "description": "Decimal as string, e.g. \"12.34\"",
            "examples": [
              "12.34"
            ]
          },
          "total_vat": {
            "type": [
              "string",
              "null"
            ],
            "description": "Decimal as string, e.g. \"12.34\"",
            "examples": [
              "12.34"
            ]
          },
          "total_gross": {
            "type": [
              "string",
              "null"
            ],
            "description": "Decimal as string, e.g. \"12.34\"",
            "examples": [
              "12.34"
            ]
          },
          "outstanding": {
            "type": [
              "string",
              "null"
            ],
            "description": "Gross − payments − issued credit notes (EUR); null for drafts",
            "examples": [
              "12.34"
            ]
          },
          "paid": {
            "type": "boolean"
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "item_code": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "description": {
                  "type": "string"
                },
                "quantity": {
                  "type": "string"
                },
                "unit": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "unit_price": {
                  "type": "string"
                },
                "discount_pct": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "tax_code": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "net": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Decimal as string, e.g. \"12.34\"",
                  "examples": [
                    "12.34"
                  ]
                },
                "vat": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Decimal as string, e.g. \"12.34\"",
                  "examples": [
                    "12.34"
                  ]
                },
                "gross": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Decimal as string, e.g. \"12.34\"",
                  "examples": [
                    "12.34"
                  ]
                }
              }
            },
            "description": "Only in single-invoice responses"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "Also changes when a payment is recorded"
          }
        }
      },
      "InvoiceInput": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "pattern": "^[a-z0-9_-]{1,24}$",
            "default": "api",
            "description": "Your system's name — together with `external_id` it makes the request idempotent."
          },
          "external_id": {
            "type": "string",
            "maxLength": 64
          },
          "issue": {
            "type": "boolean",
            "description": "true — issue now (number, ledger); false — draft"
          },
          "contact_id": {
            "type": "integer",
            "description": "Existing contact; or `contact`"
          },
          "contact": {
            "type": "object",
            "properties": {
              "private": {
                "type": "boolean",
                "description": "Sell to the aggregate „Privatūs klientai“ contact"
              },
              "name": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "vat_code": {
                "type": "string"
              },
              "country": {
                "type": "string",
                "minLength": 2,
                "maxLength": 2
              },
              "email": {
                "type": "string",
                "format": "email"
              },
              "address": {
                "type": "string",
                "description": "Required to issue for a company"
              }
            },
            "description": "Found by code → VAT code → e-mail + name, otherwise created"
          },
          "issue_date": {
            "type": "string",
            "format": "date"
          },
          "supply_date": {
            "type": "string",
            "format": "date"
          },
          "due_date": {
            "type": "string",
            "format": "date"
          },
          "currency": {
            "type": "string",
            "default": "EUR"
          },
          "prices_include_vat": {
            "type": "boolean",
            "default": false
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "item_code": {
                  "type": "string",
                  "description": "Goods lines also post cost of goods sold (FIFO)"
                },
                "description": {
                  "type": "string",
                  "description": "Required without item_code"
                },
                "quantity": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "unit": {
                  "type": "string"
                },
                "unit_price": {
                  "type": "number"
                },
                "discount_pct": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "tax_code": {
                  "type": "string",
                  "description": "Default — item / company setting"
                }
              },
              "required": [
                "quantity",
                "unit_price"
              ]
            },
            "minItems": 1,
            "maxItems": 500
          }
        },
        "required": [
          "external_id",
          "issue",
          "issue_date",
          "lines"
        ]
      },
      "Document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "new",
              "processed",
              "rejected"
            ]
          },
          "recognition_status": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "pending",
              "done",
              "failed",
              "skipped",
              null
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "accounting_month": {
            "type": [
              "string",
              "null"
            ]
          },
          "recognized": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "supplier": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "number": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "date": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "gross": {
                "type": [
                  "number",
                  "string",
                  "null"
                ]
              }
            }
          },
          "purchase_invoice": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "integer"
              },
              "number": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "status": {
                "type": "string"
              }
            }
          },
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "size": {
                  "type": "integer"
                }
              }
            }
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OrderInput": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "maxLength": 32,
            "description": "Not a reserved name (shop connections `<platform>-N`, billing sources)"
          },
          "external_id": {
            "type": "string",
            "maxLength": 64
          },
          "reference": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "currency": {
            "type": "string"
          },
          "prices_include_vat": {
            "type": "boolean",
            "default": true
          },
          "customer": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "vat_code": {
                "type": "string"
              },
              "country": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "address": {
                "type": "string"
              },
              "invoice": {
                "type": "boolean"
              }
            }
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "sku": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "quantity": {
                  "type": "number"
                },
                "unit_price": {
                  "type": "number"
                },
                "discount_pct": {
                  "type": "number"
                },
                "vat_rate": {
                  "type": "number"
                },
                "tax_code": {
                  "type": "string"
                }
              }
            },
            "minItems": 1,
            "maxItems": 500
          },
          "payment": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "number"
              },
              "date": {
                "type": "string",
                "format": "date"
              },
              "method": {
                "type": "string",
                "enum": [
                  "bank",
                  "cash"
                ]
              },
              "reference": {
                "type": "string"
              },
              "money_account": {
                "type": "string"
              }
            }
          },
          "expected_gross": {
            "type": "number"
          },
          "expected_vat": {
            "type": "number"
          }
        },
        "required": [
          "source",
          "external_id",
          "date",
          "lines"
        ]
      },
      "RefundInput": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "maxLength": 32
          },
          "order_external_id": {
            "type": "string"
          },
          "external_id": {
            "type": "string",
            "maxLength": 56
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "amount": {
            "type": "number",
            "description": "Money actually paid back to the customer (outgoing payment against the order invoice). Independent of the credit note: omit it if nothing was paid back."
          },
          "method": {
            "type": "string",
            "enum": [
              "bank",
              "cash"
            ]
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "sku": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "quantity": {
                  "type": "number"
                },
                "unit_price": {
                  "type": "number"
                },
                "vat_rate": {
                  "type": "number"
                },
                "tax_code": {
                  "type": "string"
                }
              }
            },
            "description": "Returned goods / services for the credit note. Without `lines` the credit note covers the whole order invoice — send lines for a partial return."
          }
        },
        "required": [
          "source",
          "order_external_id",
          "external_id",
          "date"
        ]
      },
      "OrderResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "created",
              "duplicate"
            ]
          },
          "invoice_id": {
            "type": "integer"
          },
          "number": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid key (`invalid_key`)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "Integrations are not available: unpaid subscription (`subscription_inactive`) or no package (`integration_plan_required`)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "`ability_missing`, `key_owner_inactive`, `plan_feature`, `read_only`",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "`not_found` — also for records of another company",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "`conflict`",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unprocessable": {
        "description": "`validation_failed` (with `errors`) or `ledger_error` (closed period, not enough stock, missing details) — nothing is saved",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "`rate_limited` (see Retry-After) or `integration_cap_reached`",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
