Skip to main content

Email yourself a preview of the invoice

POST/api/v1/invoices/{id}/preview

Emails the invoice as the customer would get it, with the same note, link and PDF, to the email address of the member making the request and to nobody else, with "Preview" at the start of the subject. The invoice is left as it is: a draft stays a draft and is not issued, nothing is recorded as sent, and it is not listed among the customer's messages. A draft is previewed as sendInvoice would issue it, with issue_date and due_date when given, and message in place of the standard note. Errors: 409 invalid_transition for a void invoice; 422 invoice_has_no_items; 422 message_too_long. It counts towards the 100 emails a day that sendQuote and sendInvoice share.

  • Needs an API key, and runs with the access of the member who made the key.
  • Send an Idempotency-Key. The same key with the same request within 24 hours gives the first answer again and changes nothing.
  • A connected AI assistant can use it too, as previewInvoice.

Parameters

In the address

  • idstring (uuid)required

Headers

  • Idempotency-Keystringrequired

    Unique user-scoped key for safely retrying this mutation for 24 hours.

    At least 1 character. Up to 200 characters.

Request body

Sent as application/json.

  • messagestring or null

    Replaces the default email text (`email_message` on the invoice).

    Up to 2000 characters.

  • issue_datestring (date)

    Draft only: the invoice date it would be issued with. Ignored once issued.

  • due_datestring (date)

    Draft only: the due date it would be issued with. Ignored once issued.

Responses

200Where the preview went.

  • dataobjectrequired

    Fields(1)
    • sent_tostring (email)required

      The address the preview was emailed to.

A refusal answers in the one error shape every operation shares.

Example

A request our own tests send. The ids are made up: put your own in their place.

curl -X POST "https://app.tradesender.co.uk/api/v1/invoices/5c559b97-554b-55cc-840a-83f274908399/preview" \
  -H "Authorization: Bearer $TRADESENDER_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "message": "Here is the invoice for the hedge and borders. [Link]"
}'