Using code that has been in production for maybe nearly a decade, which has obviously been tweaked here and there as the FreeAgent API has been adjusted, I am now getting an error when I try to create an invoice. The error is as follows:
Client error: POST https://api.freeagent.com/v2/invoices resulted in a 422 Unprocessable Entity response: {"errors":[{"message":"contact_id can't be blank"}]}
Here is the body of the data that I am sending to the invoices endpoint (I’ve obviously redacted certain items).
array ( 'contact' => 'https://api.freeagent.com/v2/contacts/123456', 'dated_on' => '2026-07-01', 'payment_terms_in_days' => 9, 'currency' => 'EUR', 'invoice_items' => array ( 0 => array ( 'item_type' => 'Months', 'description' => 'Software Subscription', 'quantity' => 1, 'price' => 18.2, 'sales_tax_rate' => 0.0, 'category' => 'https://api.freeagent.com/v2/categories/002', ), ), 'ec_status' => 'Reverse Charge', )
Could someone please help explain why we’re suddenly looking for contact_id and why this is failing suddenly?
I’ve tried including contact_id as well as in place of contact. I can’t seem to get anything to work.