Cannot mark invoice as sent via API

Hello!,

We’re trying to send invoices (created as drafts on 1st Sep) via the API. When we POST to:

https://api.freeagent.com/v2/invoices/xxxxxxx/send_email

we get a really helpful 400 error:

{“errors”:{“error”:{“message”:“This Invoice has errors and cannot be sent”}}}

If we then login to FreeAgent goto edit the invoice (without changing anything) and then click save, we get the error message:

Unable to schedule email delivery because the date for this invoice (01 Sep 25) is in the past

However, if we view the invoice and click on the ‘Send Now’ breadcrumb link, it sends the invoice and schedules payment.

I’m now spending my afternoon going through 198 invoices and manually marking them as sent via the last method.

This seems like a bug to me. Can a member of staff advise?

Hi @oliverdk, I’m Simon, an engineer from FreeAgent. It’s likely you’re seeing this error if the invoices have been set to automatically email using your templates. You should be able to use this endpoint if the invoice hasn’t been set to automatically send in this way.

Could you try to uncheck “Email this invoice automatically” for an affected invoice and attempt this again?

The invoices you have already created may be set up to automatically send in this way due to settings on the contact, which you can change if you’d like to default to not sending automatically in future. Let me know if this doesn’t solve your issue - hope it’s helpful!

Hi @fa_boardfish,

I ended up sending them all manually so there a none to test with but they were draft invoices not sent to customers and from memory weren’t set to send automatically.

I’ve just checked a few of the contacts and they’re haven’t got contact level invoice email settings setup.

Thanks for getting back to me, and my apologies that you needed to do this manually. If you find you need to do this again and want to automate it using the mark_as_sent endpoint, please get in touch if you’re seeing that error for a given invoice and we can look into why that’s happening for you.

It’s a monthly email invoice run, I’ll ping a message here next month when it comes up

1 Like