### Account balance response example Source: https://docs.microbooks.io/docs/how-to-guides/reports Example JSON response showing account balances grouped by account type. Includes account metadata and closing balances for each account. ```json { "updated_at": "2022-10-24 20:26:00", "closing_balance": { "1": -200 } } ``` -------------------------------- ### Report Response Example Source: https://docs.microbooks.io/docs/how-to-guides/reports Shows a JSON response with account details and balances for different account types (INVENTORY, BANK). ```json { "INVENTORY": { "accounts": [ { "uuid": "9c11e2d8-9f38-42c3-a816-d2e056ab366f", "id": 10, "entity_id": 1, "category_id": null, "currency_id": 1, "code": 2, "name": "Baylee Wolf", "description": null, "account_type": "INVENTORY", "destroyed_at": null, "deleted_at": null, "created_at": "2022-10-24 20:25:59", "updated_at": "2022-10-24 20:25:59", "closing_balance": { "1": 200 } }, { "uuid": "c9696ad1-b6e4-4fa9-891a-c58ab5baca77", "id": 36, "entity_id": 1, "category_id": null, "currency_id": 1, "code": 4, "name": "Reyes Hand", "description": null, "account_type": "INVENTORY", "destroyed_at": null, "deleted_at": null, "created_at": "2022-10-24 20:25:59", "updated_at": "2022-10-24 20:25:59", "closing_balance": { "1": 100 } } ], "balance": 300 }, "BANK": { "accounts": [ { "uuid": "b2abcf20-48d0-489e-8b82-8bbc3227d5ca", "id": 12, "entity_id": 1, "category_id": null, "currency_id": 15, "code": 2, "name": "Lowell Brakus", "description": null, "account_type": "BANK", "destroyed_at": null, "deleted_at": null, "created_at": "2022-10-24 20:25:59", "updated_at": "2022-10-24 20:25:59", "closing_balance": { "1": -100 } }, { "uuid": "9431276a-76fc-47ea-87fd-82e490d3f366", "id": 17, "entity_id": 1, "category_id": null, "currency_id": 15, "code": 1, "name": "Torrey Wyman", "description": null, "account_type": "BANK", "destroyed_at": null, "deleted_at": null, "created_at": "2022-10-24 20:25:59", "updated_at": "2022-10-24 20:25:59", "closing_balance": { "1": 100 } }, { "uuid": "d4c2dca1-31e1-44be-ba80-4c4529d4cf1e", "id": 57, "entity_id": 1, "category_id": null, "currency_id": 65, "code": 4, "name": "Eliezer Vandervort", "description": null, "account_type": "BANK", "destroyed_at": null, "deleted_at": null, "created_at": "2022-10-24 20:26:00", "updated_at": "2022-10-24 20:26:00", "closing_balance": { "1": -100 } } ] } } ``` -------------------------------- ### Response for closing rates Source: https://docs.microbooks.io/docs/how-to-guides/reporting-periods Example JSON response showing a success status and a closing_rates array with exchange rate details. ```json { "status": "success", "closing_rates": [ { "uuid": "6c2cd8bb-33ec-4721-b19d-f8c7049488d3", "id": 1, "entity_id": 1, "exchange_rate": { "uuid": "b3cb2a3b-308a-4bac-b8fa-762e747f4d7e", "id": 1, "entity_id": 1, "currency_id": 2, "valid_from": "2022-09-27T22:00:08.000000Z", "valid_to": "2022-10-21T13:02:21.000000Z", "rate": "100.0000" } }, { "uuid": "4bbd98dd-6de7-4a8c-8810-994a7b676c7b", "id": 2, "entity_id": 1, "exchange_rate": { "uuid": "e90bcf87-1e58-4fc7-bfa9-43e59cb888d1", "id": 2, "entity_id": 1, "currency_id": 4, "valid_from": "2022-10-01T14:25:38.000000Z", "valid_to": "2022-10-21T13:02:21.000000Z", "rate": "150.0000" } } ] } ``` -------------------------------- ### GET /books/v1/reports/trial-balance?format=pdf Source: https://docs.microbooks.io/docs/how-to-guides/reports Retrieves the Trial Balance report in PDF format for download or printing. ```APIDOC ## GET /books/v1/reports/trial-balance?format=pdf ### Description Retrieves the Trial Balance report in PDF format. The response is a PDF file. ### Method GET ### Endpoint /books/v1/reports/trial-balance?format=pdf ### Parameters #### Query Parameters - **format** (string) - Required - Set to `pdf` to receive the PDF version. ### Request Example No request body required. ### Response #### Success Response (200) - **Content-Type** (string) - `application/pdf` - **Body** (binary) - PDF file content. #### Response Example ``` Binary PDF data ``` ``` -------------------------------- ### Restore response JSON Source: https://docs.microbooks.io/docs/how-to-guides/recycle-bin Example success response for the restore operation, showing the restored resource object. ```json { "status": "success", "message": "Non Current Asset: Ms. Elisabeth Murphy Sr. restored successfully", "resource": { "uuid": "d66fc8fc-c073-41c9-bb36-2ae70f0130da", "id": 1, "entity_id": 1, "category_id": 1, "currency_id": 1, "code": 9, "name": "Ms. Elisabeth Murphy Sr.", "description": null, "type": "Non Current Asset", "is_closed": false, "category": { "uuid": "6460d9b7-dbdc-4ce3-a9fe-f51c2fd94cd8", "id": 1, "entity_id": 1, "name": "voluptatum", "type": "Non Current Asset" } } } ``` -------------------------------- ### Set Custom Year Start Source: https://docs.microbooks.io/docs/how-to-guides/entities Set year_start to the number representing the starting month when the financial year starts mid-calendar year. The example uses 4 for April. ```json { "name": "Acme Inc", "currency_code": "USD",, "year_start": "4", // April } ``` -------------------------------- ### Create Revenue Account - Python Source: https://docs.microbooks.io/docs/getting-started/quickstart/accounts Uses requests library to POST to /books/v1/account with OPERATING_REVENUE type. Prints response text. ```python import requests url = "https://api.microbooks.io/books/v1/account" body = {"name": "Revenue Account", "account_type": "OPERATING_REVENUE"} headers = {"Authorization": "Bearer "} response = requests.request("POST", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### GET /books/v1/entity Source: https://docs.microbooks.io/docs/getting-started/authentication/oauth-flow Calls the Microbooks API with an access token. This is an example of a protected resource endpoint. ```APIDOC ## GET /books/v1/entity ### Description Calls the Microbooks API with an access token. This is an example of a protected resource endpoint. ### Method GET ### Endpoint https://api.microbooks.io/books/v1/entity ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token: `Bearer `. ### Response #### Success Response (200) Returns the requested entity data. ``` -------------------------------- ### POST /books/v1/account Source: https://docs.microbooks.io/docs/getting-started/quickstart/accounts Creates a new account with a name and account type. The example shows creating a Capital Account of type EQUITY. ```APIDOC ## POST /books/v1/account ### Description Creates a new account in the books. The account must have a name and an account type (e.g., EQUITY). ### Method POST ### Endpoint https://api.microbooks.io/books/v1/account ### Parameters #### Request Body - **name** (string) - Required - The name of the account (e.g., "Capital Account"). - **account_type** (string) - Required - The type of the account (e.g., "EQUITY"). ### Request Example ```json { "name": "Capital Account", "account_type": "EQUITY" } ``` ### Response #### Success Response (200) - **status** (string) - Status of the request (e.g., "success"). - **message** (string) - Success message (e.g., "Equity: Capital Account created successfully"). - **resource** (object) - Details of the created account. - **name** (string) - Account name. - **currency_id** (integer) - Currency identifier. - **code** (integer) - Account code. - **entity_id** (integer) - Entity identifier. - **id** (integer) - Account ID. - **type** (string) - Account type (e.g., "Equity"). - **is_closed** (boolean) - Whether the account is closed. - **category** (null) - Account category (null if not set). #### Response Example ```json { "status": "success", "message": "Equity: Capital Account created successfully", "resource": { "name": "Capital Account", "currency_id": 1, "code": 3001, "entity_id": 1, "id": 1, "type": "Equity", "is_closed": false, "category": null } } ``` ``` -------------------------------- ### GET /books/v1/account/movement Source: https://docs.microbooks.io/docs/cookbook/reports Retrieves the breakdown of a cash flow section's balance movement by listing the account movements for the specified section. Use the same start and end dates as the Report resource to get the relevant movements. ```APIDOC ## GET /books/v1/account/movement ### Description Retrieves the breakdown of a cash flow section's balance movement by listing the account movements for the specified section. Use the same start and end dates as the Report resource to get the relevant movements. ### Method GET ### Endpoint /books/v1/account/movement ### Parameters #### Query Parameters - **section** (string) - Required - The cash flow section identifier (e.g., ASSETS). - **start-date** (string, format: YYYY-MM-DD) - Required - The start date of the reporting period. - **end-date** (string, format: YYYY-MM-DD) - Required - The end date of the reporting period. ### Request Example GET https://api.microbooks.io/books/v1/account/movement?section=ASSETS&start-date=2022-04-01&end-date=2022-04-30 ### Response #### Success Response (200) - **movements** (array) - List of account movements that constitute the cash flow section movement. #### Response Example (No explicit response body provided in the source documentation.) ``` -------------------------------- ### GET /books/v1/category/{categoryId}/accounts Source: https://docs.microbooks.io/docs/cookbook/reports Retrieves the breakdown of a Category's balance by listing the accounts that constitute the reported amount for the category in a report section. Use the same start and end dates as the Report resource to get the relevant accounts. ```APIDOC ## GET /books/v1/category/{categoryId}/accounts ### Description Retrieves the breakdown of a Category's balance by listing the accounts that constitute the reported amount for the category in a report section. Use the same start and end dates as the Report resource to get the relevant accounts. ### Method GET ### Endpoint /books/v1/category/{categoryId}/accounts ### Parameters #### Path Parameters - **categoryId** (integer) - Required - The unique identifier of the category. #### Query Parameters - **start-date** (string, format: YYYY-MM-DD) - Required - The start date of the reporting period. - **end-date** (string, format: YYYY-MM-DD) - Required - The end date of the reporting period. ### Request Example GET https://api.microbooks.io/books/v1/category/1/accounts?start-date=2022-04-01&end-date=2022-04-30 ### Response #### Success Response (200) - **accounts** (array) - List of accounts that constitute the category balance. #### Response Example (No explicit response body provided in the source documentation.) ``` -------------------------------- ### Create Revenue Account - C# Source: https://docs.microbooks.io/docs/getting-started/quickstart/accounts Uses RestClient to POST to /books/v1/account with OPERATING_REVENUE type. Adds bearer token header and prints response content. ```csharp var client = new RestClient("https://api.microbooks.io/books/v1/account"); client.Timeout = -1; var request = new RestRequest(Method.POST); var body = "{ \"name\": \"Revenue Account\", \"account_type\": \"OPERATING_REVENUE\" }"; request.AddParameter("text/plain", body, ParameterType.RequestBody); request.AddHeader("Authorization", "Bearer " + ); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Python request for Trial Balance report Source: https://docs.microbooks.io/docs/getting-started/quickstart/reports Use this Python script to fetch the Trial Balance report. It sends a GET request with an Authorization header and prints the response text. Replace with your token. ```python import requests url = "https://api.microbooks.io/books/v1/reports/trial-balance" body = {} headers = {"Authorization": "Bearer "} response = requests.request("GET", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### Get Clearances - C# Source: https://docs.microbooks.io/docs/how-to-guides/transactions C# script using RestClient to GET clearances. Sends null body and bearer token. ```csharp var client = new RestClient("https://api.microbooks.io/books/v1/transaction/1/clearances"); client.Timeout = -1; var request = new RestRequest(Method.GET); var body = null; request.AddParameter("text/plain", body, ParameterType.RequestBody); request.AddHeader("Authorization", "Bearer " + ); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Get Clearances - NodeJs Source: https://docs.microbooks.io/docs/how-to-guides/transactions Node.js script using request module to GET clearances. Sends empty body and bearer token. ```nodejs var request = require('request'); var options = { 'method': 'GET', 'url': 'https://api.microbooks.io/books/v1/transaction/1/clearances', 'headers': {'Authorization': 'Bearer '}, 'body': '{}' }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### Create Revenue Account - PHP Source: https://docs.microbooks.io/docs/getting-started/quickstart/accounts Uses Guzzle client to POST to /books/v1/account with OPERATING_REVENUE type. Sends async request and echoes response body. ```php $client = new Client(); $body = '{ "name": "Revenue Account", "account_type": "OPERATING_REVENUE" }'; $request = new Request('POST', 'https://api.microbooks.io/books/v1/account', [headers' => ['Authorization' => 'Bearer ']], $body ); $res = $client->sendAsync($request)->wait(); echo $res->getBody(); ``` -------------------------------- ### Get Clearances - Curl Source: https://docs.microbooks.io/docs/how-to-guides/transactions Curl command to retrieve a list of assignable transactions to which a transaction has been assigned for clearance. Uses GET request to the /transaction/1/clearances endpoint. ```curl curl --location --request GET 'api.microbooks.io/books/v1/transaction/1/clearances' ``` -------------------------------- ### GET account balances with Node.js request Source: https://docs.microbooks.io/docs/how-to-guides/accounts Uses the request module to send a GET request. Requires a valid bearer token in the Authorization header. ```javascript var request = require('request'); var options = { 'method': 'GET', 'url': 'https://api.microbooks.io/books/v1/account/1/balances', 'headers': {'Authorization': 'Bearer '}, 'body': '{}' }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### Create Exchange Rate - Response Source: https://docs.microbooks.io/docs/how-to-guides/exchange-rates Example response from the API after successfully creating an exchange rate. Shows the created resource with its details. ```json { "status": "success", "message": "ExchangeRate: 100.00 for Euro (EUR) from 2022-07-20 created successfully", "resource": { "valid_from": "2022-07-20T00:00:00.000000Z", "currency_id": 2, "rate": 100, "entity_id": 1, "id": 4, "currency": { "uuid": "7b87e7e9-0e23-44aa-9694-ba9ccfc0091b", "id": 2, "user_id": 1, "name": "Euro", "currency_code": "EUR" } } } ``` -------------------------------- ### Create Revenue Account - NodeJs Source: https://docs.microbooks.io/docs/getting-started/quickstart/accounts Uses request library to POST to /books/v1/account with OPERATING_REVENUE type. Logs response body. ```nodejs var request = require('request'); var options = { 'method': 'POST', 'url': 'https://api.microbooks.io/books/v1/account', 'headers': {'Authorization': 'Bearer '}, 'body': '{ "name": "Revenue Account", "account_type": "OPERATING_REVENUE" }' }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### GET account balances with Python requests Source: https://docs.microbooks.io/docs/how-to-guides/accounts Uses the requests library to send a GET request. Requires a valid bearer token in the Authorization header. ```python import requests url = "https://api.microbooks.io/books/v1/account/1/balances" body = {} headers = {"Authorization": "Bearer "} response = requests.request("GET", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### Create Entity - Python Source: https://docs.microbooks.io/docs/getting-started/quickstart/business-setup Python example using requests library to POST entity data. Prints the response text. ```python import requests url = "https://api.microbooks.io/books/v1/entity" body = {"name": "Acme Inc", "currency_code": "USD"} headers = {"Authorization": "Bearer "} response = requests.request("POST", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### Get Clearances - Curl Source: https://docs.microbooks.io/docs/cookbook/transactions Use this cURL command to retrieve the clearances for a transaction. The endpoint is 'api.microbooks.io/books/v1/transaction/1/clearances' and requires a GET request. No request body is needed. ```curl curl --location --request GET 'api.microbooks.io/books/v1/transaction/1/clearances' ``` -------------------------------- ### GET account balances with C# RestClient Source: https://docs.microbooks.io/docs/how-to-guides/accounts Uses RestSharp's RestClient to send a GET request. Requires a valid bearer token in the Authorization header. ```csharp var client = new RestClient("https://api.microbooks.io/books/v1/account/1/balances"); client.Timeout = -1; var request = new RestRequest(Method.GET); var body = null; request.AddParameter("text/plain", body, ParameterType.RequestBody); request.AddHeader("Authorization", "Bearer " + ); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Opening Balances response JSON Source: https://docs.microbooks.io/docs/how-to-guides/accounts Example response from the Opening Balances endpoint. Shows the structure of the returned balance objects, including fields like balance_type, balance, and transaction details. ```json { "status": "success", "account_balances": [ { "uuid": "339c1d88-9653-4e19-8bef-9ddc84cf936c", "id": 1, "entity_id": 1, "account_id": 1, "currency_id": 4, "exchange_rate_id": 1, "reporting_period_id": 1, "reference": "maxime", "transaction_date": "2021-10-21 16:17:55", "transaction_no": "esse", "balance_type": "DEBIT", "balance": "50.0000", "transaction_name": "Supplier Bill", "amount": 50, "type": "Debit", "is_posted": true, "is_credited": false, "exchange_rate": {...} }, { "uuid": "d08c2d44-cb33-4c80-b8af-1adf5494d44d", "id": 2, "entity_id": 1, "account_id": 1, "currency_id": 6, "exchange_rate_id": 1, "reporting_period_id": 1, "reference": "repellendus", "transaction_date": "2021-10-21 16:17:55", "transaction_no": "soluta", "balance_type": "DEBIT", "balance": "50.0000", "transaction_name": "Client Invoice", "amount": 50, "type": "Debit", "is_posted": true, "is_credited": false, "exchange_rate": {...} }, { "uuid": "039cce94-9df6-4bbe-ae30-44eddc160281", "id": 3, "entity_id": 1, "account_id": 1, "currency_id": 8, "exchange_rate_id": 1, "reporting_period_id": 1, "reference": "iste", "transaction_date": "2021-10-21 16:17:55", "transaction_no": "odit", "balance_type": "DEBIT", "balance": "50.0000", "transaction_name": "Journal Entry", "amount": 50, "type": "Debit", "is_posted": true, "is_credited": false, "exchange_rate": {...} }, { "uuid": "b50feee7-7d54-4918-bd19-15dd7d3cab90", "id": 4, "entity_id": 1, "account_id": 1, "currency_id": 11, "exchange_rate_id": 6, "reporting_period_id": 1, "reference": "deserunt", "transaction_date": "2021-10-21 16:17:56", "transaction_no": "quia", "balance_type": "CREDIT", "balance": "40.0000", "transaction_name": "Supplier Bill", "amount": 40, "type": "Credit", "is_posted": true, "is_credited": true, "exchange_rate": {...} } ] } ``` -------------------------------- ### GET account balances with cURL Source: https://docs.microbooks.io/docs/how-to-guides/accounts Sends a GET request to the Opening Balances endpoint using cURL. Replace the placeholder in the URL with the actual account ID. ```bash curl --location --request GET 'https://api.microbooks.io/books/v1/account/1/balances' ``` -------------------------------- ### Get Transaction Assignments - Node.js Source: https://docs.microbooks.io/docs/cookbook/transactions Use this Node.js script to retrieve transaction assignments. It uses the 'request' library to send a GET request with an Authorization header. ```javascript var request = require('request'); var options = { 'method': 'GET', 'url': 'https://api.microbooks.io/books/v1/transaction/1/assignments', 'headers': {'Authorization': 'Bearer '}, 'body': '{}' }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### Create Discount - Python Source: https://docs.microbooks.io/docs/how-to-guides/discounts Uses the requests library to POST the discount payload to the API. Requires an Authorization header with a bearer token. ```python import requests url = "https://api.microbooks.io/books/v1/discount" body = { "name": "Trade Discount", "code": "SALE", "rate" : 10, "account_id" : 1 } headers = {"Authorization": "Bearer "} response = requests.request("POST", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### Create Output VAT Account with Python Source: https://docs.microbooks.io/docs/getting-started/quickstart/accounts Uses the requests library to POST the Output VAT account data. Prints the HTTP response text. ```python import requests url = "https://api.microbooks.io/books/v1/account" body = {"name": "Output VAT Account", "account_type": "CONTROL"} headers = {"Authorization": "Bearer "} response = requests.request("POST", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### Get Transaction Assignments - Curl Source: https://docs.microbooks.io/docs/cookbook/transactions Use this cURL command to retrieve assignments for a transaction. The endpoint is GET /books/v1/transaction/1/assignments. Replace the bearer token with a valid one. ```bash curl --location --request GET 'api.microbooks.io/books/v1/transaction/1/assignments' ``` -------------------------------- ### Create Output VAT Account with C# Source: https://docs.microbooks.io/docs/getting-started/quickstart/accounts Uses RestClient to POST a raw body with the Output VAT account data. Sets timeout to -1 and adds the Authorization header. ```csharp var client = new RestClient("https://api.microbooks.io/books/v1/account"); client.Timeout = -1; var request = new RestRequest(Method.POST); var body = "{ \"name\": \"Output VAT Account\", \"account_type\": \"CONTROL\" }"; request.AddParameter("text/plain", body, ParameterType.RequestBody); request.AddHeader("Authorization", "Bearer " + ); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Retrieve Income Statement in PDF format (Curl) Source: https://docs.microbooks.io/docs/how-to-guides/reports Calls the income-statement endpoint with format=pdf to get the report in PDF. Uses a GET request with no authentication headers shown. ```curl curl --location --request GET 'api.microbooks.io/books/v1/reports/income-statement?format=pdf' ``` -------------------------------- ### Create Balance Response Source: https://docs.microbooks.io/docs/how-to-guides/balances Example response from the balance creation request, showing the created balance resource with status, message, and resource details. ```json { "status": "success", "message": "Debit Balance: Barrett Runolfsdottir DVM for year 2022 created successfully", "resource": { "reporting_period_id": 2, "exchange_rate_id": 1, "balance_type": "DEBIT", "currency_id": 2, "account_id": 1, "transaction_date": "2021-10-21", "balance": 100, "transaction_no": "1EGP2008", "entity_id": 1, "id": 1, "transaction_name": "Client Invoice", "amount": 100, "type": "Debit", "is_posted": true, "is_credited": false, "exchange_rate": {...}, "account": {...}, "currency": {..}, "reporting_period": {...} } } ``` -------------------------------- ### Retrieve Income Statement in HTML format (Curl) Source: https://docs.microbooks.io/docs/how-to-guides/reports Calls the income-statement endpoint with format=html to get the report in HTML. Uses a GET request with no authentication headers shown. ```curl curl --location --request GET 'api.microbooks.io/books/v1/reports/income-statement?format=html' ``` -------------------------------- ### GET account balances with PHP Guzzle client Source: https://docs.microbooks.io/docs/how-to-guides/accounts Uses Guzzle's Client to send a GET request. Requires a valid bearer token in the Authorization header. ```php $client = new Client(); $body = null; $request = new Request('GET', 'https://api.microbooks.io/books/v1/account/1/balances', [headers' => ['Authorization' => 'Bearer ']], $body ); $res = $client->sendAsync($request)->wait(); echo $res->getBody(); ``` -------------------------------- ### Create Input VAT Account with Python Source: https://docs.microbooks.io/docs/getting-started/quickstart/accounts Uses the requests library to POST the Input VAT account data. Prints the HTTP response text. ```python import requests url = "https://api.microbooks.io/books/v1/account" body = {"name": "Input VAT Account", "account_type": "CONTROL"} headers = {"Authorization": "Bearer "} response = requests.request("POST", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### C# request for Trial Balance report Source: https://docs.microbooks.io/docs/getting-started/quickstart/reports Use this C# script to fetch the Trial Balance report. It uses RestSharp to send a GET request and prints the response content. Replace with your token. ```csharp var client = new RestClient("https://api.microbooks.io/books/v1/reports/trial-balance"); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer " + ); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Get Clearances - PHP Source: https://docs.microbooks.io/docs/cookbook/transactions PHP code using Guzzle client to send a GET request to the clearances endpoint. It includes the Authorization header and prints the response body. ```php $client = new Client(); $body = '{}'; $request = new Request('GET', 'https://api.microbooks.io/books/v1/transaction/1/clearances', [headers' => ['Authorization' => 'Bearer ']], $body ); $res = $client->sendAsync($request)->wait(); echo $res->getBody(); ``` -------------------------------- ### Create Output VAT Account with PHP Source: https://docs.microbooks.io/docs/getting-started/quickstart/accounts Uses a Guzzle Client to send an asynchronous POST request with the Output VAT account body. Expects a Client class to be imported/available. ```php $client = new Client(); $body = '{ "name": "Output VAT Account", "account_type": "CONTROL" }'; $request = new Request('POST', 'https://api.microbooks.io/books/v1/account', [headers' => ['Authorization' => 'Bearer ']], $body ); $res = $client->sendAsync($request)->wait(); echo $res->getBody(); ``` -------------------------------- ### Get Clearances - Node.js Source: https://docs.microbooks.io/docs/cookbook/transactions Node.js code using the request module to fetch clearances. It makes a GET request to the endpoint with the Authorization header and logs the response body. ```javascript var request = require('request'); var options = { 'method': 'GET', 'url': 'https://api.microbooks.io/books/v1/transaction/1/clearances', 'headers': {'Authorization': 'Bearer '}, 'body': '{}' }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### Create Balance with Python requests Source: https://docs.microbooks.io/docs/how-to-guides/balances Uses the requests library to POST a balance creation request. The body includes the same parameters as the cURL example, and the response is printed. ```python import requests url = "https://api.microbooks.io/books/v1/balance" body = { "currency_id" : 2, "exchange_rate_id" : 1, "account_id" : 1, "reporting_period_id" : 2, "balance_type" : "DEBIT", "transaction_type" : "IN", "transaction_date" : "2021-10-21", "balance" : 100 } headers = {"Authorization": "Bearer "} response = requests.request("POST", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### PHP: Get Account Schedule Source: https://docs.microbooks.io/docs/cookbook/accounts Use this PHP script to call the Account Schedule endpoint. It creates a GET request with an Authorization header and echoes the response body. ```php $client = new Client(); $body = null; $request = new Request('GET', 'https://api.microbooks.io/books/v1/account/1/schedule', [headers' => ['Authorization' => 'Bearer ']], $body ); $res = $client->sendAsync($request)->wait(); echo $res->getBody(); ``` -------------------------------- ### Create Input VAT Account with C# Source: https://docs.microbooks.io/docs/getting-started/quickstart/accounts Uses RestClient to POST a raw body with the Input VAT account data. Sets timeout to -1 and adds the Authorization header. ```csharp var client = new RestClient("https://api.microbooks.io/books/v1/account"); client.Timeout = -1; var request = new RestRequest(Method.POST); var body = "{ \"name\": \"Input VAT Account\", \"account_type\": \"CONTROL\" }"; request.AddParameter("text/plain", body, ParameterType.RequestBody); request.AddHeader("Authorization", "Bearer " + ); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Python: Get Account Schedule Source: https://docs.microbooks.io/docs/cookbook/accounts Use this Python script to call the Account Schedule endpoint. It sends a GET request with an Authorization header and prints the response text. ```python import requests url = "https://api.microbooks.io/books/v1/account/1/schedule" body = {} headers = {"Authorization": "Bearer "} response = requests.request("GET", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### Response for Prepare Closing Transactions Source: https://docs.microbooks.io/docs/how-to-guides/reporting-periods Sample JSON response showing a successful preparation with a list of closing transactions. Each transaction includes details like transaction_type, narration, amount, and line_items. ```json { "status": "success", "closing_transactions": [ { "transaction_type": "JN", "transaction_date": "2022-12-31T00:00:00.000000Z", "account_id": 2, "narration": "EUR 2022 Forex Balance Translation", "reference": "EUR", "currency_id": 1, "transaction_no": "JN02/0001", "exchange_rate_id": 4, "entity_id": 1, "id": 3, "transaction_name": "Journal Entry", "is_posted": false, "is_credited": false, "amount": 1000, "tax": { "total": 0 }, "assignable": true, "clearable": true, "has_integrity": true, "line_items": [...], "clearances": [], "assignments": [] }, { "transaction_type": "JN", "transaction_date": "2022-12-31T00:00:00.000000Z", "account_id": 3, "narration": "GBP 2022 Forex Balance Translation", "reference": "GBP", "currency_id": 1, "transaction_no": "JN02/0002", "exchange_rate_id": 4, "entity_id": 1, "id": 4, "transaction_name": "Journal Entry", "is_posted": false, "is_credited": false, "amount": 1000, "tax": { "total": 0 }, "assignable": true, "clearable": true, "has_integrity": true, "line_items": [...], "clearances": [], "assignments": [] } ] } ``` -------------------------------- ### Get Transaction Assignments - C# Source: https://docs.microbooks.io/docs/cookbook/transactions Use this C# script to retrieve transaction assignments. It uses RestSharp to send a GET request with an Authorization header and prints the response content. ```csharp var client = new RestClient("https://api.microbooks.io/books/v1/transaction/1/assignments"); client.Timeout = -1; var request = new RestRequest(Method.GET); var body = null; request.AddParameter("text/plain", body, ParameterType.RequestBody); request.AddHeader("Authorization", "Bearer " + ); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Create COGS Account - C# Source: https://docs.microbooks.io/docs/getting-started/quickstart/accounts Uses RestClient to POST to /books/v1/account with OPERATING_EXPENSE type. Adds bearer token header and prints response content. ```csharp var client = new RestClient("https://api.microbooks.io/books/v1/account"); client.Timeout = -1; var request = new RestRequest(Method.POST); var body = "{ \"name\": \"COGS Account\", \"account_type\": \"OPERATING_EXPENSE\" }"; request.AddParameter("text/plain", body, ParameterType.RequestBody); request.AddHeader("Authorization", "Bearer " + ); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Create Bank Account Balance with Python Source: https://docs.microbooks.io/docs/getting-started/quickstart/balances POST a bank account balance using the requests library. Set the Authorization header with your bearer token and provide the account ID. Prints the response text. ```python import requests url = "https://api.microbooks.io/books/v1/balance" body = { "account_id": "", "balance_type": "DEBIT", "transaction_type": "JN", "transaction_date": "20XX-12-31", "balance": 100 } headers = {"Authorization": "Bearer "} response = requests.request("POST", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### Get Transaction Assignments - Python Source: https://docs.microbooks.io/docs/cookbook/transactions Use this Python script to fetch transaction assignments. It sends a GET request to the assignments endpoint with an Authorization header. Requires the 'requests' library. ```python import requests url = "https://api.microbooks.io/books/v1/transaction/1/assignments" body = {} headers = {"Authorization": "Bearer "} response = requests.request("GET", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### C#: Get Account Schedule Source: https://docs.microbooks.io/docs/cookbook/accounts Use this C# code to retrieve the account schedule. It uses RestClient to send a GET request with an Authorization header and prints the response content. ```csharp var client = new RestClient("https://api.microbooks.io/books/v1/account/1/schedule"); client.Timeout = -1; var request = new RestRequest(Method.GET); var body = null; request.AddParameter("text/plain", body, ParameterType.RequestBody); request.AddHeader("Authorization", "Bearer " + ); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Register account with Python Source: https://docs.microbooks.io/docs/getting-started/authentication/register Uses the requests library to POST the registration payload to the Microbooks API and prints the response. ```python import requests url = "https://api.microbooks.io/auth/v1/account" body = {"name": "John Doe", "email": "john.doe@example.com", "password": "securepassword"} headers = {} response = requests.request("POST", url, headers=headers, json=body) print(response.text) ``` -------------------------------- ### Get Account Movement with Curl Source: https://docs.microbooks.io/docs/cookbook/reports Use this Curl command to retrieve the account movement for a cashflow section. The endpoint is GET /books/v1/account/movement with section, start-date, and end-date query parameters. ```curl curl --location --request GET 'https://api.microbooks.io/books/v1/account/movement?section=ASSETS&start-date=2022-04-01&end-date=2022-04-30' ``` -------------------------------- ### POST /books/v1/discount Source: https://docs.microbooks.io/docs/how-to-guides/discounts Creates a new Discount resource. Requires the discount's name, code, rate, and the ID of its control account. ```APIDOC ## POST /books/v1/discount ### Description Creates a new Discount resource. The request body must include the discount's name, code, rate, and the ID of its control account. ### Method POST ### Endpoint api.microbooks.io/books/v1/discount ### Parameters #### Request Body - **name** (String) - Required - A label to identify the Discount. - **code** (String) - Required - A symbol/acronym to identify the Discount. - **rate** (Float) - Required - The rate of the Discount as a percentage. - **account_id** (Integer) - Required - The ID of the Discount's Control Account. ### Request Example { "name": "Trade Discount", "code": "SALE", "rate" : 10, "account_id" : 1 } ### Response #### Success Response (200) - **status** (String) - Status of the request. - **message** (String) - Success message. - **resource** (Object) - The created Discount resource. - **name** (String) - The discount name. - **code** (String) - The discount code. - **rate** (Float) - The discount rate. - **account_id** (Integer) - The ID of the control account. - **operations_discount** (Boolean) - Whether this is an operations discount. - **entity_id** (Integer) - The ID of the entity. - **id** (Integer) - The discount ID. - **account** (Object) - The associated account details. #### Response Example { "status": "success", "message": "Discount: Trade Discount (SALE) at 10.00% created successfully", "resource": { "name": "Trade Discount", "code": "SALE", "rate": 10, "account_id": 1, "operations_discount": false, "entity_id": 1, "id": 2, "account": { "uuid": "9bf98392-556e-4f68-8e92-3fcfef689f25", "id": 1, "entity_id": 1, "category_id": null, "currency_id": 1, "code": 2, "name": "Rick Schinner II", "description": null, "type": "Direct Expense", "is_closed": false } } } ### Errors - **100** - Orphaned Items - Cannot recycle the Discount Resource because it has dependent Resources. - **101** - Missing Entity - The Discount Resource requires an existing Entity because it is applied to Line Items used in Transactions, for the purpose of preparing Financial Statements which are scoped to an Entity. - **102** - Missing Applicable Account - The Discount Resource requires an Account of type `Account::CONTROL` to which the amounts charged by the Discount will be posted. - **103** - Invalid Acount Type - The Account type of the Account select for the Discount Resource must be `Account::CONTROL`. - **104** - Invalid Applicable Rate - A Discount with a rate of 0 is meaningless. ```