Skip to content

Invoice data by webhook

A webhook is a message one program sends another over the web. With it, Doxtly can talk to the system that keeps your invoices. The data can travel in either direction, and this recipe shows both: a form that pushes a request out to your accounting system, and a shop that pushes order data in so Doxtly makes the PDF.

A client asks for an invoice on your website. Doxtly passes the request to your accounting system and emails the client the number it gets back.

Available when: an accounting system with an API, and an active email integration

Canvas with a trigger on A form is submitted, a Webhook step showing POST and the address, and a Send email step

You need a form, here “Request an invoice”, with fields such as company, tax_id, amount and email, and the address and key of your accounting system’s API.

  1. Create a workflow with the trigger A form is submitted on the form.

  2. From Notifications in the palette, drop Webhook and connect it.

  3. On Request, keep the Method on POST and set the URL to your system’s address, such as https://api.example.com/invoices.

  4. On Headers, click Add header. Set Name to Authorization and Value to Bearer followed by your key. Tick Secure, so the value is encrypted and hidden once saved. Leave the Content-Type header that’s already there.

  5. On Body, keep Body source on Content with the JSON format, and write what your system expects. Use the Insert a variable button for the values:

    {
    "buyer": { "name": "{{ company }}", "taxId": "{{ tax_id }}" },
    "amount": "{{ amount }}",
    "externalId": "{{ _execution.eventId }}"
    }
  6. On Response, choose Store the response body in a variable and set Variable for the response to invoice. A JSON answer becomes an object, so a number field in it is {{ invoice.number }}.

  7. Add Send email to {{ email }}, with a template that prints {{ invoice.number }}.

  8. Save and switch it on.

Body tab of the Webhook step with JSON content holding variables for company, tax_id and amount

A value that’s a single variable and nothing else keeps its type, so "{{ amount }}" arrives as a number if the form gave a number. That also lets you pass a whole list: "items": "{{ items }}".

Only a 2xx answer counts as success. Anything else stops the run, and the Webhook card shows what the endpoint said. Redirects aren’t followed.

Your shop or CRM knows the order, and Doxtly makes the document. The other system calls a webhook address of yours with the data, and that starts the workflow.

Available when: a webhook of your own, within your plan's number of webhooks, and an active email integration

Canvas with a Webhook request trigger, a Generate document step, a Send email step and an Upload to Google Drive step
  1. Under Resources > Webhooks, create a webhook, for example “Shop invoices”. Choose Token under authentication and copy the token, which is shown once.

  2. In its Data section, turn on Check the data against a JSON Schema and paste a schema of the data. It rejects malformed requests before they start anything, and it makes the fields show up in the variable picker. Without one, you type paths by hand.

  3. Give the address and the token to the other system.

  4. Create a workflow. Set Starts on to Webhook and Trigger source to “Shop invoices”. Only a webhook that’s switched on can be chosen.

  5. Add Generate document with your invoice template, and set Output filename to Invoice-{{ number }}.pdf. The template prints the request’s fields. A field the template needs and the request lacks stops the step with an error, naming what’s missing.

  6. Add Send email to {{ buyer.email }}, with the generated document under Attachments.

  7. Add Upload to Google Drive with the Target folder Invoices/{{ _execution.date | first(7) }} and the generated document under Files to upload, if you keep copies there.

  8. Save and switch it on.

For this request, the variables are {{ number }}, {{ buyer.email }} and so on:

{
"number": "FV-2026-11-042",
"buyer": { "name": "Halden Logistics", "email": "accounts@halden.example" },
"items": [ { "name": "GDPR training", "net": 1200 } ]
}

The webhook answers the caller as soon as it has taken the request, and the workflow runs after that. So a success answer means “received”, not “the invoice has gone”.

Systems often repeat a call when they aren’t sure it arrived. Turn on Require an idempotency key on the webhook if the other side can send an Idempotency-Key header: a repeat with the same key gets the first response and starts nothing. Keys are remembered for a day, and a request without one gets a 400.

For the first direction, the Webhook card shows the address, Status 201 or similar, and Response in: invoice.

Webhook step card with POST and the address, chips Status 201 and Response in: invoice, and a Delivery ID

For the second, open the request under Resources > Webhooks. Its Workflows tab lists the runs it started, and says why if there are none. A run’s Details tab links back to the Webhook request. See Webhook requests.