Step 3 of 5
Invoices
Create invoices with POST /invoice, see where the fields print, validate the sums, use reservations and store only the returned id.
Create an invoice
You create an invoice with one call to the Invoice Tools API. Waya validates it in real time and answers 201 with the created invoice, or with an error code that tells you what to correct. Every call needs an authorization token, so authenticate first.
Do not wrap the request in data
The request body is the invoice itself. Only the response is wrapped in data.
This minimal request invoices a mocked test individual for four hours of consultation. Waya looks the debtor up by national identifier and uses their registered address. The lookup operation (opens in a new tab) in Swagger lists the test identifiers.
curl --request POST \
--url 'https://api.sandbox.waya.se/v4/rest/invoice' \
--header 'Authorization: Bearer <authorization-token>' \
--header 'Content-Type: application/json' \
--data '{
"externalNumber": "INV-1001",
"debtor": {
"nationalIdentifier": {
"number": "194107102222",
"countryCode": "SE"
}
},
"rows": [
{
"text": "Consultation services",
"unit": "h",
"unitPrice": 800.00,
"quantity": 4,
"vatPercentage": 25.0,
"priceExcludingVat": true
}
]
}'
Change externalNumber each time you run it, because it must be unique. The identifier is a mocked individual that exists in non-production environments only, so use a real debtor in production. A successful call answers 201, and Response lists the fields to know first. You can also find the new invoice in Insight (opens in a new tab).
Swagger describes every field of the request: the debtor, the rows and the optional fields (opens in a new tab), and the delivery methods (opens in a new tab).
Address lookup
Use the lookup operation to check an identifier, or to show the registered address, before you invoice.
/legal-entity/{country-code}/{national-identification-number}Lookup address given a national identifier in Swagger (opens in a new tab)curl --request GET \
--url 'https://api.sandbox.waya.se/v4/rest/legal-entity/SE/194107102222' \
--header 'Authorization: Bearer <authorization-token>'
In non-production environments, only mocked individuals and a few real organizations can be looked up. The lookup operation (opens in a new tab) in Swagger lists them.
Your own invoice PDF
Normally Waya produces the invoice PDF. The exception is a client that uses Waya's reminder or collection services without the invoice service. You then create the invoice with sendAs set to REMINDER or DEBT_COLLECTION. Waya did not produce the original invoice, so you supply its PDF. Waya makes the PDF available to the debtor online, and prints it on the back of reminders and collection letters. You can send the PDF in attachments when you create the invoice, as Swagger (opens in a new tab) describes.
After the invoice is created
You can also set the PDF afterwards. The body is the PDF file itself, not JSON:
curl --request PUT \
--url 'https://api.sandbox.waya.se/v4/rest/invoice/<invoice-id>/pdf' \
--header 'Authorization: Bearer <authorization-token>' \
--header 'Content-Type: application/octet-stream' \
--data-binary '@invoice.pdf'
After sending shows how to retrieve an invoice PDF.
Where fields print
Invoices that Waya sends follow one template. The drawing shows its layout with placeholder text. The logo, the issuer, the payment details and the footer come from the client's settings, not from the request.
Avs. Företaget AB, Gatan 1, SE-123 45 Staden
FAKTURA
Datum
2026-11-04
Fakturanummer
1234567890
Sida
1 / 1
Utställare
Företaget AB
Gatan 1
123 45 Staden
000000-0000
Kunden AB
Box 123
123 45 Staden
Sverige
Kundnummer
10234
Er referens
Referens A
Vår referens
Referens B
Ert ordernr
1001
Vårt ordernr
5001
Leveransvillkor
Villkor
Märkning
Märkning
Person-/org.nr
000000-0000
Telefon
000-000 00 00
Lös allt snabbt och smidigt online på Mina sidor.
| Artikelnr | Vara/tjänst | Antal | Enhet | À pris | Summa |
|---|---|---|---|---|---|
| Beskrivning av utfört arbete. | |||||
| A-100 | Tjänst | 2,00 | st | 400,00 SEK | 800,00 SEK |
| A-200 | Produkt | 1,00 | st | 200,00 SEK | 200,00 SEK |
Fri text till mottagaren.
Text om fakturaadministrationen, påminnelseavgift och dröjsmålsränta.
Postadress
Företaget AB
Gatan 1
123 45 Staden
Kontaktinformation
faktura@exempel.se
000-000 00 00
Org.nr
000000-0000
Godkänd för F-skatt
Betalningsmottagare
Mottagaren
Bankgiro 123-4567
Uppgifter för automatisk avläsning
#1234567890 #1250 000 >1234567#41#
| Marker | API field | Printed as |
|---|---|---|
| 1 | debtor.name and debtor.billingAddress | Recipient's name and address. Without an address, the registered address of debtor.nationalIdentifier is used |
| 2 | debtor.externalNumber | Kundnummer |
| 2 | yourReference | Er referens |
| 2 | ourReference | Vår referens |
| 2 | yourOrderNumber | Ert ordernr |
| 2 | ourOrderNumber | Vårt ordernr |
| 2 | termsOfDelivery | Leveransvillkor |
| 2 | reference | Märkning, recommended for general comments |
| 2 | debtor.vatNumber | Momsreg.nr |
| 2 | debtor.nationalIdentifier | Person-/org.nr, when there is no VAT number |
| 2 | debtor.phone | Telefon |
| 3 | articleNumber, text, quantity, unit and unitPrice of each row | Artikelnr, Vara/tjänst, Antal, Enhet and À pris |
| 4 | comment | Free text at the bottom left of the totals box |
Marker 2 is the reference grid. It prints only the fields you send, so a field that you leave out leaves no gap. The template applies a limit of 50 characters to each printed reference field, so keep the debtor's customer number (Kundnummer), your references, order numbers, terms of delivery and marking within it. yourReferenceId, ourReferenceId and project are not printed.
A row with only a text prints as a line of text, like the first row in the drawing. invoiceDate prints as Datum and dueDate as Förfallodag. Waya sets the invoice number and the OCR number.
For Peppol and other e-invoices, use edi.yourReference and edi.yourOrderNumber.
Validate the sums
Send your own totals in sumValidation, and Waya compares them with its own calculation from the data in the request. It catches rounding differences between your system and Waya before an invoice goes out. You can validate the whole invoice, each row, or both.
The allowed difference is set for each client. Swagger (opens in a new tab) describes the totals that you can send.
Response
A successful call answers 201 with the invoice, wrapped in data. These are the fields to know first:
| Field | Description |
|---|---|
id | The invoice's ID in Waya. It is the master reference |
_link | A link to the invoice. The format is unconfirmed: Swagger's only link examples are host-relative paths such as /v4/rest/…. Fetching by id with Get an invoice (GET /invoice/{id}) always works |
_paymentDetailsLink | A link to the invoice's payment details, in the same unconfirmed format. Fetch them with Get payment details and the invoice id |
ocr | Waya's invoice and payment reference |
Store only the id. It is the only value your system needs to keep, and you can fetch everything else when you need it, as After sending describes. Keep the entity type with the ID if you store IDs of several types, as Entity IDs (opens in a new tab) in Swagger explains.
Reservations
A reservation lets you create an invoice and hold it back. Create it with "reservation": true. Waya creates it, but does not send it until you finalize it. Until then you can replace or delete it:
Replace is a full replacement, so send "reservation": true again to keep the invoice held back. Swagger describes finalizing as setting reservation to false, so a Replace body with reservation set to false or left out finalizes the invoice and sends it.
/invoice/{id}/finalizeFinalize a reserved invoice in Swagger (opens in a new tab)curl --request PUT \
--url 'https://api.sandbox.waya.se/v4/rest/invoice/<invoice-id>/finalize' \
--header 'Authorization: Bearer <authorization-token>'
If a request fails, Errors explains how to read the error code.