Unauthorised 401 when creating invoice

Hi all,

I receive a 401 Unauthorized response when trying to create an new invoice with the JSON at the bottom. The URI’s used are valid/exist. I am using https://developers.google.com/oauthplayground/ to send the POST request to https://api.sandbox.freeagent.com/v2/invoices. Other POST or GET requests I have tried work but not this one. Anybody has an idea what the problem might be? What puzzles me particularly is that the response is 401.


"total_value": "200.0",
"paid_value": "50.0",
"due_value": "150.0",
"comments":"An example invoice comment.",
"always_show_bic_and_iban": false,
"send_new_invoice_emails": false,
"bank_account": "https://api.sandbox.freeagent.com/v2/bank_accounts/4956",
"ec_status":"EC Goods",
"payment_methods": {
  "paypal": true,
  "stripe": false
    "description":"Test InvoiceItem",


Hi @thei :wave:

Peter here from the Engineering team at FreeAgent - sorry to hear you’re having trouble.

I’ve had a quick look here for you, and it looks like you’re not wrapping your params in an invoice key, like so:

  "invoice": {
    "url": "https://api.sandbox.freeagent.com/v2/invoices/88390",
    "contact": "https://api.sandbox.freeagent.com/v2/contacts/72540",

From the docs:

“Payload should have a root invoice element, containing elements listed under Invoice Attributes.”

Sorry about the 401 error - in this case it’s the wrong thing to return, and is a bit misleading; I’ll raise it internally to see if we can try to improve our error responses in the future.

For now though, I hope this gets you back on track!

All the best,

Ah fantatsic, thanks for the quick answer Peter!