/v1/invoices/{id}/emailsSends one file of this invoice to one email address, as an attachment.
The file is the one GET /v1/invoices/{id}/download would hand out for the same format. It is sent only when the invoice’s newest check accepts it. A file that may not be downloaded is not sent either. An invoice already sent stays downloadable on the check it was sent with, but sending it again needs the newest check.
A 202 means the email provider accepted the email. It does not mean the buyer’s mail server received it. The invoice’s history gets one api:emailed event with the format, the address and the provider’s id.
Send an Idempotency-Key: a retry with the same key and body answers the first email and sends nothing, also when the first answer was lost on the way. An email sent by itself is sent once in the same way.
to and format may be left out when the invoice was made for a customer that is delivered by email (deliveryPlan on the invoice). The address and the file are then the ones the invoice was filed with. An invoice is also sent without this request when the company’s sending setting (/v1/sending) made it automatic; its sending then says how that went.
Path parameters
- idstring (uuid)Required
Headers
- Idempotency-Keystring
The same key and body again is answered with the first answer, and nothing is done twice. The same key with another body is 409
idempotency_key_reused; while the first is still being done, 409request_in_progress. A key over 255 characters is 400invalid_idempotency_key. Without a key, every request is done.
Request body
application/json, required
- tostring (email)
One email address. Left out
- formatstring
Which file of the invoice to attach. A DATEV file is not sent by email. Left out, the file of the invoice's email delivery.
One oforiginal,ubl,cii,zugferd-pdf,peppol,en16931-ubl,en16931-cii,factur-x,extended-cii,zugferd-extended.
Response
A 202 answer carries these fields.
- emailIdstringRequired
The email provider's id for this email.
- tostringRequired
- formatstringRequired
Status codes
| Status | Meaning |
|---|---|
202 |
The email provider accepted the email. |
400 |
The body is not JSON (invalid_json), or is not one address and one invoice file, and the invoice’s delivery plan does not fill in what is left out (invalid_email). Nothing was sent. |
401 |
No usable credential was sent (invalid_credentials). |
404 |
No such invoice exists for this company, or it has no file of that format (unknown_invoice). |
409 |
The file may not leave, for the reason the download gives (invoice_rejected, invoice_not_validated, invoice_changed_since_check), it cannot be written in that format (conversion_would_be_incomplete), or an edit replaced this version (invoice_replaced; the message names the newest version). Nothing was sent. A repeat with the same Idempotency-Key and another body (idempotency_key_reused), or while the first is still being done (request_in_progress; send it again in a moment). Nothing was done twice. |
502 |
The email provider refused the email or could not be reached (email_not_sent); its reason is in the message. Or the engine could not build the file (engine_unavailable). Nothing was sent. |
503 |
This deployment has no email provider set up (email_not_configured). Nothing was sent. |
/v1/invoices/{id}/emailscurl -X POST https://api.certinvo.com/v1/invoices/$INVOICE_ID/emails \
-H "Authorization: Bearer $CERTINVO_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @body.jsonimport { readFile } from 'node:fs/promises'
const invoiceId = '3f0c2a5e-8d1b-4c7a-9e2f-6b5d4a3c2b1a'
const response = await fetch(`https://api.certinvo.com/v1/invoices/${invoiceId}/emails`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CERTINVO_API_KEY}`,
'Content-Type': 'application/json',
},
body: await readFile('body.json'),
})
console.log(response.status, await response.json())import os
import requests
invoice_id = "3f0c2a5e-8d1b-4c7a-9e2f-6b5d4a3c2b1a"
response = requests.post(
f"https://api.certinvo.com/v1/invoices/{invoice_id}/emails",
headers={"Authorization": f"Bearer {os.environ['CERTINVO_API_KEY']}", "Content-Type": "application/json"},
data=open("body.json", "rb"),
)
print(response.status_code, response.text){
"emailId": "string",
"to": "string",
"format": "string"
}