Skip to content
Hydda One API
Esc
↑↓navigate↵open⌘Jpreview
On this page

Billing

Deliver an organization's approved invoices through your ERP or invoicing platform, and report the outcomes back, up to 200 in one request.

The billing API is for an invoicing integration: the system that connects an organization to its ERP or invoicing platform. Hydda One builds the invoices, and an operator approves them. Your integration handles each approved invoice. It delivers the invoice, collects payment, and books it in the organization’s own system.

Your integration does all the calling. Hydda One never calls it. The integration reads work from queues, up to 200 items at a time, and reports the outcome of a whole page in one request.

New to the objects on this page? Invoicing objects explains contracts, proposals, invoices and payments, and how they connect.

Get started

This walk-through sends one invoice from start to finish in the development environment. It takes four calls. Your integration must already exist and be ready: Build your own integration covers that, and how to get the access token used below.

The two reports go to batch routes. A batch takes up to 200 items, so a production integration reports a whole page of the queue in one request. Here each batch holds one item.

Get an invoice onto the queue

The send queue is empty until an operator has sent an invoice. In the admin console at admin.dev.hydda.one, an operator does two things under Invoicing:

  1. On Invoice basis, choose Create invoice on a contract that has something to invoice. The invoice is now Ready to send.
  2. On Invoices, choose Send on it. The invoice now shows Sending.

Sending in the admin console is approved in the API: the operator has handed the invoice over, and it waits for your integration. It is on the send queue once its invoice date is today or earlier.

This assumes your integration does not have Invoice review switched on. With it on, Create invoice makes a proposal first, which your integration passes before the operator can send it. See The flow.

Read the send queue

curl "https://api.dev.hydda.one/v1/billing/send-queue?limit=200" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Each item is one invoice with its lines, its VAT subtotals and its recipient. This one is shortened:

{
  "items": [
    {
      "invoice": {
        "id": "3f1c2a9e-7b64-4d0f-9a1e-5c8d7e6f4b21",
        "businessContextId": "9b7a2d10-3c44-4e0a-8f6e-1d2c3b4a5f6e",
        "contractId": "b2d4f6a8-0c1e-4a3b-8d5f-7e9a1c3b5d7f",
        "documentKind": "invoice",
        "status": "approved",
        "invoiceNumber": 42,
        "requestedInvoiceDate": "2026-11-16",
        "requestedDueDate": "2026-12-16",
        "currency": "SEK",
        "totalNetMinorUnits": 1000000,
        "totalVatMinorUnits": 250000,
        "totalGrossMinorUnits": 1250000
      },
      "lines": [
        {
          "position": 1,
          "label": "Office 301, December 2026",
          "quantity": "1",
          "unitPriceMinorUnits": 1000000,
          "amountMinorUnits": 1000000,
          "vatRateBasisPoints": 2500,
          "periodStart": "2026-12-01",
          "periodEnd": "2026-12-31"
        }
      ],
      "vatSubtotals": [
        { "vatRateBasisPoints": 2500, "netMinorUnits": 1000000, "vatMinorUnits": 250000 }
      ],
      "recipient": {
        "agentName": "Acme AB",
        "agentType": "company",
        "identifiers": [{ "scheme": "se-orgnr", "value": "5560000001" }],
        "invoiceAddress": { "street": "Storgatan 1", "postalCode": "111 22", "city": "Stockholm", "country": "SE" },
        "deliveryMethod": "email",
        "billingEmail": "invoices@acme.example"
      }
    }
  ]
}

An empty items list means no invoice is waiting. A 400 with BILLING_INTEGRATION_NOT_CONFIGURED means your integration is not ready yet.

Issue the invoices, then report them sent

Create each invoice in your ERP, in the account that belongs to the item’s businessContextId. Then tell Hydda One what your ERP issued, with one item for each invoice:

curl -X POST https://api.dev.hydda.one/v1/billing/batch/report-sent \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {
        "invoiceId": "3f1c2a9e-7b64-4d0f-9a1e-5c8d7e6f4b21",
        "externalReference": "erp-invoice-88213",
        "issuedInvoiceNumber": "2026-000317",
        "issuedInvoiceDate": "2026-11-16",
        "dueDate": "2026-12-16",
        "issuedTotalGrossMinorUnits": 1250000
      }
    ]
  }'

