За developers: API за интеграции
Друга програма (вашата счетоводна програма, скрипт, онлайн магазин) работи с данните на една фирма през REST API — със същите действия като екраните, само с правата, които собственикът ѝ е дал.
Ключ
- Собственикът на фирмата прави ключ в Настройки → Интеграции: име, права (преглед, приключване, качване, запис, свързване, импорт) и срок. Ключът се показва веднъж.
- Всяка заявка носи
Authorization: Bearer pa_live_…. Фирмата идва от ключа. - Адресът:
https://app.ravnosmetka.io/api/v1/… - Ключът не стига до действията на собственика (хора, настройки, ключове, закриване) и до предаването на месеца.
- Всичко, което интеграцията направи, се записва като „интеграция <име>“.
curl -H "Authorization: Bearer pa_live_…" https://app.ravnosmetka.io/api/v1/transactions
Правила
| Какво | Как |
|---|---|
| Суми | Цели числа в стотинки / центове (12000 = 120,00) |
| Грешка | { error, source, retryable?, ref? } — source е input, internal или външната услуга |
| 401 | Няма ключ, грешен, изтекъл или спрян |
| 403 | Ключът няма правото за това действие |
| 429 | Над 600 заявки в минута за интеграцията; вижте Retry-After |
| 423 | Фирмата е закрита — само четене |
Действия (208)
Описанията са на английски, както в спецификацията на API. Колоната „Право“ казва кое право на ключа е нужно (едно от изброените).
offices
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/trial | всеки ключ | The trial of the company's payer (#706; anyone in the company): { key, status: none | trial | ended | paying, daysLeft, documentsLeft, used, days, documents, endsAt, warn }. The plans' trial (days or documents, whichever comes first) counted over all the payer's companies; when it ends the company is read-only (402 trial_ended) except the export, closing and leaving the office |
Фирмата
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/info | всеки ключ | Role of the caller in this company, demo flag, whether extraction is available |
Файлове за преглед
| Заявка | Право | Описание |
|---|---|---|
POST /api/v1/phone-links | качване | A file from the phone (#467): a short link for this person (upload right) — { token, url, expiresAt, maxFiles, qrSvg }. The phone opens url without signing in (GET /p/:token, a page; POST /p/:token/upload, the file as the body, x-file-name) and each file goes in through POST /inbox/upload as this person. Works 15 minutes, up to 30 files; 409 when uploading is switched off |
GET /api/v1/phone-links/:token | качване | The files that came through the link so far — { expiresAt, files: [{ id, name, status, skipped?, at }] }; only for the person who made it, else 404 (expired, stopped or another person's) |
DELETE /api/v1/phone-links/:token | качване | Stop the link (the window on the computer closed); 204 |
POST /api/v1/inbox/:id/split-pages | качване | "✂ Раздели на документи…" (#557): a PDF candidate of several documents split by hand — { starts: [the pages a new document starts with] }; the parts are taken in as candidates (source.split { name, pages, of, byHand }), the file is taken off the list (a decision split). Also: a PDF of several documents is split by itself when taken in, by the text of its pages |
POST /api/v1/inbox/merge | качване | Files joined (#240, #557: files first — the files become ONE new PDF file, read as a candidate; the files joined stay with status merged, mergedInto; a long receipt (layout strip) stays a picture of its photos): body { ids } (2–30 files, in page order), layout: pages (default) | strip — a long receipt in several overlapping photos (#241): read as one strip (each line once), stitched into one picture (strip { file, height, joints }; GET /inbox/:id/file?strip=1), the sum of the lines checked against the total; only photos. The first leads: it gets pages [{ id, file, name }] and is read again with every page in one model call; the others become status "page" (pageOf, page) and keep how they were in beforeMerge. 409 for a saved file, a statement or one that already has pages. |
POST /api/v1/inbox/:id/split | качване | "Раздели" (#240): the pages of a document are files of their own again, as they were before the merge (no reading again). 409 when the document is saved. |
POST /api/v1/inbox/groups/dismiss | качване | Photos suggested as one long receipt (#241) that are not: { ids } — the group is not offered again (upload) |
GET /api/v1/files | преглед / качване | month/from/to: the month a file came in (#663), month on each: the month its document goes to; group=waiting|ready|review|duplicate|error|rejected|document|all — the filters of the one Файлове screen (#563), groupCounts how many in each; each file has party, number, total, currency, issueDate as read. came=d7|d30|all — by when the files came instead of the documents' month, q= a search by name, limit= how many (default 100; total says all) (#454). Files (#233, #234): every file that came in, newest first; groups: [{ ids, names, why }] — photos that look like one long receipt (#241), ordered top → bottom — { files: [{ id, name, kind, hasFile, hash, at, source { kind: upload|drive|gmail|returned, label, by, from, subject, path… }, operationId, result: reading|ready|review|document|rejected|duplicate|error|replaced, reasons, decidedBy { kind: agent|rule|person, name, id? }, document { kind: invoice|cash|statement, id } | null, confidence, month (of the issue date, null while unknown) }], counts { all, <result>: n } }. ?result= filters the list; ?source= and the period (?month= / ?from=&to=: the month of the issue date of the document — the accounting period; a file with no date read yet belongs to every period) filter both the list and the counts. The original: GET /inbox/:id/file. An employee sees only their own uploads. |
GET /api/v1/inbox | преглед / качване | month/from/to: the month a file came in (#663), month on each: the month its document goes to; waiting=all — every waiting file whatever the period; the saved and rejected still by it (#454). fields.reading.score is the rating as the checks say today (a kept reading is scored again from its values, nothing written; by hand stays). Documents waiting for review (bulk upload, Google Drive) with their status and month (the invoice date; null while unknown); ?from=&to= (or ?month=) lists that period plus the documents without a date; ?all=true includes saved and discarded; ?saved=true includes the saved ones (with invoiceId), not the discarded (#176); ?discarded=true includes the rejected ones, with discard { reason, note, by, at } and decisionId (POST /decisions/:id/reverse puts one back, #179); ?ruled=true lists the documents inbox rules handled (removed ones too), newest first; ?confidence=high|low: only the readings we are sure / not sure of (#152) — fields.reading { confidence, reasons, fields: { <field>: { value, page, box [left, top, right, bottom] 0–1, approx, sure, reason, usual } } } |
GET /api/v1/inbox/:id | преглед / качване | One inbox item (a file) with its reading, status and history — for the one file window (#563); 404 for another employee's |
GET /api/v1/inbox/:id/file | преглед / качване | The file of an inbox item; ?page=N: that page of a document of several pages (#240) |
POST /api/v1/inbox/upload | качване | Bulk upload: one file as the request body (x-file-name header; ?hold=1: a page taken on the phone — kept with status "held", not read, until POST /inbox/merge reads the pages together (#240); a .zip is opened and each file inside is taken in on its own, with source.zip { name, path } — the answer is then { zip: true, name, items, skipped } (#238), also for Drive and Gmail; x-transaction-id for a receipt of a card payment — linked when saved); invoices (PDF, photos, spreadsheets .ods/.xlsx) are read right away and get a status (ready / needs_review / not_ours / duplicate / error), statements wait for their preview |
POST /api/v1/inbox/:id/accept-anyway | запис | "Приеми въпреки грешката" (#507): a digital document rejected for an error in itself (or a suspicious one) saved at the person's own risk — { reason } (3–500 chars); the invoice keeps its errors (red) and acceptedAnyway { by, at, reason, errors }; recorded as a decision (saved_anyway). 409 when the document was not rejected for an error in itself, 422 when it still cannot be saved (a duplicate, no lines) |
POST /api/v1/inbox/:id/save | запис | Save an inbox document (#247: a rejected one → 409 — a digital document wrong in itself, discard.reason "wrong_digital", is never saved, filled by hand or put back; a suspicious one, status "suspicious" — a receipt whose QR code confirms the reading but whose sums are wrong — only with { confirm: true }, else 409; the approval is recorded as a decision) — status "suspicious", #247: read exactly, but its own sums / VAT / EIK are wrong — only with { confirm: true }, else 409; the approval is recorded as a decision) — an invoice through POST /invoices with the same checks (confirmNotOurs to save one that is not for the company), a cash receipt as an expense of the cash desk (#137); confirm: a person checked a document that waited for a look and saves it anyway, recorded as a review decision (#183). receipt { number, issueDate, sellerName, sellerEik, net, vat, total }: a cash receipt corrected by hand — the checks run on the corrected values; when one still fails it is not saved (the document comes back with the reasons) unless confirm; the correction is a review decision (#189). Saving is an operation (#181) |
POST /api/v1/inbox/save-ready | запис | Save every inbox invoice with status ready (?from=&to=: only that period) — runs in the background: 202 + operationId, follow /operations/:id/events |
POST /api/v1/inbox/:id/done | запис / импорт | Mark an inbox item as handled elsewhere (statement imported, invoice saved through the form) |
GET /api/v1/inbox/unread | преглед / качване | Files not read (#724): { counts: { other_company, paused, cap, pages, trial }, total, groups: [{ reason: paused | other_company, operationId, ids, count, otherBefore, readIds (the files of the run read before the pause, not for the company), moveTo: { companyId, name } | null }] } — a paused run or files for another company, and a company of the person's with the number found on them (where they may be moved). An employee sees only their own |
POST /api/v1/inbox/unread/read | качване | Read files that wait unread now (#724): { ids } — Read / Go on: a person says yes to a paused run (it does not pause again), to a PDF of other companies and to a scan of many pages; the payer's AI cap and the trial still hold them back → { items, read, waiting } |
POST /api/v1/inbox/unread/move | качване | Move files that wait unread — or were read as not for the company — to the company they are for (#724): { ids, companyId } — one of the person's companies where they may upload (404 otherwise; 423 closed, 403 DPA not accepted, 402 trial ended there). There they come in as an upload (source moved, from where and by whom) and are read; here they are removed with the reason moved → { moved, companyId, name, items: [{ id, to }] } |
POST /api/v1/inbox/unread/discard | качване | Remove files that wait unread (#724): { ids } — Cancel: files for another company or of a paused run as not for the company; the others as other. A decision that can be reversed (POST /decisions/:id/reverse) → { discarded } |
POST /api/v1/inbox/:id/retry | качване | Read a document that failed again from its original (stored copy, Drive or Gmail); a new item replaces it (owner); ?strong=true (#462): a read invoice still waiting, read again by the strong model from the document itself (not its text layer) — owner only |
POST /api/v1/inbox/retry-errors | качване | Read every failed document again (?from=&to=: only that period and the undated ones), up to ?limit= (default 30), as one operation, in the background: 202 + operationId (owner) |
POST /api/v1/inbox/:id/swap-parties | запис | Seller and buyer the other way round on a read invoice waiting in Файлове (#460) — also a digital one: the direction and the counterparty follow, the file is checked again, the step is in its history; again → back. 400 for a receipt, a protocol by art. 117 or a file not waiting |
POST /api/v1/inbox/recheck | качване | The waiting files checked again by today's rules (#445), from what was read — no model called: whose they are, a digital one not for the company rejected by itself, the checks of the document itself; returns { changed, operationId } |
DELETE /api/v1/inbox/:id | качване | Throw an inbox item away (the original in Drive is not touched); body { reason, note } says why it is not an invoice (proforma, offer, delivery_note, contract, newsletter, bank_notice, other) |
POST /api/v1/inbox/:id/restore | качване | "Не е по правилото — върни": a document a rule removed or labelled goes back to how it was |
GET /api/v1/decisions | преглед | The period (?month= / ?from=&to=) is the month of the issue date of the document: a decision taken later about an October invoice is in October (#247); a document with no date: the month of the decision. Review decisions (#113): who, when, which document, what (discarded, rule, saved_anyway, filled_by_hand, done_elsewhere, retried), reason, note, rule, edits, reversed; filters ?from=&to= (when taken), kind, reason, by, itemId, invoiceId; newest first |
PATCH /api/v1/decisions/:id | запис | Change the reason or note of a decision; the change is kept in its history (from → to, who, when) and the document says the same |
POST /api/v1/decisions/:id/reverse | запис | "Върни за преглед": a removed document (by hand or by a rule) goes back to how it was; saving is undone through its operation (400) |
GET /api/v1/inbox-rules | преглед | Rules for documents that are not invoices: conditions (from, fileName, words, counterparty, source), reason, action (discard / label), hits, on/off |
GET /api/v1/inbox-rules/:id/matches | преглед | The documents waiting for a look that the rule fits now |
POST /api/v1/inbox-rules/:id/apply | запис | "Приложи към N": apply the rule to the documents it fits now — one operation, undoable |
GET /api/v1/intake | преглед / качване | Every source with what it takes in (#116) and, since #151, its switch (enabled; until set the old agent.importDrive / importGmail are taken over), autoSave (#395; until set the old agent.autoSaveReady), label, lastRun { at, taken, files? }, changedBy / changedAt; email (#616) also has address — the company's document e-mail address ("" until the system has a document mailbox), formerAddresses (#685: its addresses on the former mailboxes, which still bring documents in) — and senders, the allowed senders ("" = all) |
POST /api/v1/download/files | преглед / качване | Download files of the inbox (#637): { ids } → one file: itself, as it came; several: a ZIP of the originals. An employee only the ones they uploaded; 404 when none |
Хора
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/names | всеки ключ | The names of the company's people (#324): { email: display name, or the e-mail when none is set } — for any member |
Месецът
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/months | преглед | Months with data and whether each one is balanced |
GET /api/v1/months/:month/summary | преглед | Totals per currency and counters for a month |
GET /api/v1/summary | преглед | Totals per currency and counters for a period of months (?from=YYYY-MM&to=YYYY-MM) — counts.matched: movements matched or needing no document (#193); balanced only when every month in it is |
Качване и разчитане
| Заявка | Право | Описание |
|---|---|---|
POST /api/v1/uploads | качване / запис | Upload a raw file (PDF/JPG/PNG/WEBP as the request body); returns its file reference |
POST /api/v1/extract/invoice | качване / запис | Read an uploaded invoice with Claude and return pre-filled fields (cheap model first, escalates when checks fail); belongsTo says whether the company is seller or buyer and sets the kind |
GET /api/v1/chart | преглед | Since #648 each account has roles [{ role, label, chosen }] and banks [iban], plus roles (every role with its code, default, problem, entries) and roleProblems (a role an entry needs and the chart lacks); POST /chart/import also gives roleSuggestions. The chart of accounts (#14, #294): { chart: { source: template | import, name, accounts: [{ code (digits, or with sub-accounts after / . - as written: 503/1, 401.12.3, 401-12), name (null for a synthetic group), type: equity | fixed_assets | inventory | settlements | cash | expense | income | other | off_balance, parent (503/1 → 503; 6021 → 602 when 602 is in the chart; else null), children: [code], depth, group, leaf (only a leaf can be put on a line), synthetic (a parent added for a sub-account code, not in the chart itself), kept (in use, kept from the previous chart) }] sorted by code, count (the accounts of the chart itself), loadedAt, by, editedAt?, editedBy? } | null, waitingForAccount: how many invoices have a line without an account (0 without a chart), templates: [{ id, name, accounts }], types: [the kinds] }. |
POST /api/v1/chart/template | запис | Load a ready template as the chart of accounts, replacing the one there: { template: nss } (the national chart, the accounts a small company uses, in euro); → { chart, kept: [{ code, name, invoices }], waitingForAccount }. Accounts used on invoice lines that the template lacks are kept (kept: true) and listed. Owner. |
POST /api/v1/chart/import | запис | Import the chart of accounts from a file, replacing the one there: { name?, text } (CSV/TSV/"code; name" per line) or { name?, file } (base64: .xlsx — its biggest sheet — or a text file in UTF-8 / Windows-1251). Rows before the first account are titles or a header naming the columns (Сметка/Код, Наименование/Име, Вид/Тип); quoted fields; an optional kind column (разход, приход, актив, пасив, разчет, капитал, парични, запаси, ДМА, задбалансова, друга, or a type id; А/П/АП and unknown words: by the class — unknown words are listed in warnings). Codes kept as written. → { chart, skipped: [{ line, text, reason }] (no code and name, a code twice), warnings: [{ line, text, reason }], kept: [{ code, name, invoices }] (accounts used on invoice lines that the file lacks: kept in the chart with kept: true, not dropped), waitingForAccount }; 400 when no account is in it or the file cannot be read. Owner. |
POST /api/v1/chart/accounts | запис | Add an account by hand (#294), e.g. a sub-account: { code, name, type? } — the kind defaults to the parent's, else by the class; → { chart, account, note? } (note: the parent is already on invoice lines and stays there until a sub-account is chosen); 409 without a chart or when the code is there. Owner. |
PATCH /api/v1/chart/accounts/:code | запис | Rename an account or change its kind (#294): { name?, type? }; the code URL-encoded (503%2F1); → { chart, account }; 404 when not in the chart. Owner. |
DELETE /api/v1/chart/accounts/:code | запис | Remove an account (#294), the code URL-encoded; 409 when it has sub-accounts or is on an invoice line (how many invoices); → { chart }. Owner. |
GET /api/v1/entry-accounts | преглед | The accounts of the entries (#295): { roles: [{ role, label, code, default, chosen, name, problem }], banks: [{ iban, label, code, chosen, name, problem }], problems, chart } |
PUT /api/v1/entry-accounts | запис | Choose the accounts of the entries (#295): { roles: { suppliers|clients|vatPurchases|vatSales|bank|cash|staff|social|taxes|persons|otherDebtors|otherCreditors|financialCosts: code | "" (default) }, banks: { IBAN: code | "" } } — only a leaf of the chart (400 otherwise); 409 without a chart |
GET /api/v1/entries | преглед | #671: with settings.vatCredit.monthlyPartialTransfer an entry { kind: partial_credit, date (the month's last day), month, partialVat, coefficient, amount, lines Дт 4531 / Кт 4534 } per month among the payments (no coefficient: no lines, a problem). #650: ?state=accepted|unknown filters the invoice entries (also=ids keeps those in view whatever their state); each has state, lineStates and noAccount; the answer has states { all, accepted, unknown } and noAccount { invoices, lines }. Each invoice entry has suggestions (#602), as GET /invoices/:id lineSuggestions; a line without tax credit puts its VAT in its cost, not 4531; with partial credit 4531 takes the VAT × the art. 73 coefficient (settings.vatCredit.coefficient), the rest is its cost — no coefficient: complete false and problems say so. Контировки (#15/#16) of a period (?month= / ?from=&to=; ?kind=invoices|payments): { entries: [{ kind: invoice | payment | no_document, date, number, counterparty, lines: [{ account (null = not chosen yet), name, debit, credit, note }], complete, balanced }], chart, counts { all, invoices, waiting } }. A purchase: Дт by lines + Дт 4531 / Кт 401; a sale: Дт 411 / Кт by lines + Кт 4532; a payment: Дт 401 / Кт 503 (501 in cash); without a document: salary 421, social 461, taxes 456, a fee 629 against 503.. accountProblems (#295): the accounts of the entries that are not in the chart or are a group — the entries with them are not complete |
POST /api/v1/invoices/:id/entry/confirm | запис | Confirm the entry of an invoice (#283): 409 while a line has no account; → the invoice with entryConfirmed { by, at }. A changed account later clears it. |
POST /api/v1/entries/suggestions/apply | запис | The suggested account and tax credit of the purchase lines of a period applied by a person (#602): { month | from, to, invoiceIds? } — only where a line has none yet. → { lines, invoices } |
GET /api/v1/line-rules | преглед | The rules for invoice lines (#602): [{ id, name, eik | supplier, contains, account, credit, basis, mode: auto | suggest | off, by, at, waiting }] — waiting: the lines of saved documents it fits that have no account yet (POST /line-rules/:id/apply) |
POST /api/v1/line-rules | запис | Since #628 a rule may also give an analytic (analytic: an id of GET /analytics). Since #15 stage 3 GET /line-rules gives each rule its origin (person | agent) and stats { applied, changed, failing, recentChanged } — failing when a person changed 2 of its last 5 lines; a failing rule in "auto" goes down to "suggest" by itself (steppedDown { at, from }). A rule for invoice lines (#602): a supplier (eik or name) and, optionally, a word of the line → an account and / or a tax credit (full | partial | none) with its basis; mode suggest by default, auto applies it by itself when a document is saved |
PATCH /api/v1/line-rules/:id | запис | Change a rule for invoice lines (#602): any of its fields, the mode too |
DELETE /api/v1/line-rules/:id | запис | Delete a rule for invoice lines (#602) |
GET /api/v1/line-rules/:id/applied | преглед | The lines a rule put on its account (#602), as they would change with it: { lines, invoices } not confirmed, confirmed (entries confirmed), closed (handed-over months — never changed); ?name= the name it had (lines before the rule id was kept) |
POST /api/v1/line-rules/:id/reapply | запис | The rule changed (#602): the lines it put there take its account and credit now — not the ones a person changed since, never a handed-over month, confirmed entries only with includeConfirmed (they are to be confirmed again). → { lines, invoices } |
POST /api/v1/line-rules/:id/move | запис | Move a rule for lines up or down (#602): of two equally specific rules that fit a line (both with a word of the same length, or both for all lines), the higher wins; a rule with a word always wins over one without. → the rules |
POST /api/v1/line-rules/:id/apply | запис | Apply a rule for invoice lines to the documents saved before it (#602): only the lines it fits that have no account yet (a person's choice stays) get its account, and its credit when the document has VAT; who: the rule. → { lines, invoices }. GET /line-rules gives each rule its waiting lines |
PUT /api/v1/invoices/:id/accounts | запис | #668: also { taxKinds: [representative | social | none | null per line] } or { taxKind } for an invoice without lines, alone — the tax on expenses a person says (null: by the line basis). #628: also { analytics: [analytic id | null per line] } or { analytic } for an invoice without lines — the analytic of the line (one of GET /analytics, active). #602: also { credits: [full | partial | none | null per line] } or { credit } for an invoice without lines — the tax credit; without lines / all only the credit changes. The account of each line of an invoice (#15): { lines: [code | null per line] } or { all: code } — leaf accounts of the chart of accounts (400 for an unknown code; 400 for a group, naming its sub-accounts, #294; 409 without a chart). An accounting decision, not an edit of the document: allowed for a digital invoice too. |
POST /api/v1/documents/check | запис | qrTotal (#666): the QR total of a receipt — a different total is an error on total, the lines only when they do not give it; A document without a file (#249): what is missing or wrong — { ok, errors: [{ field, message }] }, nothing saved. Body as POST /documents. Paid by card (payment: card, #296): also cardPayments [{ id, date, amount, currency, merchant, description }] — the card payments not yet linked with that amount, from 2 days before its date to 7 after; the form sends the chosen one as transactionId. |
GET /api/v1/transactions/:id/document-draft | запис | "Документ без файл" from a bank movement (#296): the form filled from it — { transactionId, kind: invoice, direction (received for money out, issued for money in), issueDate, total (minor units, without the sign), currency, counterpartyName (empty for a card payment: the terminal text is not the company), counterpartyEik (from an earlier document of that counterparty, else empty), counterpartyIban, payment (card | bank), hint (the payment reason) }. |
POST /api/v1/invoices/:id/attach-document/compare | запис | "Прикачи файл" (#296), step 1: read an uploaded file ({ file, name? } from POST /uploads) for a document typed by hand and compare — { file, values (what the file says), differences: [{ field, label, typed, read }], digital (read from a text layer: its values win), belongsTo, score }. Nothing is changed. 409 when the document already has a file (POST /invoices/:id/replace-document for that). |
POST /api/v1/invoices/:id/attach-document | запис | "Прикачи файл" (#296), step 2: { file, use?: { <field>: file | typed } } — the file becomes the document; for each difference the file's value (the default) or what was typed. The values taken are kept in attached { file, at, by, took: [{ field, from, to }] }; a typed value kept against the file is a correction by hand (the rating says so). The result must pass the checks (422 { errors }); a digital file is not overruled (409). The rating moves from "на ръка, без документ" to the file's. |
POST /api/v1/documents | запис | A document without a file (#249), described by hand: { kind: invoice | credit_note | debit_note | receipt | cash_out (РКО) | cash_in (ПКО) | z_report (#250: the daily report of a fiscal device — device, base20, vat20, base9, vat9, base0, cash, card; the groups = total, cash + card = total; the cash part goes to the cash desk) | sis (#250: a СИС — person, personId (10 digits, kept masked), gross, tax, insurance; total = paid) | protocol_117 (#250: протокол по чл. 117 ЗДДС — relatesToInvoice a received invoice we have, VAT 20 / 9 %, saved as a received document with documentType protocol_117, never paid), foreign? (#250: a foreign counterparty — no EIK, its VAT number of another country, any number, 0 % without a reason), advance? (an advance invoice), direction (issued | received, invoice kinds), number (10 digits for invoice kinds), issueDate, counterpartyName, counterpartyEik (valid), counterpartyVatNumber? (= BG + EIK), net, vatRate (20 | 9 | 0), vat, total, currency, relatesToInvoice (notes: an invoice we have), vatExemptReason (at 0 %), person + reason (orders), payment? (bank | cash | card) } — amounts in minor units. Validated like every document; a failing check → 422 { errors }. Invoice kinds go to the invoices (byHand, documentType; paid in cash → a cash movement); a receipt and the orders go to the cash book; a receipt paid by card or by the bank goes to the invoices (documentType receipt, the invoice-only checks skipped) so it can be linked with its payment. transactionId (#296): typed for that bank movement — linked to it (a match made by the person, undoable) when the movement is open, the direction and currency agree and the amounts fit exactly; otherwise only offered. → 201 { kind, invoice?, cash?, link?: { status: linked | offered, transactionId, match? , reason? } } |
GET /api/v1/counterparties | преглед | The counterparties remembered (#472): one card each — name, EIK, VAT number, address, country, bank accounts, the usual VAT rate and payment, the differences documents brought; with the number of documents and the balance (#487): { [currency]: { theyOwe, weOwe } } — what is left unpaid of the issued and of the received documents (a credit note lowers it; a protocol by art. 117, a receipt, a Z report and a СИС do not count) |
GET /api/v1/counterparties/:id/documents | преглед | The documents of a counterparty card (#483), the newest first — what the count in Контрагенти opens: each with its kind, direction, number, date, total, paid and status; 404 for an unknown card |
POST /api/v1/counterparties | запис | A counterparty typed by hand (#472) |
PUT /api/v1/counterparties/:id | запис | A counterparty edited by hand (#472): the person's values win, the differences it had are cleared |
DELETE /api/v1/counterparties/:id | запис | A counterparty card deleted (#472); its documents stay |
POST /api/v1/download/documents | преглед | Download documents (#637): { ids (at most 2000, as a list shows them or ticked), with: data | file } → a ZIP: the digital part — one xlsx with three sheets (documents, lines, entries) and the same three as CSV (";", decimal comma) — and with "file" the originals in a folder (and a text file listing the documents without one). Only what the person may see; 404 when none |
GET /api/v1/invoices/:id/protocol-117 | преглед | Протокол по чл. 117 (#514) of a received foreign invoice without VAT: { needed, protocol: { id, number, issueDate, vat, hasFile } | null, draft (filled from the invoice: the next number of the company's series, the date, the base in EUR — none for another currency, needsRate —, 20 %, the VAT, what was supplied, the basis), bases }; 400 for an invoice that needs none |
GET /api/v1/protocols-117/:month | преглед | The protocols by art. 117 of a month and the open months after it, as they are and as they would be made again in one series (#599): { month, months, closed, blocked, rows: [{ invoice, protocol | null, action: create | renumber | refresh | kept | needsRate, number, issueDate }] } — ordered by the date of the invoice, dated with it, numbered after the last protocol before the month; attached ready protocols keep their number (skipped); blocked when one of the months is handed over |
POST /api/v1/protocols-117/:month/regenerate | запис | Make the protocols of GET /protocols-117/:month again in one operation (#599): new ones created, the others get their number and date in place and a new PDF (the one before stays in replacedFiles). → { create, renumber, refresh, kept, needsRate, errors, operationId, summary }; 409 when a month is handed over |
POST /api/v1/invoices/:id/protocol-117/read | запис | A ready protocol (someone else's PDF, uploaded with POST /uploads) read by AI (#514): { values: { number, issueDate, net, vatRate, vat } | null, draft, kind } — to fill the form |
POST /api/v1/invoices/:id/protocol-117 | запис | The protocol (#514): { number, issueDate, net, vatRate (20 | 9), vat, description?, basis?, file? } — checked like a document by hand (POST /documents, kind protocol_117), linked to the invoice; with file the attached ready protocol is its file, without it the protocol is made here as a PDF (A4, Cyrillic): the recipient (the company) top left, the supplier top right, the lines of the invoice as on it — quantity, unit, unit price, amount in its currency (#595). → 201 { protocol, made }; 409 when the invoice has one |
Асистентът
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/assistant/conversations | преглед | The person's own conversations with the assistant in this company (#298), newest first: [{ id, title, createdAt, updatedAt, turns }] |
GET /api/v1/assistant/conversations/:id | преглед | One conversation (#298, one's own; 404 for another's): { id, title, turns: [{ q, a, at, model, costUsd, tools }] } |
POST /api/v1/assistant/conversations/:id/proposals/:pid/:action | преглед | A write the assistant proposed (#299): confirm runs each action through its own route with the person's rights, in one operation (kind chat), undoable from Операции; dismiss drops it. 409 when no longer pending |
DELETE /api/v1/assistant/conversations/:id | преглед | Delete one's own conversation (#298) |
POST /api/v1/assistant/ask | преглед | Assistant (#217): a question in the person's words (Bulgarian), answered from the company's data. Read-only tools (month summary, movements with their proposals, invoices) call this API with the person's own rights. Body: question, optional month (YYYY-MM), view (where the person is), model (haiku, sonnet, opus — the owner only, for one question; otherwise the company's model, #300), history (up to 6 earlier {q, a}). Returns answer, model, tools (for the system owner also usage (tokens) and costUsd, #711) and, when the person asked to see something, navigate ({ view, tab?, month?, label }) — the screen the app opens; warning from 80 % of the monthly limit (questions) or of the system owner's cap. Each question adds to the company's counter (#300). 503 without a Claude key; 429 over the monthly limit in questions or the cap (source: limit), until the next month or a higher limit. Since #298: conversationId goes on with a kept conversation (the earlier turns are sent with the data their tools read, trimmed — the last 3 with data, up to 8 as text); without it a new one is started; the answer carries conversationId. ?stream=true answers one JSON per line: { type: tool, name } · { type: text, delta } · { type: done, …the answer } · { type: error, error } |
Документи
| Заявка | Право | Описание |
|---|---|---|
POST /api/v1/invoices/:id/payment-method | запис | How a document is paid (#409): { paymentMethod: bank_transfer|cash|card|null } — set on the document (read only otherwise), recorded in paymentMethodLog { from, to, by, at }; cash: not suggested for bank movements |
POST /api/v1/invoices/:id/accounting-month | запис | The accounting month of a document (#392): { month: "YYYY-MM" | null } — by default the month of its date; another month is recorded in accountingMonthLog (from, to, by, at); null puts it back. The period lists (?month), the month closing and the VAT follow it (month) |
GET /api/v1/documents | преглед | Every kind of document of the period (#402): invoices, credit / debit notes, protocols (чл. 117), Z reports and the cash receipts saved into the cash book (id receipt:<inboxId>, receiptId, cashId); filter by month or from/to, direction received/issued, kind (invoice|credit_note|debit_note|protocol_117|receipt|z_report), problems=true; returns { documents, counts (per kind, only those there are), total } |
GET /api/v1/invoices | преглед | Invoices with payment status and checks (reading.score (#243): { kind: invoice|receipt, value 0–127 (the sum of the passed checks, powers of two — unique per combination), max, level: green|orange|red|manual, checks: [{ code, weight, label, ok: true|false|null (nothing to compare), text }] }; edited by hand → value 227, level manual, manual { by, at }, readValue; thresholds in settings.readingScore { green, red }; the same score is in fields.reading.score of a read inbox document; filter by month or from/to, status, deleted, direction received/issued; withoutFile=true — only documents typed by hand, without a file (Документи → Без файл, #406); problems=true — only those that need a look: a failing check (error or warning) or a reading we are not sure of, #224); each with a document says how sure its reading is: reading { confidence, reasons, derived, missing } (#152); without a document: reading { confidence: null, manual: true } |
POST /api/v1/invoices | запис | Add an invoice (manually or from extracted fields); vehicles (#676): the plates printed on the document; with seller/buyer from the reading it is refused (422 not_our_company) unless confirmNotOurs. Takes foreign, counterpartyCountry (ISO 2 letters), counterpartyAddress and paymentMethod (bank_transfer|cash|card — cash: not suggested for bank movements) (#404). Refused (422, errors) when a check of the document itself fails (#399: sums, EIK, number / date / counterparty / total, a future date, the company not a party — also with confirmNotOurs —, VAT when not registered). With a file (#390) it needs its lines, giving the base (or the total when they include VAT) → else 422 "Не става документ: редовете …". With inboxId (#379): saved from the document window of За преглед — the file is the item's own (Drive, Gmail, returned for review), the item becomes saved with the invoice (404 unknown item, 409 no longer waiting) acceptAnyway { reason, errors? } (#507): saved although a check of the document fails, at the person's own risk — stored as acceptedAnyway { by, at, reason, errors } |
POST /api/v1/invoices/:id/personal-payment | запис | "Платена от лична сметка" (#120): a person from settings.people paid the invoice (person, date, amount, how it will be paid back: bank, cash, offset, waived); the invoice is paid, the company owes the person |
DELETE /api/v1/invoices/:id/personal-payment | запис | Remove the invoice's personal payments, while nothing was paid back |
GET /api/v1/people | преглед | The people who may pay company invoices from their own account (settings.people: name, IBAN) |
GET /api/v1/personal | преглед | "За възстановяване" (#120): per person — invoices paid from their account, how they were paid back (bank, cash, offset, waived), what is still owed |
PATCH /api/v1/personal/:id | запис | Change how a personal payment will be paid back |
POST /api/v1/personal/:id/settle | запис | Pay back by an offset, or not at all (waived), with a note |
GET /api/v1/invoices/:id/reading | преглед | How the invoice was read (#152): confident or not with the reasons, each field with its value, how sure, why, what is usual for the counterparty and where on the document (page and box; exact from a digital PDF's text layer, approximate from a scan); an invoice read before this was kept, or entered by hand with a file, gets one worked out from its saved values (derived: true; places only in a digital PDF); 404 without a document |
GET /api/v1/invoices/:id/payments | преглед | How the invoice was paid (#117): each payment (numbered n, with remainingAfter, #118) with its bank line and statement, the other invoices the movement pays, who and when, how (suggestion with score and reasons, rule, by hand, in bulk) and its operation; cash with who and when; undone matches (by whom, when, with which run) and where the payment went |
GET /api/v1/invoices/:id | преглед | pageCount (#240): the photos of a document put together (GET /invoices/:id/document?page=N each); lineSuggestions (#602): per line { index, account, credit, basis, source: { account, credit }, why, auto, note } — rules, history, the law (art. 70). With lines [{ description, quantity, unit, unitPrice, amount, vatRate, account, credit, creditBasis }] as read (#13) and reading.score with its checks. One invoice with its payments, history and possible duplicates. For the document window (#370): suggestedPayments — the open bank movements the rules suggest for it (and, #466, those past the matching window in any month — same counterparty or its number and the amount — with late: true and month: YYYY-MM), the same suggestion as in Свързване ({ transaction, amount, score, reasons, note, rule, afterThis }, the surest first; [] once paid), and entry — its Контировка as in GET /entries (lines with account names, complete, balanced, confirmed; null for a private invoice) |
PATCH /api/v1/invoices/:id | запис | Files first, then documents (#390): a document that came from a file is read only → 409 (it is corrected by POST /invoices/:id/back-to-review, fixed as a file and accepted again); undo / revert of an earlier change stay. A document typed by hand (no file) is corrected here; the change is marked manual with a reason |
DELETE /api/v1/invoices/:id | запис | Delete an invoice permanently (only an archived one) |
GET /api/v1/invoices/:id/document | преглед | The original document of an invoice (inline or ?download=1) |
POST /api/v1/invoices/:id/back-to-review | запис | "Върни за преглед" (#185): the invoice is removed and its document waits in За преглед again ("върната за преглед"), to be corrected and saved or rejected; one entered by hand gets a document made from it. An operation — undoing it brings the invoice back. Not for an invoice with a matched payment. Body (optional): { note } — why, kept on the step and the decision (#187). Answers { operationId, item } |
POST /api/v1/invoices/:id/archive | запис | Archive (soft-delete) an invoice with a reason |
POST /api/v1/invoices/:id/restore | запис | Restore an archived invoice |
POST /api/v1/invoices/:id/replace-document | запис | Replace the document of an invoice with a newly uploaded file |
POST /api/v1/invoices/:id/cash-payment | запис | "Платена в брой" / "Получено в брой": makes a cash movement in the cash desk for the invoice (whole or an amount, date, receipt) (#121) |
DELETE /api/v1/invoices/:id/cash-payment | запис | Remove the invoice's cash payment (its cash movements in the cash desk) |
POST /api/v1/invoices/:id/confirm-reading | запис | "✓ Потвърди — прочетено вярно" (#544): a person confirms the reading of a saved document (reviewed { by, at }) — it is "✓ потвърдена" instead of "не сме сигурни"; 409 when the document has an error |
POST /api/v1/invoices/:id/not-duplicate | запис | Mark a flagged pair as not duplicates ({ of: the other invoice, note }): the pair is never flagged again; who, when and the note are kept |
GET /api/v1/duplicate-marks | преглед | Pairs of invoices marked as not duplicates (who, when, note) |
DELETE /api/v1/duplicate-marks/:id | запис | "Провери пак": remove a not-duplicates mark, so the pair is compared again |
Операции и отмяна
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/operations | преглед | Runs that created records (agent, upload, form, statement import), newest first, with what each created |
GET /api/v1/operations/:id | преглед | One operation: everything it created (invoices, movements, matches, inbox items) and what would stop undoing it |
POST /api/v1/operations | качване | Start a batch (bulk upload); files sent with x-operation-id join it |
POST /api/v1/operations/:id/finish | качване | Finish a batch with a summary |
GET /api/v1/operations/:id/progress | преглед / качване | State of a running bulk run (polling): total, done, by status, the document now, running / stopped |
GET /api/v1/operations/:id/events | преглед / качване | Server-Sent Events of a running bulk run: progress, one "item" per finished document (its new state), "done" at the end; a ping every 15 s |
POST /api/v1/operations/:id/stop | качване / запис | Stop a running bulk run after the document being read now; what is done stays (one operation, undoable) |
Банка
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/transactions/:id/invoices | преглед | "Друга фактура…" (#118): the open invoices this movement may pay — the counterparty's partly paid ones first (group partly_paid), then the counterparty's, then the rest — with paidSoFar, remaining and suggestedAmount (min of the payment and the rest) |
POST /api/v1/transactions/:id/questions | свързване | "Въпрос" (#144): a question for the accountant on a movement; open ones set the line aside in "ред по ред" and go to the open questions of the month closing |
GET /api/v1/questions | преглед | (The old questions, #144; a new question in "Ред по ред" is a conversation about the movement, POST /threads.) Questions for the accountant (?open=true: not answered yet) |
PATCH /api/v1/questions/:id | свързване / приключване | Answer a question (answer), resolve it (resolved: true — who and when are kept) or change it |
POST /api/v1/download/movements | преглед | Download the movements of a period (#637): { from, to (YYYY-MM), account?, with: data | file } → a ZIP with an xlsx and a CSV of the movements (date, account, amount, counterparty, description, status, the documents they are matched with); with "file" also the statement files they came from — to import elsewhere |
GET /api/v1/transactions | преглед / качване | ?glance=matched|waiting|none (#279): matched (also without a document) · waiting for a confirmation (a candidate found, or partly matched) · none found — the cards of a statement as filters. Bank movements with match status, suggestions (each with invoice { total, paidSoFar, remaining, paymentsSoFar } and afterThis { paid, remaining, status, overpayment }, #118) and problems; every invoice a match pays says its instalment { n, remainingAfter, final } (filter by month or from/to, account, status, noDocumentKind: only the movements with that no-document suggestion; auto=true: only those an auto-approval rule applied; queue=true: "ред по ред" (#144) — open movements without an open question, each with confidence, the most confident first; each movement says how it came in: origin; each match says who made it: by — the person, or "автоматично"; autoBlocked { code, message } (#214) — why a suggestion was not applied by itself: rule_suggests, statement_not_digital, candidates, no_reference, amount, paid_before, duplicate, corrected, not_digital, sums, cash, same_invoice; null when a rule would apply it or nothing is suggested) |
GET /api/v1/accounts | преглед / качване | Bank accounts with bank name, label and the totals of a month or a period (from/to) — count, open; and (#495) statements (how many), coverage { from, to, missing: [months with no statement between the first and the last] }, balance { amount, date, currency } (the last balance the bank gave, null when its files have none) |
GET /api/v1/statements | преглед | Imported bank statements as documents |
GET /api/v1/statements/document | преглед | The original statement file (?file=…; inline or ?download=1) |
GET /api/v1/statements/table | преглед | Rows of a CSV/Excel statement (?file=…) |
POST /api/v1/statements/upload | импорт | Upload a statement (UniCredit or Fibank XML / CSV / Excel / PDF as the request body); returns the detected columns, or the movements read from XML/PDF |
POST /api/v1/statements/ai-mapping | импорт | Unknown table layout: the AI (cheap model, first 30 rows only) says which column is what; the table is then read by code and the mapping is remembered on import |
POST /api/v1/statements/ai-read | импорт | Unknown format: the AI reads the whole file (cheap model first, strong one when balances do not match); returns the preview like a PDF statement |
POST /api/v1/statements/preview | импорт | Preview of an XML/PDF statement before import: summary (errors, confidence, doubts), totals per currency, all rows with flags |
POST /api/v1/statements/import | импорт | Import a CSV/Excel statement with the confirmed column mapping |
POST /api/v1/statements/import-extracted | импорт | Import movements read from an XML or PDF statement; reversals are marked as needing no document |
Съобщения
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/threads | преглед / качване | Threads the person may see (with "view": all; otherwise only their own): ?status=open|closed|all (default open), ?about=transaction:<id> | invoice:<id> | month:YYYY-MM, ?mine=true. Each with its last message and the person's unread count; totals { unread, open, closed } |
POST /api/v1/threads | преглед / качване | New thread with its first message: title (a general thread) and/or about { type: general|transaction|invoice|month, id }; participants by to (e-mails of the company's people) and roles (default: owners and accountants), plus @mentions in the text. The others are told (event message_new: the bell and e-mail with the thread link and a reply-to address) |
GET /api/v1/threads/:id | преглед / качване | One thread: its messages (who, when, text, via app|email), the people with their roles, the person's unread count |
POST /api/v1/threads/:id/messages | преглед / качване | Write in a thread: the author and the @mentioned join it; a closed thread opens again; the others are told |
PATCH /api/v1/threads/:id | преглед / качване | Close / reopen (status: closed|open — who and when are kept), rename (title), add people (add: e-mails) |
POST /api/v1/threads/:id/read | преглед / качване | Mark the thread read up to now for the person |
Каса
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/cash | преглед | The cash desk (#121) for a period (?month= or ?from=&to=): opening and closing balance, movements with a running balance (a cash payment from before the cash desk as legacy), warnings (below zero) |
GET /api/v1/owed | преглед | "Лично" (#220): what each person owes the company — [{ person, outstanding, debts: [{ matchId, transactionId, date, amount, description, counterparty, note, settlements: [{ how: salary|bank|cash|offset, amount, date, month?, id? }], settled, outstanding }] }]. A movement is marked with POST /matches { kind: personal, person, note? } |
POST /api/v1/download/cash | преглед | Download the cash book of a period (#637): { from, to, with: data | file } → a ZIP with an xlsx and a CSV (date, kind, person, note, income, expense, documents); with "file" the receipts attached |
POST /api/v1/owed/settle | свързване | Paying back "Лично" (#220), the oldest first: { person, how: salary (month?) | bank (transactionId: an incoming, unmatched movement — matched as a repayment) | cash (a cash movement in, kind repayment) | offset (against what the company owes the person, #120), amount? (default all), date?, note? } |
DELETE /api/v1/owed/:matchId/settlements/:id | свързване | Undo a paying back from a salary or by an offset (#220); a bank or cash one is undone by undoing its match / cash movement |
POST /api/v1/cash/count | запис | The count of the cash desk (#142): { date, counted, book? } → { computed (the book on that date), difference, booked }; book: true records the count (GET /cash counts) and books a difference as a movement "разлика при преброяване" |
GET /api/v1/advances | преглед | Advances to account for and business trips (#142, #361): { advances: [{ id, person, purpose, date, trip?: { orderNumber, destination, from, to, perDiem, days }, status: open|settled, documents: [{ invoiceId, amount, number, counterpartyName }], movements, account: { given, documents, perDiem, days, spent, returned, paidBack, balance (> 0 the person holds it, < 0 owed to them), owes } }], people: [{ person, balance }] }; ?open=true, ?person= |
POST /api/v1/advances | запис | A new advance or business trip: { person, purpose (a trip: by its destination), date, amount? (given in cash now — out of the cash desk), trip?: { orderNumber, destination, from, to, perDiem (a day), days? } } |
PATCH /api/v1/advances/:id | запис | Change an advance's purpose or its trip |
POST /api/v1/advances/:id/give | запис | More cash given: { amount, date, note? } |
POST /api/v1/advances/:id/documents | запис | A received document paid with the advance: { invoiceId, amount? (default what is open) } — the invoice is paid by that much |
DELETE /api/v1/advances/:id/documents/:invoiceId | запис | Take a document off the advance |
POST /api/v1/advances/:id/settle | запис | Settle: { date } — what the person still holds comes back to the cash desk (return), or what they spent over is paid to them (reimbursement); the advance is closed |
POST /api/v1/advances/:id/reopen | запис | Open a settled advance again (its settling movement is taken back) |
POST /api/v1/cash | запис | A cash movement: date, direction (in / out), amount, kind (invoice, advance, reimbursement, return, salary, other), person / counterparty, note, receipt (the cash receipt file), allocations to invoices (in pays issued, out pays received; not more than is left); answers with warnings (below zero, over the legal limit); the receipt is optional |
PATCH /api/v1/cash/:id | запис | Change a cash movement (e.g. attach its cash receipt); one to / from the bank changes through its bank match |
DELETE /api/v1/cash/:id | запис | Delete a cash movement (legacy-<invoiceId>: the cash flag from before the cash desk); one to / from the bank is undone through its bank match |
GET /api/v1/cash/:id/receipt | преглед | The cash receipt (касов бон) of a cash movement |
POST /api/v1/cash/:id/back-to-review | запис | A cash receipt back to review, as an invoice (POST /invoices/:id/back-to-review): its cash expense goes, the receipt waits among the files to review; an operation, undone like any. Body: { note? } → { operationId, item } |
Контировки
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/line-signs | преглед | The signs of a line (#669): the ready ones (with the company changes) and its own — [{ id, name, words [stems; a trailing space: a whole word], supplier, effect (credit | account | question | warning), credit, basis, account, text, when (empty | coefficient | cars | asset), mode (suggest | off), ready, edited, by, at, hits (purchase lines that have its words) }] |
POST /api/v1/line-signs | запис | An own sign of a line (#669): { name, words, effect, ... } — it needs what its effect says (a credit, an account of the chart, a text) |
PATCH /api/v1/line-signs/:id | запис | A sign changed (#669): a ready one keeps its id, the change is the company own; mode suggest | off — a sign never saves by itself |
DELETE /api/v1/line-signs/:id | запис | An own sign removed, or a ready one back as it came (#669): { ok, ready } |
GET /api/v1/expense-tax/:year | преглед | The tax on expenses for the representative and the social expenses of a year (#629, #668): { year, rate (of the year, settings.expenseTax.rates; 0.1 by default), months: [{ month, base, tax, socialBase, socialTax, documents: [{ invoiceId, number, date, counterparty, kind (representative | social), base, tax, confirmed }] }], total { base, tax, socialBase, socialTax } } — the base is their cost as booked (the VAT without credit in it); a line is representative when its credit basis is art. 70(1)(2) of the VAT Act |
GET /api/v1/line-rules/proposals | преглед | Rules proposed from repetitions (#15, stage 3): a person chose the same account for a supplier's lines 3 times or more and no rule covers them — [{ id, name, eik, supplier, contains, account, credit, count, examples }] |
POST /api/v1/line-rules/proposals/accept | запис | Accept a proposed rule (#15): { id } → 201 the rule, in "suggest" mode, origin "agent" (right "save") |
POST /api/v1/line-rules/proposals/reject | запис | Reject a proposed rule (#15): { id } — not proposed again (right "save") |
GET /api/v1/line-rules/measure | преглед | The measure (#15): of a period's purchase lines with an account — by { rule, history, ai (the model's suggestion accepted), person } and how many a person changed after a rule, the history or the model |
POST /api/v1/invoices/:id/accounts/ai | запис | Ask the model for the lines of an invoice that rules and history do not decide (#634): an account of the chart per line with confidence and why, kept on the line as a suggestion (never saved by itself); { lines } — how many got one. 409 without an AI key or a chart |
DELETE /api/v1/invoices/:id/accounts/ai | запис | Drop the model's suggestions of an invoice (#650, the drop-AI button): from its lines that have no account yet → { lines } — how many |
POST /api/v1/entries/suggestions/ai | запис | The same for the invoices of a period (#634): { month | from, to, invoiceIds? (only these — the ones a tab shows, #650) } → { lines, invoices }; a line already asked is not asked again (at most 100 invoices a call) |
GET /api/v1/accounting-policy | преглед | The company's accounting policy (#634, #15): { text, by, at } — principles in words with examples, read by the model every time |
PUT /api/v1/accounting-policy | запис | Set the accounting policy (#634): { text } (right "save") |
POST /api/v1/download/entries | преглед | Download the entries of a period (#637): { from, to, kind?: invoices | payments } → a ZIP with an xlsx and a CSV of debit–credit pairs (confirmed or not — the state is a column) |
GET /api/v1/analytics | преглед | The company's analytics (#628) — a car, a site, a project: { id, name, active, lines (how many lines have it) } |
POST /api/v1/analytics | запис | A new analytic (#628): { name } (unique, case aside) → 201 { id, name, active } (right "save") |
PATCH /api/v1/analytics/:id | запис | Rename an analytic or make it (in)active (#628): { name?, active? }; an inactive one stays on the lines that have it but is not offered or suggested (right "save") |
DELETE /api/v1/analytics/:id | запис | Remove an analytic (#628) — only when no line and no rule has it (409 says how many); else make it inactive (right "save") |
GET /api/v1/analytics/report | преглед | Costs and income by analytic (#628) for ?from=YYYY-MM&to=YYYY-MM: per analytic the entry amounts of its lines (a cost with the VAT not credited) and its documents { invoiceId, number, date, direction, counterparty, amount, currency } |
Свързване
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/hints | преглед | Hints: rules "movement text contains … → supplier", with how many movements they fit and how often they led to a confirmed match |
POST /api/v1/hints | свързване | Add a hint (owner); offered after a confirmed card match, or written by hand |
PATCH /api/v1/hints/:id | свързване | Change a hint: text, supplier, card payments only, on/off (owner) |
DELETE /api/v1/hints/:id | свързване | Delete a hint (owner); confirmed matches stay |
GET /api/v1/differences | преглед | Differences between payments and their invoices (#252), newest first: { differences: [{ matchId, index, amount (> 0 the invoice got less, < 0 the payment had more), reason, label, note?, by, at, how: { source: manual|proposed }, document?: { needed, kind, from, status: waiting|linked|no_file, invoiceId?, record? }, paid, transaction, invoice }], totals: [{ reason, label, count, amount }], waitingDocuments } — a waiting difference may carry proposals: credit notes in the register that fit it [{ invoiceId, number, issueDate, total, sure }]; ?reason=, ?waiting=true (only those waiting for a document) |
POST /api/v1/differences/document | свързване / запис | Upload the document behind a difference (#252 stage 2): the file as the body (PDF / JPG / PNG / WebP). Read with Haiku (the strong model again only when the reading fits no difference waiting for a document), kept in documents/differences/ → { file, reading: { kind: offset|complaint|penalty|late_interest|credit_note|advance_invoice|withholding_tax|other, kindLabel, title, number, date, parties, invoices: [{ number, date, amount }], total, currency, model }, escalated, costUsd, candidates: [{ matchId, index, score, sure, fits, misfits, note?, label, amount, invoice, transaction }] }. Nothing is linked: confirm with PUT /matches/:id/allocations/:index/document { file, kind, number, date, reading } |
GET /api/v1/differences/document | преглед | An uploaded document behind a difference (#252): ?file=differences/… |
GET /api/v1/differences/reasons | преглед | The reasons for a difference (#252): { less: [...], more: [...] } — each { id, label, side, hint, document?: { kind, from }, needsNote? } |
POST /api/v1/matches/:id/file | свързване / запис | The document of a payment without an invoice (#512) — an insurance policy, a tax notice: the file (PDF or an image) as the body, its name in x-file-name; kept with the match as file { path, name, by, at }. 400 for a match with invoices |
GET /api/v1/matches/:id/file | преглед | The document of a payment without an invoice (#512), inline; 404 when none |
DELETE /api/v1/matches/:id/file | свързване / запис | Takes the document off a payment without an invoice (#512) |
PUT /api/v1/matches/:id/allocations/:index/document | свързване / запис | The document behind a difference (#252): { invoiceId } links a document in the register (a credit note…); { file, kind, number, date, reading? } links an uploaded one (POST /differences/document); { kind, number, date } records it by hand without a file; null / {} puts it back to waiting |
POST /api/v1/matches | свързване | (#473: several allocations in one link — each document once, at most what is left of it, 400 otherwise.) (kind personal, #220: "Лично" — { transactionId, kind: personal, person, note? }: a payment out that was the person's own; they owe it, GET /owed.) Link a movement to invoices (with amounts; an allocation may carry difference: { amount, reason, note? } — the payment differs from the invoice for a reason and the invoice is closed, #252), mark it as needing no document (salary, social security, tax, fee, contract, transfer, cash, other), or a reimbursement to a person (kind reimbursement, personal: which personal payments it pays back; default the oldest first, #120) |
POST /api/v1/matches/transfer | свързване | Confirm a transfer between own accounts: both movements together (otherId), or one side while the other is not imported yet; undoing one side undoes both |
GET /api/v1/matches/no-document | преглед | The no-document suggestions of a period (?month= or ?from=&to=, ?account=, ?kind=): { total, byKind } — what POST would confirm |
POST /api/v1/matches/no-document | свързване | Confirm the no-document suggestions of a period, all or one ?kind= (salary, social, tax, fee, contract, transfer, other) — the server picks the movements; one operation, undoable |
POST /api/v1/matches/auto | свързване | "▶ Пусни правилата": run the rules in automatic mode now — for a period (?month= or ?from=&to=) or, without one, for every month; only digital documents not corrected by hand, only when everything fits — one operation, undoable; also runs by itself (every month) after a statement import and after invoices are saved |
GET /api/v1/matches/auto | преглед | What the rules in automatic mode would apply now (#301): { period: { from, to, count, byRule: [{ ruleId, name, count }] } | null, all: { count, byRule } } — the chosen period (?month= or ?from=&to=) and every month; ?rule= counts one rule as if it were automatic (404 when there is no such rule). Nothing is applied. |
GET /api/v1/match-rules | преглед | The rules for bank statements (#128, #114), in their order: the system ones and the company's own — name, kind (invoice, hint, fee, tax, social, salary, transfer, contract, other), mode (auto, suggest, off), recognize (words, except, ibans, ownAccounts), conditions (account, direction, maxAmount, counterparty, text, reference), search (the invoice rule), hits |
POST /api/v1/match-rules/try | преглед | "Бърза проверка": which rule would take a movement with this description / counterparty / account / amount → { kind, reason, rule } |
GET /api/v1/match-rules/:id/matches | преглед | What the rule would apply now (?month= or ?from=&to=), as if it were on |
POST /api/v1/match-rules/:id/apply | свързване | "Приложи": apply this rule alone now — for a period (?month= or ?from=&to=) or, without one, for every month; one operation, undoable |
POST /api/v1/matches/suggested | свързване | "Потвърди всички" (#203): every movement of the period (?month= or ?from=&to=; ?account= only that account's, #495) with a suggestion gets it — a suggested invoice (the best one, as much as both allow) or a suggested kind without one (salary, tax, fee…); ?only=invoice,salary,… takes just those groups. One operation that can be undone; answers { created, skipped, operationId } |
POST /api/v1/matches/bulk | свързване | Mark many movements at once as needing no document (salary, social security, tax, fee, contract, transfer, other) — one operation, undoable |
DELETE /api/v1/matches/:id | свързване | Undo a match |
Приключване на месеца
| Заявка | Право | Описание |
|---|---|---|
GET /api/v1/vat/ledgers/:month | преглед | The VAT ledgers of a month (#293, stage 1): { month, currency: EUR, sales: [{ seq, docType (01 / 02 / 03 / 09), number, date, counterpartyId, counterpartyName, goods, art163a, amounts: { key: minor units }, notes }], purchases: [...], totals: { sales, purchases }, problems: [{ invoiceId, number, message }], columns: { lead, sales, purchases }, nap: { ready, missing, submitter } } — each column with its form number and file field (ППЗДДС Приложения № 10–12); docs/vat-ledgers.md |
GET /api/v1/vat/ledgers/:month/nap | преглед | The files for НАП (#293, stage 2): a ZIP of DEKLAR.TXT, PRODAGBI.TXT, POKUPKI.TXT by ППЗДДС Приложение № 12 (fixed width, windows-1251, CR LF; amounts in euro). 409 without the company VAT number or company.vatSubmitter; header x-ledger-problems: the documents the ledgers could not place (not in the files) |
GET /api/v1/vat/ledgers/:month/xlsx | преглед | The VAT ledgers of a month as Excel (#293): sheets Продажби, Покупки (and Да се провери) |
GET /api/v1/package/:month | приключване | With entries { all, waiting, confirmed } (#287). Month closing for the accountant: contents and open questions |
GET /api/v1/package/:month/zip | приключване | Also Контировки.csv and the sheet Контировки of Опис.xlsx: the entries as debit–credit pairs (#287). The documents of the month as a ZIP: folders + inventory spreadsheet |
Версия на приложението: 0.6.11.