{"id":1742,"date":"2025-05-13T10:48:50","date_gmt":"2025-05-13T07:48:50","guid":{"rendered":"https:\/\/moito.com\/blog\/?p=1742"},"modified":"2025-05-13T10:49:58","modified_gmt":"2025-05-13T07:49:58","slug":"erpnext-how-to-change-sales-order-status-to-closed-through-rest-api-after-submit","status":"publish","type":"post","link":"https:\/\/moito.com\/blog\/erpnext-how-to-change-sales-order-status-to-closed-through-rest-api-after-submit\/","title":{"rendered":"ERPNext How to change Sales order status to Closed through rest API after submit"},"content":{"rendered":"\n<p>You cannot simply send an update request for a document and change its status to &#8220;Closed&#8221; in ERPNext.<\/p>\n\n\n\n<p>In order to change the status of already submitted document to &#8220;Closed&#8221; you need to call the API: <strong>\/api\/method\/erpnext.selling.doctype.sales_order.sales_order.close_or_unclose_sales_orders<\/strong><\/p>\n\n\n\n<p>You can use <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-medium-orange-color\">POST<\/mark><\/strong> call to the API as follow:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-light-orange-color\">https:\/\/{ERPURL}\/api\/method\/erpnext.selling.doctype.sales_order.sales_order.close_or_unclose_sales_orders?names=&#91;\u201cSO25000008\u201d]&amp;status=Closed<\/mark>\n<\/code><\/pre>\n\n\n\n<p>or using the following Python code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import requests\nheaders = {\n    \"Authorization\": f\"token {API_KEY}:{API_SECRET}\",\n    \"Content-Type\": \"application\/json\",\n}\nurl = f\"{ERP_URL}\/api\/method\/erpnext.selling.doctype.sales_order.sales_order.close_or_unclose_sales_orders?names=&#91;\\\"{name}\\\"]&amp;status=Closed\"\n\nresponse = requests.post(url,  headers=headers) \n\nprint(response.status_code)<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>You cannot simply send an update request for a document and change its status to &#8220;Closed&#8221; in ERPNext. In order to change the status of already submitted document to &#8220;Closed&#8221; you need to call the API: \/api\/method\/erpnext.selling.doctype.sales_order.sales_order.close_or_unclose_sales_orders You can use POST call to the API as follow: or using the following Python code:<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1012,7],"tags":[823,1047,1044,1051,1043,1013,1045,808,1046,1050,1048,1049],"class_list":["post-1742","post","type-post","status-publish","format-standard","hentry","category-erpnext","category-it","tag-api","tag-api-call","tag-close","tag-close-document","tag-close_or_unclose_sales_orders","tag-erpnext","tag-order","tag-python","tag-sales-order","tag-status-change","tag-submitted","tag-submitted-document"],"_links":{"self":[{"href":"https:\/\/moito.com\/blog\/wp-json\/wp\/v2\/posts\/1742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/moito.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/moito.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/moito.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/moito.com\/blog\/wp-json\/wp\/v2\/comments?post=1742"}],"version-history":[{"count":4,"href":"https:\/\/moito.com\/blog\/wp-json\/wp\/v2\/posts\/1742\/revisions"}],"predecessor-version":[{"id":1746,"href":"https:\/\/moito.com\/blog\/wp-json\/wp\/v2\/posts\/1742\/revisions\/1746"}],"wp:attachment":[{"href":"https:\/\/moito.com\/blog\/wp-json\/wp\/v2\/media?parent=1742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/moito.com\/blog\/wp-json\/wp\/v2\/categories?post=1742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/moito.com\/blog\/wp-json\/wp\/v2\/tags?post=1742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}