Create Invoice through API - PHP cURL - Sandbox

Hi Fari,

There’s a few changes to your JSON needed:

  • For invoices presently only one can be created at a time, so remove
    the array surrounding the hash
  • dated_on needs to be a date and not a time, so remove the time stamp
  • You have status twice (although this doesn’t cause a problem).
    Invoices can only be created as “Draft” and then have to be marked as sent
  • You can’t set net_value etc. Instead, create a nested array of
    invoice items with price and quantity and the API will fill out net_value,
    etc for you. Invoices are created in the same way as in the main app.

For example, using Curl:

-H “Authorization: Bearer XXXXXXX”
-H “Accept: application/xml”
-H “Content-Type: application/json”
-d ‘{
“invoice”: {
“contact”: “”,
“status”: “Draft”,
“dated_on”: “2012-08-16”,
“currency”: “GBP”,
“exchange_rate”: “1.0”,
“comments”: “Added by api”,
“omit_header”: false,
“payment_terms_in_days”: 30,
“invoice_items”: [
“description”: “Test InvoiceItem”,
“item_type”: “Hours”,
“price”: “112.0”,
“quantity”: “1.0”

Kind regards,

GraemeOn 24 July 2012 15:34, Fari wrote:


I want to create an invoice for an existing contact, but I can’t. I can
create a project for that contact.

$post_cars = ‘{“invoice”:[{“contact”:"",“status”:“Draft”,“dated_on”:"2012-08-16
by api”,“omit_header”:false,“payment_terms_in_days”:30}]}’;

I’ve also tried “/v2/contacts/385”, but no success.

Any help, please?

Thank you,

You received this message because you are subscribed to the Google Groups
“FreeAgent API” group.
To view this discussion on the web visit
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Graeme Boyd
Senior Software Engineer

Web. Blog.
Twitter. @freeagent!/freeagent Facebook.

40 Torphichen Street, Edinburgh, EH3 8JB
FreeAgent Central Ltd. Registered in sunny Scotland SC316774