The answer is 200 with one result for each item, in the order you sent them. This one is shortened:

{
  "results": [
    { "status": 200, "result": { "id": "3f1c2a9e-7b64-4d0f-9a1e-5c8d7e6f4b21", "status": "sent" } }
  ]
}

A result with status 200 was taken, and its result is the invoice, now sent. The admin console shows it as Sent, and the invoice has left the send queue. Any other status means that item was refused. See One result per item.

If your ERP refuses an invoice, report it on POST /v1/billing/batch/report-failed with a reason instead. The operator sees it as Delivery failed, with your reason.

Report the payments

When customers pay, report each payment under your payment platform’s own id for it. An item names its invoice by invoiceId, or by the externalReference you gave it:

curl -X POST https://api.dev.hydda.one/v1/billing/batch/report-payments \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {
        "externalReference": "erp-invoice-88213",
        "platformPaymentId": "bank-tx-2026-11-30-0042",
        "amountMinorUnits": 1250000,
        "paymentDate": "2026-11-30"
      }
    ]
  }'

The answer has the same shape. This payment covers the issued total, so the invoice in its result is now paid, and Paid in the admin console.

That is the whole happy path. The rest of this page covers what a production integration also needs: full queues, reviewing proposals, credit notes, deleted invoices and safe retries.

To generate a client, use the OpenAPI document.

When a call times out

A batch can succeed even though you never saw its answer. Send the same batch again, and read each result. Most reports answer a repeated item as they answered the first. Two kinds refuse it, and that refusal means the first call arrived:

Report A repeated item answers
Sent, payments, payment reversals, write-offs 200 with the unchanged invoice.
Discarded 204.
Failed 400 with BILLING_INVOICE_STATUS_INVALID. The first call arrived.
Pass, reject 400 with BILLING_PROPOSAL_STATUS_INVALID. The first call arrived.

What the token needs

The caller is the organization’s invoicing integration. An organization has one at a time. Three things must be in place:

  1. A token. An integration of your own uses the client_credentials grant. A connector from Hydda uses the installation-token grant. See Authentication.
  2. The Billing Integration role at the organization. For an integration of your own, an administrator assigns it to the integration’s application. For a connector from Hydda, Hydda One grants it when an administrator saves the connector’s settings. See Roles.
  3. A ready configuration. The queues stay closed until the integration reports its organization configuration ready. Until then, the queues and reports answer BILLING_INTEGRATION_NOT_CONFIGURED. See the Integrations API for how to report it.

Build your own integration walks through all three.

A token without the role answers 403.

Capabilities

An invoicing integration states which parts of the invoicing it handles. These parts are its capabilities. For an integration of your own, an administrator switches them on when creating it.

Capability Name in the admin console Required What the integration does
sending Sending Yes Delivers each approved invoice, then reports it sent or failed. Reports payments and write-offs. Discards deleted invoices.
basisVerification Invoice review No Checks each proposed invoice before it becomes an invoice, then passes or rejects it.

A route for a capability the integration does not have answers BILLING_INTEGRATION_GATE_NOT_DECLARED. It never answers an empty queue instead.

The flow

