Envoyer un document par email

Pour envoyer un document (facture, devis, pièce jointe) vous devez utiliser l'endpoint /apps/:appId/email/document.

var myHeaders = new Headers();

myHeaders.append("Authorization", "Bearer <token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "title": "Titre de mon email",
  "body": "Contenu de mon email",
  "from": "[email protected]",
  "documents": [
    {
      "type": "invoice", // Types : invoice ou quote ou attachment
      "id": "1" // ID de votre facture, devis ou pièce jointe
    }
  ],
  "recipients": [
    "[email protected]",
    "[email protected]",
    "[email protected]"
  ],
  "recipients_cc": [
    "[email protected]",
    "[email protected]"
  ],
  "recipients_bcc": [
    "[email protected]",
    "[email protected]"
  ]
});

var requestOptions = {
		method: 'POST',
		headers: myHeaders,
		body: raw,
		redirect: 'follow'
};

fetch("https://api.sinao.app/v1/apps/:appId/email/document", requestOptions)
		.then(response => response.text())
		.then(result => console.log(result))
		.catch(error => console.log('error', error));