# Seismisk invoice tool API

Base address: https://seismisk.com/invoice/api/v1
Every call carries the header  Authorization: Bearer sk_inv_...  The key is made in Settings (https://seismisk.com/invoice/manage?tab=settings); it is shown once.
Bodies and answers are JSON. Money is in euros as a number (100 or 100.5), without VAT; VAT is added on top by vat_rate.
A mistake answers with {"error": {"code", "message", "fields"}} and status 400, 401, 404, 409 or 429. Limits: 120 calls a minute, 30 invoices an hour, 10 new invoice types a day.

## Account
GET /me  ->  seller details and the next invoice and advance invoice numbers.

## Settings (numbering, documents, links)
GET /settings
PATCH /settings            any of:
  numbering        {"pattern": "ZD-YYYY-NNNN", "next_number": 42, "reset": "month" | "year" | "never", "advance_pattern": "A-YYYY-NNN", "advance_next_number": 1}
                   Pattern = free text plus NN.. (the running number; the count of N's is the padding), DD, MM, YYYY, YY.
                   A yearly reset needs the year in the pattern, a monthly one the month and the year. A number that was already issued is refused.
  document_title   "rekins" | "pavadzime"   (title of Latvian invoices)
  clients_may_correct   true | false   (the client may correct their own details by the link in their e-mail, until the end of the month)
  privacy_url, terms_url   the seller's own https links, shown on forms with consent: true
  sender_name      the name e-mails are sent under
The seller's own details (company name, registration and VAT numbers, address, e-mail, logo, password) are set by the person in Settings, not by the API.

## Invoice types (the forms your clients fill in)
GET /types                 list
GET /types/{id}            one
POST /types                create. Fields:
  lines            [{"description": "Consultation, 1 hour", "price": 100}]   (required)
  vat_rate         21 | 12 | 5 | any number | null for none                    (default 21)
  eu_reverse_charge   true (default) | false. A business client from another EU country whose VAT number the EU register VIES confirms
                   at the moment of issue gets the document with VAT 0 and the reverse-charge note. A number of the seller's own country,
                   a number that is not found, or a register that does not answer: the VAT stays. Works when the seller has a VAT number.
  discount_percent a discount in % that every client gets, shown as a line with a minus
  discount_codes   [{"code": "RUDENS", "percent": 20, "pay_url": "https://buy.stripe.com/...", "pay_url_no_vat": "..."}]
                   A client who enters a code on the form gets that code's discount (instead of discount_percent). Any number up to 20.
  language         "lv" | "en"                                                  (default "lv")
  mode             "advance" (advance invoice first, default) | "simple" (invoice right away)
  due_days         days after the invoice date, 0 = same day
  next             "stripe" | "link" | "thanks"
  stripe_url       a stripe.com payment link (needed with next "stripe")
  pay_url_no_vat   the pay link for an EU business without VAT. One payment link has one price, so each other amount needs its own link:
                   this one, and pay_url / pay_url_no_vat inside each discount code. With a Stripe link they are required, with your
                   own link optional. The links themselves are made in the seller's Stripe account; this API only stores them.
  link_url         your own https link (with next "link"; empty = the client stays on the page)
  thanks_text, thanks_url, thanks_seconds   (with next "thanks")
  consent, phone, news   true | false: ticks and the phone field on the form
  button           the text on the button
  suffix           own number suffix of this type
PATCH /types/{id}          change any of the same fields
POST /types/{id}/pause     {"paused": true | false}
GET /types/{id}/codes      the five ways to put the form on a site: link, button, popup, iframe, html
POST /types/{id}/test      e-mails a test to the seller: marked TEST, no number used; in advance mode both documents
Each type has form_url: the link your client opens.

## Clients
GET /clients, GET /clients/{id}
POST /clients   {"email" (required), "name", "address", "business": true, "company", "reg", "vat", "legal_address", "phone"}

## Invoices
GET /invoices?kind=advance|invoice|credit&status=awaiting|sent|paid|cancelled|converted&month=2026-11&client_id=&type_id=
GET /invoices/{id}         one; pdf_url opens the PDF without a key
GET /invoices/{id}/pdf     the PDF
POST /invoices             issue one document for one client and e-mail it to them (you get a copy):
  client_id  or  client: {...as in POST /clients}
  lines, vat_rate, language, due_days, eu_reverse_charge, discount_percent       as above
             An invoice issued without VAT carries reverse_charge: {vat, checked, consultation, name} (the register's answer).
  kind       "advance" (default) | "invoice"
  pay_url    optional https link for the Pay button in the e-mail
  send       false = issue without e-mailing
POST /invoices/{id}/paid        an advance invoice that awaits payment: issues the tax invoice with the next number and e-mails it. Answers {advance, invoice}
POST /invoices/{id}/mark-paid   a sent invoice: marks it paid
POST /invoices/{id}/cancel      a sent or paid invoice: issues a credit note with the next number and e-mails it. Answers {invoice, credit_note}
POST /invoices/{id}/remove      an advance invoice that will not be paid: hides it
PATCH /invoices/{id}/client     change the client details in place (same number and date) until the end of the month of issue; the amended PDF is e-mailed

## Example
curl -X POST https://seismisk.com/invoice/api/v1/invoices -H "Authorization: Bearer sk_inv_..." -H "Content-Type: application/json" \
  -d '{"client": {"email": "janis@example.com", "business": true, "company": "SIA Paraugs", "reg": "40000000000"}, "lines": [{"description": "Konsultācija, 1 stunda", "price": 100}], "vat_rate": 21, "kind": "invoice", "language": "lv"}'