Each call is described in the billing reference.

  1. Verify the proposals. Only with the basisVerification capability. Poll GET /v1/billing/verification-queue. Rule on each proposal: send the ones you accept to batch/pass-proposals, each with your externalReference, and the others to batch/reject-proposals, each with a reason. A pass answers with the proposal and the invoice it became. The invoice carries your reference. It reaches the send queue once an operator approves it.
  2. Send the invoices. Poll GET /v1/billing/send-queue. It lists approved invoices whose requested invoice date has come, oldest approval first. “Today” is the current calendar day in UTC. Issue each invoice in your ERP. Then send the issued ones to batch/report-sent, and the ones your ERP refused to batch/report-failed, each with a reason.
  3. Report payments. Send the payments your platform receives to batch/report-payments, a whole bank file at a time. Send the payments that were taken back to batch/report-payments-reversed. An item names its invoice by invoiceId or by your own externalReference.
  4. Report write-offs. Send the amounts your platform gives up collecting to batch/report-write-offs. An item names its invoice by invoiceId only.
  5. Discard deleted invoices. Poll GET /v1/billing/withdrawal-queue. It lists invoices an operator deleted after you attached your reference to them. Discard your copy of each, then send them to batch/report-discarded.
  6. Report credit notes your platform issued. When your platform credits an invoice Hydda One sent, send the credit note to batch/report-credit-notes, or one at a time to POST /v1/billing/invoices/{invoiceId}/report-credit-note. See Credit notes your platform issued.

Credit notes your platform issued

A credit note you issue in your own platform, against an invoice Hydda One sent, is reported with report-credit-note. Hydda One records it as a credit note that is already issued. It never appears on the send queue, so do not report it sent.

The body carries your own externalReference for the credit note, its issuedInvoiceNumber, issuedInvoiceDate and issuedTotalGrossMinorUnits, which is negative, and an optional documentUrl. It says what was credited in exactly one of two shapes:

  • lines: the credited invoice’s lines, by the id the send queue gave each line, with the net amount credited on each.
  • vatRates: the net amount credited at each VAT rate the invoice carries, with a vatTreatment at a zero rate. Use this when your platform does not credit named lines.

Amounts in both shapes are net and positive. A line can be credited up to what is left of it, and the invoice up to what is left of its net, counting every credit note against it.

The credit is applied to the invoice in the same call, up to what is still open on it. The answer carries both documents and appliedMinorUnits:

  • The invoice’s balance drops by the applied amount. An invoice it brings to zero is paid.
  • What the invoice could not take stays open on the credit note. Settle it with a refund, a negative payment on the credit note, or a negative write-off.
  • Do not report the credit used as a payment on the invoice it credits. The application already did that.

To name the invoice by your own reference, use POST /v1/billing/invoices/by-external-reference/{externalReference}/report-credit-note. A batch item names it by invoiceId or invoiceExternalReference.

Report in batches

Every report has a batch route under /v1/billing/batch. A batch takes 1 to 200 items, and a queue read returns up to 200 items, so one read leads to one report call.

Report Batch route An item names
Pass proposals POST /v1/billing/batch/pass-proposals proposalId
Reject proposals POST /v1/billing/batch/reject-proposals proposalId
Invoices sent POST /v1/billing/batch/report-sent invoiceId
Invoices failed POST /v1/billing/batch/report-failed invoiceId
Payments POST /v1/billing/batch/report-payments invoiceId or externalReference
Payments taken back POST /v1/billing/batch/report-payments-reversed invoiceId or externalReference
Write-offs POST /v1/billing/batch/report-write-offs invoiceId
Deleted invoices discarded POST /v1/billing/batch/report-discarded invoiceId

The body is { "items": [...] }. An item names its proposal or invoice and carries what you report about it. A payment or payment-reversal item names its invoice by exactly one of invoiceId and externalReference.

curl -X POST https://api.dev.hydda.one/v1/billing/batch/report-sent \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {
        "invoiceId": "3f1c2a9e-7b64-4d0f-9a1e-5c8d7e6f4b21",
        "externalReference": "erp-invoice-88213",
        "issuedInvoiceNumber": "2026-000317",
        "issuedInvoiceDate": "2026-11-16",
        "dueDate": "2026-12-16",
        "issuedTotalGrossMinorUnits": 1250000
      },
      {
        "invoiceId": "7a9e1c3b-5d7f-4b2d-8f6a-0c1e4a3b8d5f",
        "externalReference": "erp-invoice-88214",
        "issuedInvoiceNumber": "2026-000318",
        "issuedInvoiceDate": "2026-11-16",
        "dueDate": "2026-12-16",
        "issuedTotalGrossMinorUnits": 980000
      }
    ]
  }'

One result per item

Items are handled in the order you sent them, each on its own. One refused item changes nothing for the others.

