{"id":4110,"date":"2024-04-04T16:04:06","date_gmt":"2024-04-04T14:04:06","guid":{"rendered":"https:\/\/modulus.help\/kb\/?post_type=docs&#038;p=4110"},"modified":"2025-02-25T13:37:58","modified_gmt":"2025-02-25T11:37:58","slug":"api-create-credit-note","status":"publish","type":"docs","link":"https:\/\/modulus.help\/kb\/docs\/documentation\/invoicing-v1\/api-create-credit-note\/","title":{"rendered":"API: Create Credit Note"},"content":{"rendered":"<p>The purpose of this API is to create new credit note.<\/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\/inv\/v1\/CreditNote?token=YOUR_TOKEN<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">API Name<\/th>\n<td>CreditNote<\/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;\">customer_details<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>Refers to customer info the credit note issued to. The structure explained <a href=\"#customer_details\" data-type=\"docs\" data-id=\"4110\">here<\/a>.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">branch_code<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>The code of an active branch.<\/td>\n<\/tr>\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 (Example: \u201c2020-01-10\u201d).<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">book_id<\/th>\n<td>Yes<\/td>\n<td>Number<\/td>\n<td>Refers to invoice book used for the credit note. Must be For Credit Note.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">status<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>May be STATUS_DRAFT or STATUS_SENT.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">salesperson_id<\/th>\n<td>No<\/td>\n<td>Number<\/td>\n<td>Refers to salesperson linked to the branch of this Credit Note.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">exchange_rate<\/th>\n<td>No<\/td>\n<td>Decimal Number<\/td>\n<td>The exchange rate when the credit note is issued. Mandatory if the customer has foreign currency.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">reference<\/th>\n<td>No<\/td>\n<td>Text<\/td>\n<td>Credit Note reference.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">description<\/th>\n<td>No<\/td>\n<td>Text<\/td>\n<td>Credit Note description.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">items<\/th>\n<td>Yes<\/td>\n<td>Array<\/td>\n<td>An array that contains at least one item. The structure explained <a href=\"#items_details\">here<\/a>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"items_details\">Item Parameter Details<\/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;\">item_code<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>Item code.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">unit_id<\/th>\n<td>Yes<\/td>\n<td>Number<\/td>\n<td>Refer to the unit of the sent quantity.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">quantity<\/th>\n<td>Yes<\/td>\n<td>Decimal<\/td>\n<td>Number The quantity of the item can not be less than or equal to 0.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">unit_price<\/th>\n<td>No<\/td>\n<td>Decimal<\/td>\n<td>Number The price of the item. If not sent will defined price in the customer or branch default price list.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"customer_details\">Customer Parameter Details<\/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;\">code<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>The code of the customer the credit note is issued to.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">name<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>The name of the customer the credit note is issued to.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">type<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>The type of the customer the credit note is issued to. Possible values are: (individual\/organization).<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">tax_registration_number<\/th>\n<td>No<\/td>\n<td>Number<\/td>\n<td>Customer&#8217;s Tax Registration Number.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">account_code<\/th>\n<td>No<\/td>\n<td>Text<\/td>\n<td>The code of the cash account of the customer.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">price_list_code (for counter parties of type customer)<\/th>\n<td>No<\/td>\n<td>Number<\/td>\n<td>The code of the price list of the customer. It must have the same currency as the customer and account.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">address<\/th>\n<td>No<\/td>\n<td>Object<\/td>\n<td>The address of the customer. The structure is explained <a href=\"#address_details\">here<\/a>.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">contact<\/th>\n<td>No<\/td>\n<td>Object<\/td>\n<td>The contact of the customer. The structure is explained <a href=\"#contact_details\">here<\/a>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"address_details\">Address Parameter Details<\/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;\">label<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>The label of the address.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">country_code<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>The country code of the address (Example: &#8220;EG&#8221;).<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">city<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>The name of the city in the specified country.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">address<\/th>\n<td>No<\/td>\n<td>Text<\/td>\n<td>Additional info of the address.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"contact_details\">Contact Parameter Details<\/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;\">type<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>The type of the contact provided, possible values are: (mobile\/phone\/email\/fax\/website\/other).<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">label<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>The label of the contact.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: left;\">value<\/th>\n<td>Yes<\/td>\n<td>Text<\/td>\n<td>The value of the contact.<\/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>Credit Note added successfully.<\/td>\n<td>\n<pre><code class=\"json\">{\n    \"credit_note_id\": xxx,\n    \"credit_note_serial\": \"YYY_ZZZZ\",\n    \"document_type\": \"Credit Note\",\n    \"creation_date_time\": \"yyy-mm-dd hh:MM:ss\"\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>Error<\/td>\n<td>Error message as elaborated here.<\/td>\n<td>\n<pre><code class=\"json\">{\n    \"error_code\": xxx\n}<\/code><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<td>500 Internal Server Error<\/td>\n<td>false<\/td>\n<td>Error<\/td>\n<td>Error message as elaborated here.<\/td>\n<td>\n<pre><code class=\"json\">{\n    \"error_code\": xxx\n}<\/code><\/pre>\n<\/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 --request POST 'https:\/\/your_account.modulus.biz\/api\/inv\/v1\/CreditNote=YOUR_TOKEN' \\\n--header 'Content-Type: application\/json' \\\n--data-raw '{ \n    \"customer_details\":{ \n        \"code\":\"1\",\n        \"name\":\"Test name\",\n        \"type\": \"individual\",\n        \"account_code\":\"1.6.10.2\",\n        \"price_list_code\":\"1\",\n        \"tax_registration_number\":\"1\",\n        \"contact\": {\n            \"type\": \"mobile\",\n            \"label\": \"\u0627\u0644\u0642\u0627\u0647\u0631\u0629 \u0627\u0644\u062c\u062f\u064a\u062f\u0629\",\n            \"value\": \"0102224791\"\n        },\n        \"address\": {\n            \"label\": \"HEADOFFICE\",\n            \"country_code\": \"EG\",\n            \"city\": \"Alexandria\",\n            \"address\": \"Test Address\"\n        }\n    }, \n    \"branch_code\": \"2\",\n    \"date\": \"2024-01-15\",\n    \"book_id\": 1,\n    \"status\": \"STATUS_DRAFT\",\n    \"items\": [\n        {\n            \"item_code\": \"451\",\n            \"unit_id\": 3,\n            \"quantity\": 50,\n            \"unit_price\": 100\n        }\n    ] \n}'<\/code><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<th>200 OK<\/th>\n<td>\n<pre><code class=\"json\">{\n    \"result\": true,\n    \"title\": \"Success\",\n    \"message\": \"Credit Note added successfully.\",\n    \"object\": {\n        \"credit_note_id\": 3439,\n        \"credit_note_serial\": \"CR_2024_01_15_03\",\n        \"document_type\": \"Credit Note\",\n        \"creation_date_time\": \"2023-01-14 00:09:00\"\n    }\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 --request POST 'https:\/\/your_account.modulus.biz\/api\/inv\/v1\/CreditNote=YOUR_TOKEN' \\\n--header 'Content-Type: application\/json' \\\n--data-raw '{ \n    \"customer_details\":{ \n        \"code\":\"1\",\n        \"name\":\"Test name\",\n        \"type\": \"individual\",\n        \"account_code\":\"1.6.10.2\",\n        \"price_list_code\":\"1\",\n        \"tax_registration_number\":\"1\",\n        \"contact\": {\n            \"type\": \"mobile\",\n            \"label\": \"\u0627\u0644\u0642\u0627\u0647\u0631\u0629 \u0627\u0644\u062c\u062f\u064a\u062f\u0629\",\n            \"value\": \"0102224791\"\n        },\n        \"address\": {\n            \"label\": \"HEADOFFICE\",\n            \"country_code\": \"EG\",\n            \"city\": \"Alexandria\",\n            \"address\": \"Test Address\"\n        }\n    }, \n    \"branch_code\": \"2\",\n    \"date\": \"2024-03-01\",\n    \"book_id\": 1,\n    \"status\": \"STATUS_SENT\",\n    \"reference\": \"CR-0883\",\n    \"items\": [\n        {\n            \"item_code\": \"6\",\n            \"unit_id\": 2,\n            \"unit_price\": 100\n        }\n    ] \n}'<\/code><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<th>400 Bad Request<\/th>\n<td>\n<pre><code class=\"json\">{\n    \"result\": false,\n    \"title\": \"Error\",\n    \"message\": \"Missing code, unit or quantity in item row with index 0.\",\n    \"object\": {\n        \"error_code\": xxx\n    }\n}<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"featured_media":0,"parent":4104,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"comment_count":0,"_links":{"self":[{"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/4110"}],"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=4110"}],"version-history":[{"count":16,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/4110\/revisions"}],"predecessor-version":[{"id":4396,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/4110\/revisions\/4396"}],"up":[{"embeddable":true,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/4104"}],"next":[{"title":"API: Create Collection Receipt","link":"https:\/\/modulus.help\/kb\/docs\/documentation\/invoicing-v1\/api-create-collection-receipt\/","href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/4113"}],"prev":[{"title":"API: Create Invoice","link":"https:\/\/modulus.help\/kb\/docs\/documentation\/invoicing-v1\/api-create-invoice\/","href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/4105"}],"wp:attachment":[{"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/media?parent=4110"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/doc_tag?post=4110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}