However, I’d prefer to be able to just use the default email address that is held against the FreeAgent contact.
If I send a blank email address then the error that I am seeing is: api.freeagent.com returned (422) Unprocessable Entity and said “to can’t be blank”
So my question is, is there anything (possibly undocumented) that I can specify that satisfies the “to” field having a value but that would pick up the associated email address and send the email to that address?
Thank you for your question. There is one way of using the contact email as the default, when using the send_email endpoint of the API, in order to not provide it again in the body. What you need to do to is create an invoice template. Here is the article of our knowledge base explaining how you can do that https://support.freeagent.com/hc/en-gb/articles/115001219010-Automatic-emails-for-new-invoices .
Once you have your invoice template saved, you can use the parameter use_template in the email hash of your POST request.
I’m not an expert with these API’s and I did struggle with this for quite a while.
While trying to get this to work, I found another way of achieving the same thing.
Not to be beaten, I did get “use_template” working (at least using the Google OAuth 2.0 Playground).
So the answer following Eva’s suggestion was to use the following in the request body (I wasn’t including the true part):