The request answers 200 with one result per item, in the same order:

{
  "results": [
    { "status": 200, "result": { "id": "3f1c2a9e-7b64-4d0f-9a1e-5c8d7e6f4b21", "status": "sent" } },
    {
      "status": 404,
      "problem": {
        "type": "about:blank",
        "title": "Not Found",
        "status": 404,
        "detail": "invoice 7a9e1c3b-5d7f-4b2d-8f6a-0c1e4a3b8d5f not found"
      }
    }
  ]
}
Result Meaning What to do
status 200 with result The item was taken. result is the invoice, the proposal, or for a pass the proposal and its invoice. Nothing.
status 204 A discard was taken. It has no result. Nothing.
status 400, 403, 404 or 409 with problem The item was refused, and changed nothing. problem is a problem details body, with a code when the refusal has one. Act on the code. See Errors to handle.
status 500 with problem An unexpected error. The item changed nothing. Send it again later.

So a 200 on the request does not mean every item was taken. Read each result. Results carry no id of their own: match a result to its item by position.

What refuses the whole batch

These are refused before any item is handled, so nothing has changed:

Answer When
401, 403 The token is missing, not valid, or lacks the role.
400 with BILLING_INTEGRATION_NOT_CONFIGURED or BILLING_INTEGRATION_GATE_NOT_DECLARED The integration is not ready, or lacks the capability.
400 with VALIDATION_FAILED The body does not match its schema. This includes no items and more than 200 items.
413 The body is over 1 MB.
429 with BILLING_BATCH_THROTTLED The batch was not taken. Wait the seconds in the Retry-After header, then send the same batch again.

The pass, reject, sent, failed and discarded batches refuse a body that names the same proposal or invoice twice. The payment, reversal and write-off batches accept one invoice several times, because one bank file can hold two payments on one invoice. Each item then needs its own platformPaymentId or platformWriteOffId.

Empty a queue

A queue has no cursor. A read returns its oldest items, and an item leaves the queue only when a report takes it. So you empty a queue in a loop:

  1. Read a page with limit=200.
  2. Do the work for each item in your ERP.
  3. Report the page. For the send queue that is one batch/report-sent with the invoices you issued, and one batch/report-failed with the ones your ERP refused.
  4. Read each result, and note the items that were refused.
  5. Read the queue again. Stop when it is empty, or when it holds only items you already tried in this run.

The second half of step 5 matters. A refused item can still be on the queue, and a loop that stops only on an empty queue then never ends.

Report an invoice you cannot issue as failed. An item nobody reports on stays at the front of its queue, and 200 of them hide everything behind them.

One item at a time

Each batch route also has a single form, which names one proposal or invoice in its path and takes the rest of the item as its body. It does the same work under the same rules. Use it for a one-off report, such as a correction made by hand. Do not loop over it to report a page.

Batch route Single route
batch/pass-proposals POST /v1/billing/invoice-proposals/{proposalId}/pass
batch/reject-proposals POST /v1/billing/invoice-proposals/{proposalId}/reject
batch/report-sent POST /v1/billing/invoices/{invoiceId}/report-sent
batch/report-failed POST /v1/billing/invoices/{invoiceId}/report-failed
batch/report-payments POST /v1/billing/invoices/{invoiceId}/report-payment
batch/report-payments-reversed POST /v1/billing/invoices/{invoiceId}/report-payment-reversed
batch/report-write-offs POST /v1/billing/invoices/{invoiceId}/report-write-off
batch/report-discarded POST /v1/billing/invoice-withdrawals/{invoiceId}/report-discarded

The two payment routes also exist under /v1/billing/invoices/by-external-reference/{externalReference}/, addressed by your own reference.

A single route answers 201 with what a batch puts in result, or 204 for a discard. A refusal is the response itself: the status and problem details that a batch puts in the item’s result.

What the queues and reports carry

What a sent report carries

A sent report brings back what your ERP issued. Your ERP decides the legal invoice, so Hydda One records what it issued.

