{
  "openapi": "3.1.0",
  "info": {
    "title": "BokföraX API",
    "version": "1",
    "description": "Det öppna API:t i BokföraX. Belopp i svaren är öre (heltal, fält som slutar på Ore); belopp i anropen är kronor. Datum skrivs ÅÅÅÅ-MM-DD. Logga in med en API-nyckel från BokföraX → Inställningar → Integrationer i huvudet Authorization: Bearer <nyckel>. En nyckel som är kopplad till en användare får det användarens roll och bolag tillåter. Fel har formen {\"error\":{\"code\",\"message\"}} med svensk text. Händelser skickas med webhooks (signerade med HMAC-SHA256 i huvudet X-BokforaX-Signature)."
  },
  "servers": [
    {
      "url": "http://127.0.0.1:51789",
      "description": "BokföraX på den egna datorn. I serverläget: byt mot serverns adress."
    }
  ],
  "tags": [
    {
      "name": "Allmänt"
    },
    {
      "name": "Bokföring"
    },
    {
      "name": "Kunder och fakturor"
    },
    {
      "name": "Leverantörer"
    },
    {
      "name": "Rapporter"
    },
    {
      "name": "Inkorg och import"
    },
    {
      "name": "AI-agenter"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/api/v1/health": {
      "get": {
        "tags": [
          "Allmänt"
        ],
        "summary": "Hälsa och version",
        "description": "Öppen. Version, API-version och om parkoppling pågår.",
        "operationId": "getHealth",
        "security": [],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/openapi.json": {
      "get": {
        "tags": [
          "Allmänt"
        ],
        "summary": "Den här specifikationen",
        "description": "Öppen. OpenAPI 3.1.",
        "operationId": "getOpenapi",
        "security": [],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/companies": {
      "get": {
        "tags": [
          "Allmänt"
        ],
        "summary": "Bolagen",
        "description": "Bolagen som nyckelns användare når (alla utan användare). Behörighet: companies/GetAll.",
        "operationId": "getCompanies",
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Company"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapshot": {
      "get": {
        "tags": [
          "Allmänt"
        ],
        "summary": "Ögonblicksbild",
        "description": "Nyckeltal, månader, att göra och deadlines för ett räkenskapsår (samma som telefonen visar).",
        "operationId": "getSnapshot",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "year",
            "in": "query",
            "required": false,
            "description": "Räkenskapsåret som slutar det året, t.ex. 2027 för 2026-10-09 – 2027-12-31 (standard: räkenskapsåret som pågår i dag)",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts": {
      "get": {
        "tags": [
          "Bokföring"
        ],
        "summary": "Kontoplanen",
        "description": "Bolagets konton (BAS). all=true tar med inaktiva konton. Behörighet: accounts/GetAll.",
        "operationId": "getAccounts",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "all",
            "in": "query",
            "required": false,
            "description": "Ta med inaktiva konton",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Account"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/verifications": {
      "get": {
        "tags": [
          "Bokföring"
        ],
        "summary": "Verifikationer",
        "description": "Verifikationer med rader för en period (högst tre år). Behörighet: ledger/List.",
        "operationId": "getVerifications",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Från och med (standard: räkenskapsårets första dag)",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Till och med (standard: räkenskapsårets sista dag)",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Verification"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Bokföring"
        ],
        "summary": "Bokför en verifikation",
        "description": "Raderna måste balansera (debet = kredit, kronor). Kräver en nyckel kopplad till en användare som får bokföra, eller anrop från den egna datorn. Behörighet: ledger/Post.",
        "operationId": "postVerifications",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewVerification"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostedVerification"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/verifications/{id}/pdf": {
      "get": {
        "tags": [
          "Bokföring"
        ],
        "summary": "Verifikationen som PDF",
        "description": "Rader, belopp, skattekoder, dimensioner och historik, och därefter underlaget (bilder och textfiler som egna sidor, PDF-bilagor sammanfogade) — samma som Spara som PDF i BokföraX. Bilagor som inte kunde läggas in står i huvudet X-BokforaX-Not-Included. Behörighet: ledger/Get.",
        "operationId": "getVerificationsIdPdf",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Posten finns inte, eller finns i ett bolag som nyckelns användare inte når (samma svar).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/verifications/{id}/attachments": {
      "post": {
        "tags": [
          "Bokföring"
        ],
        "summary": "Lägg till en bilaga",
        "description": "Kvitto eller faktura (PDF, bild, text, CSV, XML eller Excel) som bilaga till en bokförd verifikation. multipart/form-data med delen file. Behörighet: ledger/AttachFile.",
        "operationId": "postVerificationsIdAttachments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Attachment"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Posten finns inte, eller finns i ett bolag som nyckelns användare inte når (samma svar).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vat": {
      "get": {
        "tags": [
          "Bokföring"
        ],
        "summary": "Momsdeklarationens rutor",
        "description": "Rutorna i öre (hela kronor × 100) för en period: 2026-09, 2026Q3 eller 2026 (helårsmoms: bolagets beskattningsår som slutar 2026, också vid brutet räkenskapsår), med periodens första och sista dag. Behörighet: vat/Build.",
        "operationId": "getVat",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "period",
            "in": "query",
            "required": false,
            "description": "Momsperiod (standard: perioden med dagens datum)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "due",
            "in": "query",
            "required": false,
            "description": "Helårsmoms: momsdeadlinens dag, som väljer perioden när två helår slutar samma kalenderår (frivillig)",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Vat"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/deadlines": {
      "get": {
        "tags": [
          "Bokföring"
        ],
        "summary": "Deadlines",
        "description": "Moms, arbetsgivardeklaration, deklarationer och årsredovisning (högst fem år). Behörighet: deadlines/List.",
        "operationId": "getDeadlines",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Från och med (standard: i dag)",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Till och med (standard: ett år fram)",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers": {
      "get": {
        "tags": [
          "Kunder och fakturor"
        ],
        "summary": "Kunderna",
        "description": "Kundregistret. text söker i namn och organisationsnummer. Behörighet: customers/GetAll.",
        "operationId": "getCustomers",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "text",
            "in": "query",
            "required": false,
            "description": "Söktext (valfri)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Customer"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Kunder och fakturor"
        ],
        "summary": "Ny kund",
        "description": "Lägger till en kund i kundregistret. Behörighet: customers/Add.",
        "operationId": "postCustomers",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewCustomer"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/articles": {
      "get": {
        "tags": [
          "Kunder och fakturor"
        ],
        "summary": "Artiklarna",
        "description": "Artikelregistret (pris exklusive moms i öre). all=true tar med inaktiva. Behörighet: articles/List.",
        "operationId": "getArticles",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "all",
            "in": "query",
            "required": false,
            "description": "Ta med inaktiva artiklar",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Article"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/articles/barcode/{code}": {
      "get": {
        "tags": [
          "Kunder och fakturor"
        ],
        "summary": "Artikel på streckkod",
        "description": "Artikeln för en streckkod: artikelns egen kod (EAN/GTIN), en förpacknings kod (quantity = förpackningens antal) eller artikelnumret. 404 när ingen artikel har koden. Behörighet: articleTools/FindBarcode.",
        "operationId": "getArticlesBarcodeCode",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BarcodeArticle"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices": {
      "get": {
        "tags": [
          "Kunder och fakturor"
        ],
        "summary": "Skickade kundfakturor",
        "description": "Obetalda (status=unpaid, standard) eller nyligen betalda (status=paid). Behörighet: invoices/List.",
        "operationId": "getInvoices",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "unpaid eller paid",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Kunder och fakturor"
        ],
        "summary": "Nytt fakturautkast",
        "description": "Skapar ett utkast. Förfallodag och referens följer kundens villkor. Utkastet bokförs och skickas från BokföraX — aldrig av API:t. Behörighet: invoices/SaveDraft.",
        "operationId": "postInvoices",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewInvoice"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Created"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices/{id}": {
      "get": {
        "tags": [
          "Kunder och fakturor"
        ],
        "summary": "En kundfaktura",
        "description": "Fakturan med rader, betalningar och påminnelser (inte utkast). Behörighet: invoices/Get.",
        "operationId": "getInvoicesId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Posten finns inte, eller finns i ett bolag som nyckelns användare inte når (samma svar).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices/{id}/pdf": {
      "get": {
        "tags": [
          "Kunder och fakturor"
        ],
        "summary": "Fakturans PDF",
        "description": "Kopian som skickades till kunden, annars en ny PDF. Behörighet: invoices/Get.",
        "operationId": "getInvoicesIdPdf",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Posten finns inte, eller finns i ett bolag som nyckelns användare inte når (samma svar).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/suppliers": {
      "get": {
        "tags": [
          "Leverantörer"
        ],
        "summary": "Leverantörerna",
        "description": "Leverantörsregistret. Bankuppgifter lämnas inte ut. Behörighet: suppliers/List.",
        "operationId": "getSuppliers",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Supplier"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Leverantörer"
        ],
        "summary": "Ny leverantör",
        "description": "Lägger till en leverantör. Bankgiro, plusgiro och IBAN läggs in i BokföraX (där ändringar kontrolleras mot bedrägeri). Behörighet: suppliers/Save.",
        "operationId": "postSuppliers",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewSupplier"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Supplier"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/supplierinvoices": {
      "get": {
        "tags": [
          "Leverantörer"
        ],
        "summary": "Leverantörsfakturor",
        "description": "Obetalda (status=unpaid, standard) eller alla (status=all), med mottagaren att betala till (bankgiro, plusgiro eller IBAN — leverantörsregistret i första hand, som i betalfilen) och OCR-numret. Behörighet: supplierInvoices/List.",
        "operationId": "getSupplierinvoices",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "unpaid eller all",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SupplierInvoice"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Leverantörer"
        ],
        "summary": "Registrera en leverantörsfaktura",
        "description": "Bokförs (faktureringsmetoden) eller väntar på betalning (kontantmetoden) som i appen; attest gäller när bolaget kräver den. vatAmount (momsen på fakturan) krävs när skattekoden har svensk moms (IN25 som standard, IN12, IN6) — ange 0 om fakturan saknar moms. Utan den svarar API:t 400, så att ingen avdragsgill moms försvinner. Behörighet: supplierInvoices/Register.",
        "operationId": "postSupplierinvoices",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewSupplierInvoice"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupplierInvoiceCreated"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/supplierinvoices/{id}/paid": {
      "post": {
        "tags": [
          "Leverantörer"
        ],
        "summary": "Markera som betald",
        "description": "Fakturan är betald (t.ex. i bankappen): BokföraX bokför betalningen av det som återstår från account (standard 1930; ett betalkonto i bolaget) på date (standard i dag), som i appen. Ingen betalning skickas till banken. requestId gör anropet säkert att upprepa. Fakturor i utländsk valuta, kreditfakturor, bestridda och ej attesterade fakturor ger 409. Behörighet: supplierInvoices/Pay.",
        "operationId": "postSupplierinvoicesIdPaid",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupplierInvoicePaidRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupplierInvoicePaid"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Posten finns inte, eller finns i ett bolag som nyckelns användare inte når (samma svar).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/income-statement": {
      "get": {
        "tags": [
          "Rapporter"
        ],
        "summary": "Resultaträkning",
        "description": "Intäkter och kostnader per avsnitt och konto för en period (högst två år). Behörighet: reports/IncomeStatementRange.",
        "operationId": "getReportsIncomeStatement",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "description": "Från och med (krävs)",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "description": "Till och med (krävs)",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Statement"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/balance-sheet": {
      "get": {
        "tags": [
          "Rapporter"
        ],
        "summary": "Balansräkning",
        "description": "Tillgångar, eget kapital och skulder per dag. Behörighet: reports/BalanceSheetAsOf.",
        "operationId": "getReportsBalanceSheet",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "asOf",
            "in": "query",
            "required": false,
            "description": "Balansdag (standard: i dag)",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BalanceSheet"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/custom": {
      "get": {
        "tags": [
          "Rapporter"
        ],
        "summary": "Egna rapporter",
        "description": "Bolagets sparade egna rapporter (id, namn, källa) och de färdiga att utgå från (nyckel och rubrik). Behörighet: customReports/List.",
        "operationId": "getReportsCustom",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/custom/{id}": {
      "get": {
        "tags": [
          "Rapporter"
        ],
        "summary": "En egen rapport",
        "description": "Kör en sparad egen rapport (id) eller en färdig (nyckeln, till exempel inbetalningar eller dokument) för perioden: kolumner, rader (text och belopp i öre) och upplysningar. Källan läses bara om nyckelns användare får läsa den. format=csv ger CSV för Excel. Behörighet: customReports/RunSaved.",
        "operationId": "getReportsCustomId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Från och med (standard: räkenskapsårets första dag)",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Till och med (standard: räkenskapsårets sista dag)",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "json (standard) eller csv",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Posten finns inte, eller finns i ett bolag som nyckelns användare inte når (samma svar).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/inbox": {
      "post": {
        "tags": [
          "Inkorg och import"
        ],
        "summary": "Skicka ett kvitto till Inkorgen",
        "description": "multipart/form-data med delarna meta (JSON) och file. Posten väntar i Inkorgen tills någon godkänner den i BokföraX. Behörighet: inbox/Create.",
        "operationId": "postInbox",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "meta",
                  "file"
                ],
                "properties": {
                  "meta": {
                    "type": "string",
                    "description": "JSON {clientId, companyId, sha256, fileName, mimeType, …} (contract/inbox-upload.md)"
                  },
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/receipts/payment-accounts": {
      "get": {
        "tags": [
          "Inkorg och import"
        ],
        "summary": "Betalkonton för kvitton",
        "description": "Kontona som ett kvitto kan ha betalats från (\"Betalt med\"): kassa och bankkonton (19xx), företagets kreditkort och PayPal. Skicka kontot som paymentAccount i kvittots meta; utan det används 1930. Behörighet: accounts/GetAll.",
        "operationId": "getReceiptsPaymentAccounts",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PaymentAccount"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/import/{kind}": {
      "post": {
        "tags": [
          "Inkorg och import"
        ],
        "summary": "Importera en fil",
        "description": "kind: amazon, bank, shopify, stripe, paypal, orders, inkop, klarna, zettle, sumup, swish, etsy, woocommerce, kassa. multipart/form-data med delen file. Samma klassning och avprickning som i appen. Behörighet: importRouter/Import.",
        "operationId": "postImportKind",
        "parameters": [
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "amazon",
                "bank",
                "shopify",
                "stripe",
                "paypal",
                "orders",
                "inkop",
                "klarna",
                "zettle",
                "sumup",
                "swish",
                "etsy",
                "woocommerce",
                "kassa"
              ]
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Bolagets id (standard: det förvalda bolaget)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "account",
            "in": "query",
            "required": false,
            "description": "Bankkontot för kind=bank (1900–1999, standard 1930)",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportResult"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/inbox/{id}/approve": {
      "post": {
        "tags": [
          "Inkorg och import"
        ],
        "summary": "Godkänn ett förslag",
        "description": "Bokför inkorgsposten enligt förslaget. Behörighet: inbox/Approve.",
        "operationId": "postInboxIdApprove",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Posten finns inte, eller finns i ett bolag som nyckelns användare inte når (samma svar).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/mcp": {
      "post": {
        "tags": [
          "AI-agenter"
        ],
        "summary": "MCP (Streamable HTTP)",
        "description": "Model Context Protocol 2025-06-18: ett JSON-RPC-meddelande per anrop (initialize, tools/list, tools/call). Samma verktyg som bokfora mcp. Läget (bara läsa, eller läsa och föreslå) väljs i BokföraX under Inställningar → Integrationer.",
        "operationId": "postMcp",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcMessage"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Svaret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcMessage"
                }
              }
            }
          },
          "400": {
            "description": "Felaktigt anrop (svensk förklaring i error.message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ingen eller okänd nyckel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Nyckelns användare får inte göra det, eller når inte bolaget.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "API-nyckel från Inställningar → Integrationer."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorBody"
          }
        },
        "required": [
          "error"
        ]
      },
      "ErrorBody": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "Health": {
        "type": "object",
        "properties": {
          "app": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "apiVersion": {
            "type": "integer"
          },
          "serverName": {
            "type": "string"
          },
          "pairingOpen": {
            "type": "boolean"
          },
          "time": {
            "type": "string"
          }
        }
      },
      "Company": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "form": {
            "type": "string"
          },
          "taxMode": {
            "type": "string"
          },
          "vatStatus": {
            "type": "string"
          },
          "isPractice": {
            "type": "boolean"
          }
        }
      },
      "Account": {
        "type": "object",
        "properties": {
          "number": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "Verification": {
        "type": "object",
        "properties": {
          "series": {
            "type": "string"
          },
          "number": {
            "type": "integer"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "description": {
            "type": "string"
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VerificationRow"
            }
          }
        }
      },
      "VerificationRow": {
        "type": "object",
        "properties": {
          "account": {
            "type": "integer"
          },
          "debitOre": {
            "type": "integer"
          },
          "creditOre": {
            "type": "integer"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "taxCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "project": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "NewVerification": {
        "type": "object",
        "properties": {
          "companyId": {
            "type": "integer"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "description": {
            "type": "string"
          },
          "series": {
            "type": "string"
          },
          "reference": {
            "type": "string"
          },
          "counterparty": {
            "type": "string"
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NewVerificationRow"
            }
          }
        },
        "required": [
          "date",
          "description",
          "rows"
        ]
      },
      "NewVerificationRow": {
        "type": "object",
        "properties": {
          "account": {
            "type": "integer"
          },
          "debit": {
            "type": "number"
          },
          "credit": {
            "type": "number"
          },
          "taxCode": {
            "type": "string"
          },
          "project": {
            "type": "string"
          },
          "costCenter": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        },
        "required": [
          "account"
        ]
      },
      "PostedVerification": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "series": {
            "type": "string"
          },
          "number": {
            "type": "integer"
          },
          "date": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "Attachment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "fileName": {
            "type": "string"
          },
          "sizeBytes": {
            "type": "integer"
          },
          "addedAt": {
            "type": "string"
          }
        }
      },
      "Vat": {
        "type": "object",
        "properties": {
          "period": {
            "type": "string"
          },
          "boxes": {
            "type": "object"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "from": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "label": {
            "type": "string"
          }
        }
      },
      "Customer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "orgNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "address": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": "string"
          },
          "vatNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "paymentTermsDays": {
            "type": [
              "integer",
              "null"
            ]
          },
          "language": {
            "type": "string"
          },
          "yourReference": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "NewCustomer": {
        "type": "object",
        "properties": {
          "companyId": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "orgNumber": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "vatNumber": {
            "type": "string"
          },
          "paymentTermsDays": {
            "type": "integer"
          },
          "language": {
            "type": "string"
          },
          "yourReference": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ]
      },
      "Article": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "number": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "priceOre": {
            "type": "integer"
          },
          "vatPercent": {
            "type": "integer"
          },
          "kind": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "BarcodeArticle": {
        "type": "object",
        "properties": {
          "article": {
            "$ref": "#/components/schemas/Article"
          },
          "quantity": {
            "type": "number"
          },
          "packaging": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "NewInvoice": {
        "type": "object",
        "properties": {
          "companyId": {
            "type": "integer"
          },
          "customerId": {
            "type": "integer"
          },
          "invoiceDate": {
            "type": "string",
            "format": "date"
          },
          "currency": {
            "type": "string"
          },
          "yourReference": {
            "type": "string"
          },
          "ourReference": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NewInvoiceRow"
            }
          }
        },
        "required": [
          "customerId",
          "rows"
        ]
      },
      "NewInvoiceRow": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "quantity": {
            "type": "number"
          },
          "unitPrice": {
            "type": "number"
          },
          "vatPercent": {
            "type": "integer"
          },
          "articleId": {
            "type": "integer"
          },
          "unit": {
            "type": "string"
          },
          "discountPercent": {
            "type": "number"
          },
          "project": {
            "type": "string"
          }
        }
      },
      "Created": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "message": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Supplier": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "orgNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": "string"
          },
          "vatNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "defaultAccount": {
            "type": "integer"
          },
          "defaultTaxCode": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "NewSupplier": {
        "type": "object",
        "properties": {
          "companyId": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "orgNumber": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "vatNumber": {
            "type": "string"
          },
          "defaultAccount": {
            "type": "integer"
          },
          "defaultTaxCode": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ]
      },
      "SupplierInvoice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "supplier": {
            "type": "string"
          },
          "invoiceNumber": {
            "type": "string"
          },
          "invoiceDate": {
            "type": "string",
            "format": "date"
          },
          "dueDate": {
            "type": "string",
            "format": "date"
          },
          "currency": {
            "type": "string"
          },
          "totalOre": {
            "type": "integer"
          },
          "vatOre": {
            "type": "integer"
          },
          "remainingOre": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "statusText": {
            "type": "string"
          },
          "payTo": {
            "type": [
              "string",
              "null"
            ]
          },
          "bankgiro": {
            "type": [
              "string",
              "null"
            ]
          },
          "plusgiro": {
            "type": [
              "string",
              "null"
            ]
          },
          "iban": {
            "type": [
              "string",
              "null"
            ]
          },
          "paymentReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "paymentReferenceIsOcr": {
            "type": "boolean"
          },
          "paidBlocked": {
            "type": [
              "string",
              "null"
            ]
          },
          "paidByAutogiro": {
            "type": "boolean"
          }
        }
      },
      "SupplierInvoicePaidRequest": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "account": {
            "type": "integer"
          },
          "requestId": {
            "type": "string"
          }
        }
      },
      "SupplierInvoicePaid": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "verification": {
            "type": [
              "string",
              "null"
            ]
          },
          "invoice": {
            "$ref": "#/components/schemas/SupplierInvoice"
          }
        }
      },
      "NewSupplierInvoice": {
        "type": "object",
        "properties": {
          "companyId": {
            "type": "integer"
          },
          "supplierId": {
            "type": "integer"
          },
          "supplierName": {
            "type": "string"
          },
          "invoiceNumber": {
            "type": "string"
          },
          "invoiceDate": {
            "type": "string",
            "format": "date"
          },
          "dueDate": {
            "type": "string",
            "format": "date"
          },
          "amount": {
            "type": "number"
          },
          "vatAmount": {
            "type": "number"
          },
          "taxCode": {
            "type": "string"
          },
          "account": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "paymentReference": {
            "type": "string"
          },
          "payTo": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "isCredit": {
            "type": "boolean"
          }
        },
        "required": [
          "invoiceDate",
          "dueDate",
          "amount"
        ]
      },
      "SupplierInvoiceCreated": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "message": {
            "type": "string"
          },
          "verification": {
            "type": [
              "string",
              "null"
            ]
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Statement": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "format": "date"
          },
          "to": {
            "type": "string",
            "format": "date"
          },
          "incomeOre": {
            "type": "integer"
          },
          "costOre": {
            "type": "integer"
          },
          "resultOre": {
            "type": "integer"
          },
          "sections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StatementSection"
            }
          }
        }
      },
      "StatementSection": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "isIncome": {
            "type": "boolean"
          },
          "totalOre": {
            "type": "integer"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StatementLine"
            }
          }
        }
      },
      "StatementLine": {
        "type": "object",
        "properties": {
          "account": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "amountOre": {
            "type": "integer"
          }
        }
      },
      "BalanceSheet": {
        "type": "object",
        "properties": {
          "asOf": {
            "type": "string",
            "format": "date"
          },
          "totalAssetsOre": {
            "type": "integer"
          },
          "totalEquityAndLiabilitiesOre": {
            "type": "integer"
          },
          "currentYearResultOre": {
            "type": "integer"
          },
          "assets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BalanceGroup"
            }
          },
          "equityAndLiabilities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BalanceGroup"
            }
          }
        }
      },
      "BalanceGroup": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "closingOre": {
            "type": "integer"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BalanceLine"
            }
          }
        }
      },
      "BalanceLine": {
        "type": "object",
        "properties": {
          "account": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "openingOre": {
            "type": "integer"
          },
          "changeOre": {
            "type": "integer"
          },
          "closingOre": {
            "type": "integer"
          }
        }
      },
      "PaymentAccount": {
        "type": "object",
        "properties": {
          "account": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "isDefault": {
            "type": "boolean"
          }
        }
      },
      "ImportResult": {
        "type": "object",
        "properties": {
          "inboxItems": {
            "type": "integer"
          },
          "earnings": {
            "type": "integer"
          },
          "orders": {
            "type": "integer"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "JsonRpcMessage": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "type": "string"
          },
          "id": {
            "type": "integer"
          },
          "method": {
            "type": "string"
          },
          "params": {
            "type": "object"
          },
          "result": {
            "type": "object"
          },
          "error": {
            "type": "object"
          }
        },
        "required": [
          "jsonrpc"
        ]
      }
    }
  }
}
