{"id":3779,"date":"2021-01-14T17:51:22","date_gmt":"2021-01-14T15:51:22","guid":{"rendered":"https:\/\/modulus.help\/kb\/docs\/documentation\/bookkeeping-module-apis\/api-create-journal\/"},"modified":"2021-02-17T13:30:34","modified_gmt":"2021-02-17T11:30:34","slug":"api-create-journal","status":"publish","type":"docs","link":"https:\/\/modulus.help\/kb\/docs\/documentation\/bookkeeping-apis-v1\/api-create-journal\/","title":{"rendered":"API: Create Journal"},"content":{"rendered":"<p>The purpose of this API is to create new journal.<\/p>\n<h4>Request<\/h4>\n<table style=\"width: auto;\">\n<tbody>\n<tr>\n<th style=\"text-align: left;\">URL<\/th>\n<td>https:\/\/your_account.modulus.biz\/api\/bk\/v1\/CreateJournal?token=YOUR_TOKEN<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">API Name<\/th>\n<td>CreateJournal<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">Method<\/th>\n<td>POST<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">Source<\/th>\n<td>Third Party Server<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">Recipient<\/th>\n<td>modulus\u00ae Server<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">Content Type<\/th>\n<td>application\/json<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Query String Parameters<\/h4>\n<table style=\"width: auto\">\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Required<\/th>\n<th>Type<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th style=\"text-align:left;\">token<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>Your authentication token.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Payload Parameters<\/h4>\n<table style=\"width: auto;\">\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Required<\/th>\n<th>Type<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th style=\"text-align: left;\">date<\/th>\n<td>Yes<\/td>\n<td>Date<\/td>\n<td>Date format must be ISO 8601 <span style=\"font-size: 0.7rem; color: grey;\"> (Example: &#8220;2020-01-10&#8221;) <\/span><br \/>\n                Has to be in an open fiscal period.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">financial_book_id<\/th>\n<td>No<\/td>\n<td>Number<\/td>\n<td>Refers to the financial book to which this journal will be posted.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">journal_notes<\/th>\n<td>No<\/td>\n<td>Text<\/td>\n<td>Journal notes if any.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">reference_number<\/th>\n<td>No<\/td>\n<td>Text<\/td>\n<td>Journal reference number.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">journal_entries<\/th>\n<td>Yes<\/td>\n<td>Array<\/td>\n<td>An array that contains at least two entries.<br \/>\n                Credit amount must be equal to Debit amount.<br \/>\n                Journal entries have the structure explained <a href=\"#journalEntries\">here<\/a>.\n            <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"journalEntries\">Journal Entry Parameter Detials<\/h4>\n<table style=\"width:auto;\">\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Required<\/th>\n<th>Type<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th style=\"text-align: left;\">account_code<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>Has to match a non-disabled leaf account in CoA.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">cost_center_id<\/th>\n<td>No<\/td>\n<td>Number<\/td>\n<td>An integer that can be used with revenue \/ expense entries to indicate the cost center to which the JV is posted.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">journal_entry_notes<\/th>\n<td>No<\/td>\n<td>Text<\/td>\n<td>Journal entry notes if any.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">base_currency_debit_amount<\/th>\n<td>Yes<\/td>\n<td>Decimal Number<\/td>\n<td>Has to be equal to credit amount.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">foreign_currency_debit_amount<\/th>\n<td>No<\/td>\n<td>Decimal Number<\/td>\n<td>Used in case of foreign currency transaction.<br \/>\n                In case used, has to be of same value as foreign currency credit amount.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">base_currency_credit_amount<\/th>\n<td>Yes<\/td>\n<td>Decimal Number<\/td>\n<td>Has to be equal to debit amount.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">foreign_currency_credit_amount<\/th>\n<td>No<\/td>\n<td>Decimal Number<\/td>\n<td>Used in case of foreign currency transaction.<br \/>\n                In case used, has to be of same value as foreign currency debit amount.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">foreign_currency<\/th>\n<td>No<\/td>\n<td>text<\/td>\n<td>Used in case of foreign currency transaction.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Responses<\/h4>\n<table style=\"width: auto;\">\n<thead>\n<tr>\n<th>HTTP Status<\/th>\n<th>result<\/th>\n<th>title<\/th>\n<th>message<\/th>\n<th>object<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th colspan=\"5\">Success Responses<\/th>\n<\/tr>\n<tr>\n<td>200 OK<\/td>\n<td>true<\/td>\n<td>Success<\/td>\n<td>New journal crated successfully.<\/td>\n<td>\n<pre><code class=\"json\">{\r\n    \"created_journal_id\": xxx,\r\n    \"created_date_time\": \"yyy-mm-dd hh:MM:ss\"\r\n}<\/code><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<th colspan=\"5\">Failure Responses<\/th>\n<\/tr>\n<tr>\n<td>400 Bad Request<\/td>\n<td>false<\/td>\n<td>Bad Request<\/td>\n<td>Error message as elaborated <a href=\"https:\/\/modulus.help\/kb\/docs\/documentation\/bookkeeping-apis-v1\/error-codes\/\" target=\"_blank\">here<\/a>.<\/td>\n<td>\n<pre><code class=\"json\">{\r\n    \"error_code\": xxx\r\n}<\/code><\/pre>\n<p>Error code as elaborated <a href=\"https:\/\/modulus.help\/kb\/docs\/documentation\/bookkeeping-apis-v1\/error-codes\/\" target=\"_blank\">here<\/a>.<\/td>\n<\/tr>\n<tr>\n<td>500 Internal Server Error<\/td>\n<td>false<\/td>\n<td>Internal Server Error<\/td>\n<td>Error message as elaborated <a href=\"https:\/\/modulus.help\/kb\/docs\/documentation\/bookkeeping-apis-v1\/error-codes\/\" target=\"_blank\">here<\/a>.<\/td>\n<td>\n<pre><code class=\"json\">{\r\n    \"error_code\": xxx\r\n}<\/code><\/pre>\n<p>Error code as elaborated <a href=\"https:\/\/modulus.help\/kb\/docs\/documentation\/bookkeeping-apis-v1\/error-codes\/\" target=\"_blank\">here<\/a>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Example 1<\/h4>\n<table style=\"width: auto;\">\n<tbody>\n<tr>\n<th>Request<\/th>\n<td>\n<pre><code class=\"json\">curl <span style=\"white-space: nowrap;\">--request POST 'https:\/\/your_account.modulus.biz\/api\/bk\/v1\/CreateJournal?token=YOUR_TOKEN' \\<\/span>\r\n--header 'Content-Type: application\/json' \\\r\n--data-raw '{\r\n    \"date\": \"2020-01-02\",\r\n    \"financial_book_id\":null,\r\n    \"journal_notes\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\",\r\n    \"reference_number\": \"AJ-23-mn\",\r\n    \"journal_entries\": [\r\n        {\r\n            \"account_code\": \"1.3\",\r\n            \"cost_center_id\": null,\r\n            \"journal_entry_notes\": \"Ut labore et dolore magna aliqua.\",\r\n            \"base_currency_debit_amount\": 100.00,\r\n            \"foreign_currency_debit_amount\": 100.00,\r\n            \"base_currency_credit_amount\": 0.00,\r\n            \"foreign_currency_credit_amount\": 0.00,\r\n            \"foreign_currency\": \"EGP\"\r\n        },\r\n        {\r\n            \"account_code\": \"1.4.2.1\",\r\n            \"cost_center_id\":null,\r\n            \"journal_entry_notes\": \"Sed do eiusmod tempor incididunt.\",\r\n            \"base_currency_debit_amount\": 0.00,\r\n            \"foreign_currency_debit_amount\": 0.00,\r\n            \"base_currency_credit_amount\": 100.00,\r\n            \"foreign_currency_credit_amount\": 100.00,\r\n            \"foreign_currency\": \"\"\r\n        }\r\n    ]\r\n}'<\/code><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<th>200 OK<\/th>\n<td>\n<pre><code class=\"json\">{\r\n\"result\": true,\r\n\"title\": \"Success\",\r\n\"message\": \"New journal created successfully.\",\r\n\"object\": {\r\n        \"created_journal_id\": 3439,\r\n        \"created_date_time\": \"2021-01-14 19:59:22\"\r\n    }\r\n}<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Example 2<\/h4>\n<table style=\"width: auto;\">\n<tbody>\n<tr>\n<th>Request<\/th>\n<td>\n<pre><code class=\"json\">curl <span style=\"white-space: nowrap;\">--request POST 'https:\/\/your_account.modulus.biz\/api\/bk\/v1\/CreateJournal?token=ddd871b104153e1da4c10713ec691d77' \\<\/span>\r\n--header 'Content-Type: application\/json' \\\r\n--data-raw '{\r\n    \"date\": \"2020-10-02\",\r\n    \"financial_book_id\":null,\r\n    \"journal_notes\": \"Sit amet nisl suscipit adipiscing bibendum.\",\r\n    \"reference_number\": \"AJ-23-mn-87\",\r\n    \"journal_entries\": [\r\n        {\r\n            \"cost_center_id\": null,\r\n            \"journal_entry_notes\": \"Nulla facilisi etiam dignissim diam quis.\",\r\n            \"base_currency_debit_amount\": 100.00,\r\n            \"foreign_currency_debit_amount\": 100.00,\r\n            \"base_currency_credit_amount\": 0.00,\r\n            \"foreign_currency_credit_amount\": 0.00,\r\n            \"foreign_currency\": \"EGP\"\r\n        },\r\n        {\r\n            \"account_code\": \"1.4.2.1\",\r\n            \"cost_center_id\":null,\r\n            \"journal_entry_notes\": \"Sed velit dignissim sodales ut eu sem integer.\",\r\n            \"base_currency_debit_amount\": 0.00,\r\n            \"foreign_currency_debit_amount\": 0.00,\r\n            \"base_currency_credit_amount\": 100.00,\r\n            \"foreign_currency_credit_amount\": 100.00,\r\n            \"foreign_currency\": \"\"\r\n        }\r\n    ]\r\n}'<\/code><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<th>400 Bad Request<\/th>\n<td>\n<pre><code class=\"json\">{\r\n    \"result\": false,\r\n    \"title\": \"Bad Request\",\r\n    \"message\": \"Failed to create new journal. Missing account code for journal entry.\",\r\n    \"object\": {\r\n        \"error_code\": 1241\r\n    }\r\n}<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"featured_media":0,"parent":3778,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"comment_count":0,"_links":{"self":[{"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/3779"}],"collection":[{"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/comments?post=3779"}],"version-history":[{"count":47,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/3779\/revisions"}],"predecessor-version":[{"id":3956,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/3779\/revisions\/3956"}],"up":[{"embeddable":true,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/3778"}],"next":[{"title":"API: Update Journal","link":"https:\/\/modulus.help\/kb\/docs\/documentation\/bookkeeping-apis-v1\/api-update-journal\/","href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/3783"}],"prev":[{"title":"Error Codes","link":"https:\/\/modulus.help\/kb\/docs\/documentation\/bookkeeping-apis-v1\/error-codes\/","href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/3868"}],"wp:attachment":[{"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/media?parent=3779"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/doc_tag?post=3779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}