Field Required What it is
externalReference Yes Your own id for the invoice, 1 to 200 characters.
issuedInvoiceNumber Yes The legal invoice number your ERP gave it. Hydda One’s own invoiceNumber is internal.
issuedInvoiceDate Yes The date the invoice was issued.
dueDate Yes The date payment is due. Hydda One judges an invoice overdue against it.
issuedTotalGrossMinorUnits Yes The total including VAT that your ERP issued. Every payment is measured against it.
paymentReference, paymentReferenceType No The reference the payer quotes, such as an OCR number. Send both or neither.
documentUrl No An https link where the issued document can be fetched.

If the invoice came from a proposal you passed, it already carries your reference. externalReference must then match it.

A batch item carries these fields and invoiceId.

Which company an invoice belongs to

One integration serves the whole organization. The organization can run several companies, each with its own ERP account.

Every queue item names businessContextId. It is the business context that owns the invoice’s contract. Issue the invoice in the ERP account of that business context.

  • An integration of your own keeps the mapping from business context to ERP account in its own system. Read the business contexts from GET /v1/operational-contexts.
  • A connector from Hydda uses the credentials of its configuration at that business context. When the business context has no configuration, it uses the organization’s.

businessContextId is null when Hydda One does not know the business context. Do not guess a company. Report the invoice failed instead.

Do not route by the item’s operationalContextId. It is the context the invoice was created in, which can differ.

What an item carries

An item carries the invoice or proposal, its lines in position order, and its VAT subtotals. The recipient block holds the customer’s name, type, identifiers, invoice address and delivery method. Every field is frozen when the document is written, so two reads of one item always agree.

Issue the invoice with requestedInvoiceDate and requestedDueDate as they stand. Do not compute other dates.

A credit note rides the same queues. Its documentKind is credit-note, and creditedInvoiceId names the invoice it credits. Its totals are negative, and it is settled with a negative payment.

An identifier with the scheme se-personnummer or se-samordningsnummer is personal data. Keep it out of your logs.

Statuses

An invoice moves through these statuses on this API:

status In the admin console Meaning
approved Sending An operator sent it. It is on the send queue from its requested invoice date.
sent Sent You reported it sent. A payment reversal can also return it here.
failed Delivery failed You reported it failed. An operator corrects the material and builds the invoice again.
paid Paid Its payments reached or passed the issued total.
written-off Written off It is settled, and part of it was written off.

An operator approves an invoice with Send in the admin console. To the operator the invoice is then on its way, which is why the console calls an approved invoice Sending.

The balance is the issued total, less every payment that was not reversed and every write-off. The invoice becomes paid when the balance reaches zero or goes past it. An overpayment is accepted. If any write-off counted, it becomes written-off instead. A partial payment or write-off leaves it sent.

A proposal is proposed until you pass or reject it. It never expires. Only an operator can cancel it.

Rules for callers

A queue is not consumed by reading it

Reading a queue claims nothing. An item stays on its queue until a report changes its status. If your integration crashes, poll again and you get the same items.

Work can therefore arrive twice. Your integration may reach your ERP and fail before it reports. It then gets the item again. Check your own reference before you issue a document a second time.

An item you cannot act on leaves the queue only when you report it failed. Nothing else clears it.

What a repeated report does

These rules hold for an item of a batch and for a single route alike. A refusal is the item’s result in a batch.

Report Sent again
Sent Changes nothing and answers the unchanged invoice, when the reference and the issued facts match. This also holds once the invoice is paid or written-off.
Failed 400 with BILLING_INVOICE_STATUS_INVALID. The invoice is no longer approved, for example because your first report landed.
Pass, reject 400 with BILLING_PROPOSAL_STATUS_INVALID. The proposal is no longer proposed.
Payment Changes nothing and answers the unchanged invoice, when the amount and date match.
Payment taken back Changes nothing and answers the unchanged invoice.
Write-off Changes nothing and answers the unchanged invoice, when the amount and date match.
Credit note Changes nothing and answers the credit note and the invoice as they are, when the invoice and the body match.
Discarded Answers 204 and changes nothing.

platformPaymentId and platformWriteOffId are your payment platform’s own ids, 1 to 200 characters. They make the payment and write-off reports safe to repeat.

