If an Invoice does NOT have send_new_invoice_emails, it behaves as expected, and the transition mark_as_sent works.
If an Invoice DOES have send_new_invoice_emails, a draft invoice is created in the GUI, and the message:
"Invoice email is configured to be sent **today** — click [Send Now] after adding your invoice items"
With the GUI, I can then click “Send now”, which calls “status/mark_as_sent”, which sends an email.
But, over the API, “transition/mark_as_sent”, does indeed mark as sent, but does NOT send the email.
Note: This has been replicated with the OAuth 2.0 Playground. Same behaviour.
However, when the date of the invoice is in the future, and send_new_invoice_emails=true, then calling “transition/mark_as_scheduled” reports the invoice as “Scheduled to Email” - then when the future date arrives, the invoice is emailed - just like using FreeAgent’s GUI.
This is a situation where the UI and API have slightly different actions available to them. While the UI’s “Mark as Sent” will also queue up the email or send it immediately, the API action only marks the invoice as sent.
For invoices which are dated today and have an email template, you may wish to use the
send_email API action (see the API documentation). If you provide the
"use_template": true flag in the parameters as described in the docs, the configured email template will be used. Sending the invoice email will also mark the invoice as sent.
Alternatively, you can always use the
mark_as_scheduled action, even on invoices whose date is not in the future - these will be sent overnight at the first opportunity.
Hope that helps you out - let us know if you have any further questions.
Thanks Chris. I suspected
send_email was a possible workaround, but hadn’t tried
mark_as_scheduled for an invoice dated today. //Greg
FYI - “Mark as Sent” does not “queue up the email or send it”. It does exactly what it says, it “marks it as sent”, without sending it. (for situations where you have emailed it manually or provided it another way)