API reference

API overview

How the FIZ API works before you send the first request: authentication with an API key or OAuth, the sandbox, drafts and issuing, series and PDF templates, safe retries with Idempotency-Key, and errors.

Authentication

API-key access requires an API key in the x-api-key header. Each key belongs to one account/NIF and issues only for that account. Create your key at app.fiz.co/settings/integrations.

Building an integration for customers? Follow the partner app guide for a working example, OAuth, signup, permissions and retries. Registered apps can also use Authorization: Bearer <access_token> with resource https://api.fiz.co. Create an app at Settings → Integrations and request explicit company consent. Never send a bearer and an API key together. A token for /mcp is not valid for REST.

OAuth supports invoices, customers and items (invoicing.read, invoicing.write, invoicing.issue), plus GET /company and GET /series (company.read). GET /exports/saft-pt requires the independent, explicitly requested saft_pt.export scope. Other routes require an API key. Registered apps read their own records; invoicing.read_all additionally permits company-wide reads, without permission to modify other records. Customer cards are separate for each app, even for the same tax number.

Before issuing, check GET /company for readiness reasons and send the draft’s updatedAt as expectedUpdatedAt in the issue body. A changed draft is rejected. Readiness is a preliminary check, not a guarantee for a particular document. OAuth grants share a 300-request/minute budget across API replicas; a 429 carries Retry-After.

Sandbox

Rehearse the whole flow (series, issuing, receipts, credit notes, PDFs) with no fiscal effect. On the API page in Settings → Integrations the owner of the company creates a sandbox, a test copy of the company on the AT test environment, and its test keys, which start with fiz_test_.

  • Same base URL and requests: the key alone decides where a request goes. GET /company answers "environment": "sandbox".
  • Documents are reported to the AT test environment only and never appear in e-Fatura. PDFs carry "DOCUMENTO DE TESTE — SEM VALIDADE FISCAL" and certification number 9999; series names get a random suffix.
  • Only the company profile and its AT connection are copied: create customers and items yourself. The company must be connected to the AT.
  • Not available with a test key: bank endpoints, MCP and OAuth apps, email, payment links, issuing transport and working documents. Recurring schedules are stored but never run.
  • A reset (at most 3 per 24 hours; deleting and creating again counts) wipes the sandbox and changes every id and key.

Issuing flow

Invoices are first created as a draft (POST /invoices) and are only reported to the Portuguese tax authority (AT) at the moment of issuance (POST /invoices/{id}/issue). You can validate all the data — and even generate the PDF — before issuing. Drafts never reach the AT; to rehearse issuing itself, use the sandbox (above).

Series and PDF templates

  • Series — list the account’s series at GET /series and pass the relevant id in the seriesId field when creating an invoice to issue it in a specific series. If omitted, the default series is used.
  • PDF templates — list templates at GET /templates and pass the relevant id in GET /invoices/{id}/pdf?templateId=... to generate the PDF with that template. To install a template in another company or the sandbox, export it with GET /templates/{id} and import it with POST /templates. A template a partner application installs is its own: only it sees the template, and it prints only the documents that application issued. How to build, check and install templates: the PDF template guide; how they are made: the template reference.

Recurring invoices

A schedule is an invoice template that FIZ issues — and reports to AT — on its own, at the frequency you set (POST /invoices/scheduled: MONTHLY on day 1, WEEKLY on Monday, …). Manage it from your system: PATCH /invoices/scheduled/{id} changes the frequency, dates or auto-send, or pauses and resumes it (status); DELETE ends it. Every document a schedule issues carries its id as scheduleTemplateId, so GET /invoices?scheduleTemplateId=... lists exactly what went out — that is how to reconcile. Requires a plan with recurring invoices.

Idempotency

Every write endpoint accepts an optional Idempotency-Key (a UUID, say), recommended for safe retries. Retrying a request with the same key returns the original response instead of executing it again — so a timeout or a dropped connection never costs you a duplicate invoice. Send a new key for a new request. Keys are scoped to your API key (or to the app, authorizing user and company for registered REST clients) and are remembered for 30 days.

  • A replayed response carries Idempotent-Replayed: true and repeats the original status code.
  • Reusing a key with a different request body is rejected with 422.
  • 409 means the first attempt is still running (retry with the same key, honouring Retry-After) or that its outcome is unknown — check whether it took effect, then retry with a new key.

A request we rejected before sending it on (a 400 from validation) leaves the key free to reuse. Any other failure — including one the invoicing backend reports — may already have taken effect, so the key is spent: check the result, then use a new key. Correcting a rejected payload is a new request, so give it a new key.

Writes without the header execute without replay protection. If a response is lost, check the result before repeating an unkeyed request.

Errors

Every error answers with a 4xx or 5xx status and one JSON shape: statusCode, message and, when the invoicing system refused the request, a code. Branch on the status and on code; the message is for people and its wording may change. When request validation fails, message is a list with one line per field.

Every response carries an X-Request-Id header. Quote it when you contact support about a request.

Specification

OpenAPI is available at /-json and /-yaml, ideal for generating a REST client. Official libraries: TypeScript (npm install @fiz-co/sdk), Python (pip install fiz-sdk) and PHP (composer require fiz-co/sdk); see Libraries. For AI coding agents: /llms.txt indexes Markdown editions of these docs.

What changed and when: the API changelog, dated, newest first, with an Atom feed to follow it.

For Claude and ChatGPT (MCP connector)

FIZ is also an MCP server: connect it once and your assistant reads your documents, drafts invoices and — only after you confirm each one — issues them.

Server URL: https://api.fiz.co/mcp

  • Claude (web, desktop, mobile) — Settings → Connectors → Add custom connector, paste the URL, then sign in to FIZ and choose the company and permissions.
  • ChatGPT — Settings → Apps & Connectors → Create, paste the URL, sign in to FIZ.
  • Claude Code — claude mcp add --transport http fiz https://api.fiz.co/mcp, then /mcp → Authenticate.

No API key is involved: access is an OAuth connection you can revoke at any time in app.fiz.co/settings/integrations. Details, permissions and the list of tools: api.fiz.co/docs/mcp.

Prefer a coding agent with shell access? The open-source skill FIZ-co/fiz-invoicing-skill (MIT) drives this REST API instead.