Skip to main content
POST
/
accounting
/
documents
Create Document
curl --request POST \
  --url https://api.rootfi.dev/v3/accounting/documents \
  --header 'Content-Type: multipart/form-data' \
  --header 'api_key: <api-key>' \
  --form file='@example-file' \
  --form company_id=123 \
  --form 'document_type_id=<string>' \
  --form 'base64_file=<string>' \
  --form 'file_name=<string>'
import requests

url = "https://api.rootfi.dev/v3/accounting/documents"

files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"company_id": "123",
"document_type_id": "<string>",
"base64_file": "<string>",
"file_name": "<string>"
}
headers = {"api_key": "<api-key>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.text)
const form = new FormData();
form.append('file', '<string>');
form.append('company_id', '123');
form.append('document_type_id', '<string>');
form.append('base64_file', '<string>');
form.append('file_name', '<string>');

const options = {method: 'POST', headers: {api_key: '<api-key>'}};

options.body = form;

fetch('https://api.rootfi.dev/v3/accounting/documents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.rootfi.dev/v3/accounting/documents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"company_id\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_type_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"base64_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_name\"\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"api_key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.rootfi.dev/v3/accounting/documents"

payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"company_id\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_type_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"base64_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_name\"\r\n\r\n<string>\r\n-----011000010111000001101001--")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("api_key", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.rootfi.dev/v3/accounting/documents")
.header("api_key", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"company_id\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_type_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"base64_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_name\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.rootfi.dev/v3/accounting/documents")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api_key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"company_id\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_type_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"base64_file\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_name\"\r\n\r\n<string>\r\n-----011000010111000001101001--"

response = http.request(request)
puts response.read_body
{
  "data": {
    "rootfi_id": 157,
    "rootfi_created_at": "2024-01-22T05:07:31.465Z",
    "rootfi_updated_at": "2024-01-22T05:07:31.000Z",
    "rootfi_company_id": 1089,
    "platform_id": "123456",
    "rootfi_deleted_at": "2023-11-07T05:31:56Z",
    "platform_unique_id": "<string>",
    "raw_data": {},
    "data_hash": "<string>",
    "file_name": "<string>",
    "file_type": "<string>",
    "file_size": "<string>",
    "document_type_id": "<string>",
    "document_type": "<string>",
    "document_uploaded": true,
    "updated_at": "<string>"
  },
  "sync_id": "<string>"
}
{
"error": {
"message": "<string>",
"code": "<string>",
"field": "<string>"
}
}
{
"error": {
"message": "<string>",
"code": "<string>",
"field": "<string>"
}
}
{
"error": {
"message": "<string>",
"code": "<string>",
"field": "<string>"
}
}
{
"error": {
"message": "<string>",
"code": "<string>",
"field": "<string>"
}
}
The Documents Data Model simplifies the handling of document documents across various accounting platforms, providing a standardised approach to accessing and managing document-related information. To Upload a file using Node JS SDK, you can use the following code:
import { RootFiClient } from "rootfi-api";

const rootfi = new RootFiClient({ apiKey: "*****" });
await rootfi.accounting.documents.create(fs.createReadStream("./helpers/test_img.png"), {
  companyId: 12,
  documentType: "BILLS",
  documentTypeId: "3770712000000689685",
});

Authorizations

api_key
string
header
required

Body

multipart/form-data
file
file
company_id
integer

The company ID of the document

document_type_id
string | null

The document type ID of the document

document_type
enum<string>

The document type of the document

Available options:
BILLS,
INVOICES,
BILL_CREDIT_NOTES,
INVOICE_CREDIT_NOTES,
EXPENSES,
PURCHASE_ORDERS,
SALES_ORDERS
base64_file
string | null

The base64 file of the document

file_name
string | null

The file name of the document

Response

data
accountingDocumentObject · object | null

The data of the created document

sync_id
string | null

The sync id of the request