Step 4 of 5

After sending

Check an invoice after it is sent (status, PDF and payment details), and adjust the debt with credits, direct payments and closures.

Check an invoice

You follow an invoice with its id, the one value you stored when you created it. One operation returns a single invoice, and another finds invoices.

Get an invoice

Fetch an invoice with its id, the value you stored. The response to Create an invoice also has a _link, but its format is unconfirmed (Swagger's only link examples are host-relative paths), so fetch by id, which always works.

Shell
curl --request GET \
  --url 'https://api.sandbox.waya.se/v4/rest/invoice/<invoice-id>' \
  --header 'Authorization: Bearer <authorization-token>'

The currentProcessStep of the answer shows where the invoice stands. Swagger explains its steps under Process status (opens in a new tab).

Find invoices

Shell
curl --request GET \
  --url 'https://api.sandbox.waya.se/v4/rest/invoice?externalNumber=INV-1001' \
  --header 'Authorization: Bearer <authorization-token>'

A hit is only a summary, so use Get an invoice for currentProcessStep and the other amounts.

Poll for updates

If you do not use webhooks, poll Find invoices with updatedSince to learn which invoices have changed. To have Waya push the news to you instead, see Webhooks.

  1. Note the current time in UTC. Call Find invoices with updatedSince set to the time you kept from your previous poll. For the first poll, use the time you want to start from.
  2. Read every page of the answer. Raise pageNumber until you reach pageCount.
  3. For each invoice found, call Get an invoice to read its current state.
  4. Keep the time you noted in step 1 for the next poll.

Note the time before the first request, so that an invoice that changes while you read the pages is found by the next poll. Take a minute off the time you keep, to allow for a difference between your clock and Waya's. Reading the same invoice twice does no harm.

Shell
curl --request GET \
  --url 'https://api.sandbox.waya.se/v4/rest/invoice?updatedSince=2026-11-02T08:00:00Z' \
  --header 'Authorization: Bearer <authorization-token>'

A Z at the end of the timestamp needs no encoding. If you write the time zone as an offset such as +01:00, encode the plus sign as %2B, because a plus sign in a query string means a space.

Retrieve the invoice PDF

GETRetrieve invoice PDF/invoice/{id}/pdfRetrieve invoice PDF in Swagger (opens in a new tab)
Shell
curl --request GET \
  --url 'https://api.sandbox.waya.se/v4/rest/invoice/<invoice-id>/pdf' \
  --header 'Authorization: Bearer <authorization-token>' \
  --output invoice.pdf

Check the status before you treat the response as a file, because a 404 carries an error body, not a PDF.

Get payment details

GETGet payment details/invoice/{id}/payment-detailsGet payment details in Swagger (opens in a new tab)

The accounts to pay to might change with the invoice's process status, so fetch the details again after a change instead of storing them.

Shell
curl --request GET \
  --url 'https://api.sandbox.waya.se/v4/rest/invoice/<invoice-id>/payment-details' \
  --header 'Authorization: Bearer <authorization-token>'

Credits

A finalized invoice can no longer be replaced or deleted. To correct it, credit it. A credit reduces what the debtor owes on the invoice.

Create a credit

A credit row points to the invoice row it credits with debitRowExternalNumber, debitRowId or debitRowArticleNumber. The row's externalNumber is the one you set when you created the invoice, and its id is in the answer from Get an invoice.

The other fields of a credit row work as the fields of an invoice row (opens in a new tab): text, unitPrice, quantity, discountTotal, discountPercentage, percentageMarkup, vatPercentage, priceExcludingVat and sumValidation. This example credits one hour of the four-hour row on the invoice from Create an invoice:

Shell
curl --request POST \
  --url 'https://api.sandbox.waya.se/v4/rest/credit' \
  --header 'Authorization: Bearer <authorization-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "externalNumber": "CR-1001",
    "debitId": "<invoice-id>",
    "rows": [
      {
        "debitRowId": "<row-id>",
        "text": "Consultation services",
        "unitPrice": 800.00,
        "quantity": 1,
        "vatPercentage": 25.0,
        "priceExcludingVat": true
      }
    ]
  }'

Store only the id, as you do for invoices. Swagger describes how to find credits (opens in a new tab) and get a credit (opens in a new tab).

Direct payments

POSTRegister a direct payment/direct-paymentRegister a direct payment in Swagger (opens in a new tab)

The debt is reduced only when you register a direct payment, so register each one to keep the invoice correct and to stop the debtor from being reminded about money that has been paid.

Shell
curl --request POST \
  --url 'https://api.sandbox.waya.se/v4/rest/direct-payment' \
  --header 'Authorization: Bearer <authorization-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "externalNumber": "1234",
    "allocations": [
      { "invoiceId": "<invoice-id>", "amount": 100 },
      { "invoiceId": "<other-invoice-id>", "amount": 50 }
    ]
  }'

If you send a payment again after an error, 319-2-6 (Already exists) tells you the payment is already registered.

Closures

POSTRegister a closure/invoice/{id}/closureRegister a closure in Swagger (opens in a new tab)
Shell
curl --request POST \
  --url 'https://api.sandbox.waya.se/v4/rest/invoice/<invoice-id>/closure' \
  --header 'Authorization: Bearer <authorization-token>' \
  --header 'Content-Type: application/json' \
  --data '{ "closeAll": true }'

Patch an invoice

PATCHPatch an invoice/invoice/{id}Patch an invoice in Swagger (opens in a new tab)
Shell
curl --request PATCH \
  --url 'https://api.sandbox.waya.se/v4/rest/invoice/<invoice-id>' \
  --header 'Authorization: Bearer <authorization-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "deliveryMethod": "EMAIL",
    "debtor": { "email": "debtor@example.com" }
  }'

If a call fails, Errors explains the error codes. Read Webhooks next to be told about changes instead of polling, and continue with Go live when you are ready for production.