A repeated sent report must say what the first one said. The same externalReference with another issued number, date, due date, total, payment reference or document link answers 409 with BILLING_SENT_REPLAY_MISMATCH. Another externalReference answers 409 with BILLING_EXTERNAL_REFERENCE_ALREADY_USED. An invoice that was never approved, or that you reported failed, answers 400 with BILLING_INVOICE_STATUS_INVALID.

Sending a whole batch again is therefore safe.

Amounts

A payment or write-off amount is never zero. Its sign must match the sign of the issued total. A refund on a credit note is a negative payment.

Hydda One accepts payments on a sent, paid or written-off invoice. A write-off cannot be undone, and there is no route for it.

Limits

What Limit
limit on every queue 1 to 200. Defaults to 50.
reason on a rejected proposal and a failed invoice 1 to 1000 characters.
Items in a batch 1 to 200.
A request body 1 MB.
Requests under /v1/billing 300 a minute from each IP address.

The queues have no cursor. You empty a queue by reporting on its items. A request over the rate limit gets 429 without a code. A batch refused with BILLING_BATCH_THROTTLED also gets 429, with a Retry-After header.

Errors to handle

These refuse a whole request, batch or single:

Code Status When
BILLING_INTEGRATION_NOT_CONFIGURED 400 The organization has no ready invoicing integration.
BILLING_INTEGRATION_GATE_NOT_DECLARED 400 Your integration does not have the capability this route needs.
VALIDATION_FAILED 400 A body, query or path parameter does not match its schema.
BILLING_BATCH_THROTTLED 429 The batch was not taken. Wait the Retry-After seconds and send the same batch again.

These refuse one proposal or invoice. In a batch they arrive in that item’s result, inside a 200 response. On a single route they are the response:

Code Status When
BILLING_INVOICE_STATUS_INVALID 400 The invoice is not in a status this report accepts.
BILLING_PROPOSAL_STATUS_INVALID 400 The proposal is no longer proposed.
BILLING_PROPOSAL_MATERIAL_ALREADY_INVOICED 409 Another invoice already bills this proposal’s material. Do not retry. An operator cancels the proposal.
BILLING_EXTERNAL_REFERENCE_ALREADY_USED 409 The invoice already carries a different externalReference, or another document holds the credit note’s externalReference.
BILLING_SENT_REPLAY_MISMATCH 409 The invoice was already reported sent under this externalReference, with other issued facts.
BILLING_PAYMENT_REPLAY_MISMATCH 409 The same platformPaymentId came with a different amount or date.
BILLING_PAYMENT_REVERSED 409 The payment was reversed, and cannot be reported again.
BILLING_PAYMENT_NOT_FOUND 404 The invoice has no payment with that platformPaymentId.
BILLING_PAYMENT_AMOUNT_INVALID 400 The amount is zero, or its sign does not match the issued total.
BILLING_WRITE_OFF_REPLAY_MISMATCH 409 The same platformWriteOffId came with a different amount or date.
BILLING_WRITE_OFF_AMOUNT_INVALID 400 The amount is zero, or its sign does not match the issued total.
BILLING_CREDIT_NOTE_INVOICE_NOT_CREDITABLE 400 The credited invoice was never sent, or is itself a credit note.
BILLING_CREDIT_EXCEEDS_LINE 400 The credit takes a line past what is left of it.
BILLING_CREDIT_EXCEEDS_INVOICE 400 The credit takes the invoice past what is left of its net.
BILLING_MANUAL_CREDIT_VAT_RATE_UNKNOWN 400 The invoice has no line at that VAT rate and treatment.
BILLING_CREDIT_WITHHELD 400 The credit cannot be recorded against this invoice. The detail says why.
BILLING_CREDIT_NOTE_REPLAY_MISMATCH 409 This externalReference was already reported for another invoice or with other contents.

A 404 without a code means the invoice or proposal does not exist, or belongs to another organization.

Each operation in the API reference lists the codes it can return. A batch operation lists only the codes that refuse the whole batch.

Was this page helpful?