sendEmail mutation
sendEmail is a GraphQL mutation of the Chameleoon MAX API. Send it as POST https://max-api.chameleoon.sk/api/v1/graphql with your API key, see Chameleoon MAX.
Renders an e-mail and queues it for delivery. Call it to send a message about a record, with a template or with your own subject and body.
The call either fails with one of the errors below before anything is stored, or returns the
message with the status QUEUED. MAX tries delivery up to 8 times, and the message then turns
SENT or FAILED. Read it with emailMessage.
Permissions
- Requires the
email.sendpermission. - The
resourcerequires its read permission:invoice.readforINVOICE,order.readforSALES_ORDER,shipment.readforSHIPMENT. - An
invoicePdfattachment requires theinvoice.readpermission, and alsoprice.readwhen MAX renders the PDF itself. - An
orderInvoiceattachment requires theorder.readandinvoice.readpermissions, and alsoprice.readwhen MAX renders the PDF itself. - A
documentattachment requires the permission that reading its record's documents requires:order.readfor an order's,invoice.readfor an invoice's. An invoice's PDF that is a stored document requires the same. - A
fileattachment must be your API key's own upload (POST /api/v1/files, whichemail.sendalso allows). - Without
price.read, the template data carries no amounts. Withoutcompany.read, it carries no issuing company, as on an order print.
Repeated calls
requestId makes a retry after a lost response safe. A repeat with the same requestId and
the same input returns applied: false and the first call's message as it is now. A repeat
with other input fails with CONFLICT and reason REQUEST_ID_REUSED.
sendTestEmail shares the same requestIds.
The response always carries the message's id and status (and applied), also on a repeat.
Its content is returned only when your API key may read the message (see
SendEmailResult).
Errors
| Code | Reason | When |
|---|---|---|
VALIDATION | NO_RECIPIENT | There is nobody to send to (field to). |
VALIDATION | INVALID_ADDRESS | An address is not valid (field to, cc or bcc). |
VALIDATION | TOO_MANY_RECIPIENTS | to, cc and bcc hold more than 50 addresses in all. |
VALIDATION | TEMPLATE_ERROR | A part does not parse or render, for example because of an unclosed {{ or {%. extensions.part names the part and, when known, extensions.line the line. |
VALIDATION | EMPTY_BODY | The HTML body renders to nothing (field html). |
VALIDATION | ATTACHMENTS_TOO_LARGE | The attachments are over 15 MiB in all. |
NOT_FOUND | TEMPLATE_NOT_FOUND | The template does not exist (field template). |
NOT_FOUND | extensions.field names what does not exist: resource, sender, orderInvoice, invoicePdf, document or file. | |
FORBIDDEN_ROLE | DOCUMENT_READ_REQUIRED | An invoice's PDF is a stored document your API key may not read (the invoice's requires invoice.read; an order's requires order.read and the order in your API key's scope), or the order's governing invoice is outside your API key's scope. Field attachments; extensions.permission names the permission. MAX never sends its own render or another file in its place. |
CONFLICT | NO_SENDER | There is no sender to send through, or the named sender is disabled. |
CONFLICT | INVOICE_NOT_READY | The order has no invoice yet. Try again later. |
CONFLICT | INVOICE_PDF_MISSING | The accounting system has not sent the invoice's PDF yet, and the invoice's external source does not allow MAX to render it (ExternalSource.invoicePrintAllowed). Try again later. |
CONFLICT | INVOICE_NOT_PRINTABLE | The invoice is pending, failed or cancelled. |
CONFLICT | INVOICE_RENDER_BUSY | MAX is busy rendering PDFs. Try again in a moment. |
CONFLICT | REQUEST_ID_REUSED | The requestId was used before with other input. |
An error whose path runs below this field does not mean the call failed: the message was queued, so do not retry. See
Mutation.
It may render an invoice PDF.
Costs 11 points plus its selection.
Arguments
input:SendEmailInput!· required
Returns
Example
Mutation
Code
Variables
Code
Response
Code
Values are illustrative: replace IDs and codes with your own before you send the call.