422 - Unprocessable Entity returned from call to [POST] invoices/55126/send_email

I’m trying to send a Invoice Email with the below I’m using a verfied email address but i’m receive the error

{“errors”:[{“message”:“from must be a verified email address”}]}
422 - Unprocessable Entity returned from call to [POST] invoices/55126/send_email.

this.Execute(string.Format(“invoices/{0}/send_email”, id), Method.POST, r =>
r.RequestFormat = DataFormat.Json;

Hi Phil,

My name is Dave and I am one of the Support Engineers here at FreeAgent. Sorry to hear you’re having some trouble sending invoices via our API, I’ll do my best to help.

I’ve had a look through our logs and I’ve identified your requests, which are indeed returning a 422 error. Our logs are quite heavily sanitised, removing PII (including the contents of emails) so it’s not imemdiately possible for me to see exactly what might be causing the error. My suspicion is that one or more of the parameters you’re sending doesn’t quite match the format our API expects, hence the Unprocessable Entity error we’re returning.

In the first instance, would you mind pointing your code to a service such as postb.in and verifying that the POST request you’re sending contains all the parameters our documentation outlines, nothing more, and nothing less. If everything looks correct, could you post a (sanitised) copy of the request you’re sending here on the forum so we can send the same payload using curl and verify the response we see in a test environment?

Dave J

Hi Dave

Here is a what i’m sending anf from the documentation everything looks correct and still getting the 422 error

invoice = new
email = new
to = "james@atlascode.com",
from = "admin@informdirect.co.uk",
subject = “Inform Direct Invoice 2000003727 for your records”,
body = “Thank you for using Inform Direct.\r\nPlease find attached an invoice for your records. The sum due has been paid. \r\n\r\nThank you.\r\n\r\nKind regards\r\n\r\nThe Inform Direct team\r\n”,
email_to_sender = true

Hi Phil,

Can you post the raw HTTP request that you’re sending, please?
The code in your last message defines some hashes, but it’s not clear how those translate into the request that’s being sent to our server.

Dave J

{ invoice = {{ email = { to = james@atlascode.com, from = admin@informdirect.co.uk, subject = Inform Direct Invoice 2000003763 for your records, body = Thank you for using Inform Direct.
Please find attached an invoice for your records. The sum due has been paid.

Thank you.

Kind regards

The Inform Direct team
, email_to_sender = True } }} }

Hi Dave

I was wondering how you were getting on looking into this.

It sometimes works fine but other times it doesn’t and leaves the invoice in a draft state due to the failure but can’t see any pattern on what’s different between the ones that work and the ones that error.



Hi Phil,

Would you mind posting an example http request that fails to complete successfully when sent to the API. The code you’ve given so far is unfortunately just a series of hashes, it doesn’t show the API end-point you’re posting to, the Content-Type of the request, etc.

The easiest way to grab the raw HTML is to point your integration to a service like postb.in, trigger a send_email request and then copy the request that’s received by postb.in into this conversation, so we can take a closer look.

Please remember to remove the Authorization: Bearer TOKEN from your request, before sharing here, as this is a secret that shouldn’t be shared.

Hi David

Here is the http request in postbin.

Let me know if you need anything else


“method”: “POST”,

“headers”: {

“host”: “postb.in”,

“connection”: “close”,

“accept”: “application/json, application/xml, text/json, text/x-json, text/javascript, text/xml”,

“user-agent”: “RestSharp/”,

“content-type”: “application/json”,

“accept-encoding”: “gzip, deflate”,

“connect-time”: “0”,

“total-route-time”: “0”,

“content-length”: “368”


“query”: {},

“body”: {

“invoice”: {

“email”: {

“to”: "james@atlascode.com",

“from”: "admin@informdirect.co.uk",

“subject”: “Inform Direct Invoice 2000003881 for your records”,

“body”: "Thank you for using Inform Direct. Please find attached an invoice for your records. The sum due has been paid. Thank you. Kind regards The Inform Direct team ",

“email_to_sender”: true




“ip”: “”,

“binId”: “SLPIPGSk”,

“inserted”: 1541514968403,

“reqId”: “RI2FTROo”


Hi David

I was just wondering how you where getting on looking into this and if you need anything else from me


Hi, Phil.

How often is this happening for you? When’s the last time you got a 422? I don’t see any failures in the last week.

Is the problem transient? In other words, if you get a 422 and then re-send the exact same request, does it then work?

Have you been able to reproduce the error using curl instead of your app?

As for how we’re getting on with this, we’ve been unable to reproduce it and we’re not getting any other reports of this problem so right now we’re relying on your help to try to track down the problem.

Thanks for your patience,