Add Documents via API Call


is there an option to add documents inclusive the document file via api?!/document/post_documents


The API supports it, it’s used by our mobile apps.

You need to send a post request to

Note: this feature requires our enterprise plan.

Hi Hillel,

thanks for the fast response! I currently use the self hosted version, but I don’t understand how to include the filecontent in the post request!?

“id”: 1,
“name”: “Test”,
“type”: “CSV”,
“invoice_id”: 1,
“updated_at”: 1451160233,
“archived_at”: 1451160233


From reviewing the code it looks like you need to set file and invoice_id (or expense_id)

Note: the data should be sent as a multipart/form-data request.

I currently have no idea how to post the documents via Api. Do you have an real life example for me, maybe with php-curl or with

curl -X POST -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest" -F "file=@/path/to/file"

I can’t find the way to push Documents via API. Can I buy commercial support for this?

For me the best way would be to have an complete example with cmd curl or php curl for PHP 7.0.

The comment above has a complete working curl example.

You can hire help here:

I tried it on the cmd and the document is uploaded, but how could I additionaly transfer the invoice_id?

My first try was to update the document after creating it, but there is no PUT Call.

Here’s what you’d add when using curl

-H "Content-Type:application/json" -d '{"invoice_id":1}'

This way don’t works :(.

“Warning: You can only select one HTTP request method! You asked for both POST
Warning: (-d, --data) and multipart formpost (-F, --form).”

Try using as the URL

the GET Link with invoice_id was the solution! Thanks!

Great to hear!

with httpful the call is:

$url = ';
$response = \Httpful\Request::post($url)
->addHeader(‘X-Ninja-Token’, ‘TOKEN’)
->addHeader(‘Requested-With’, ‘XMLHttpRequest’)
->attach([‘file’ => $pdfFile])

I know this is an old post, but just wanted to thank you for this answer, it worked great for me.