{"id":2497,"date":"2023-12-12T19:25:37","date_gmt":"2023-12-12T19:25:37","guid":{"rendered":"https:\/\/developers.maplink.global\/how-to-receive-the-current-status-of-the-problem-via-webhook\/"},"modified":"2024-02-28T13:22:00","modified_gmt":"2024-02-28T13:22:00","slug":"how-to-receive-the-current-status-of-the-problem-via-webhook","status":"publish","type":"post","link":"https:\/\/developers.maplink.global\/en\/how-to-receive-the-current-status-of-the-problem-via-webhook\/","title":{"rendered":"How to receive the current status of the problem via webhook?"},"content":{"rendered":"\n<p>The Planning API works <strong>asynchronously <\/strong>. This means that when a problem is sent, an ID is returned and through this ID it will be possible to consult the current state of processing and, when completed, the solution to the problem.<\/p>\n\n<p>Using the parameter <code>callback<\/code> in the request to Planning, you can inform a <em>webhook<strong> <\/strong><\/em>to receive a request at each change of state in the processing of the problem.<\/p>\n\n<p>This way you don&#8217;t have to check the status of the problem to see if it has been processed. The API will notify the <em>webhook <\/em>when the solution is available for consultation.<\/p>\n\n<p>The following parameters are required:<\/p>\n\n<ul class=\"wp-block-list\">\n<li><code>url<\/code>  &#8211; URL with the address that will receive the <em>callback<\/em>.<\/li>\n\n\n\n<li><code>user<\/code>  &#8211; (Optional) Text with the user name if the endpoint requires authentication<em>.<\/em><\/li>\n\n\n\n<li><code>password<\/code>  &#8211; (Optional) Password text if the endpoint requires authentication.<\/li>\n<\/ul>\n\n<p>Below is an example of how the callback is used:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\"callback\": {\n    \"password\": \"nome_usuario\",\n    \"url\": \"https:\/\/enqkbfcos3dhgchuikd.webhook.net\",\n    \"user\": \"senha\"\n},<\/pre>\n\n<p>The HTTP method is a POST. The user and password information goes in headers <code>user<\/code> and <code>password<\/code>. A JSON will be sent with the format and fields below:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[{\n    id: String,\n    jobId: String,\n    type: Enum (STATUS_CHANGE, ERROR, STEP_CHANGE, PERCENT_CHANGE, WARNING),\n    description: String,\n    createdAt: Date\n}] <\/pre>\n\n<p>The callback will send data with each change in the processing state. The Planning API callback will send each state along with the problem ID in the body. Thus, once the status <strong><code>\"SOLVED\"<\/code><\/strong>, you can create a trigger to get the solution. Below is the list of all the states sent in:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">1- Status ENQUEUED\n    [0]\n    createdAt: 1617034915185\n    description: ENQUEUED\n    jobId: 6061fea38031257fe109f0b7\n    type: STATUS_CHANGE\n\n\n    [1]\n    createdAt: 1617034915255\n    description: 1\n    jobId: 6061fea38031257fe109f0b7\n    type: PERCENT_CHANGE\n \n2-Status CONVERT_TO_MATRIX\n    [0]\n    createdAt: 1617034915164\n    description: CONVERT_TO_MATRIX\n    jobId: 6061fea38031257fe109f0b7\n    type: STATUS_CHANGE\n \n3- Status PROCESSING\n    [0]\n    createdAt: 1617034915335\n    description: PROCESSING\n    jobId: 6061fea38031257fe109f0b7\n    type: STATUS_CHANGE\n \n4- Status MATRIX_CALCULATION\n    [0]\n    createdAt: 1617034915608\n    description: MATRIX_CALCULATION\n    jobId: 6061fea38031257fe109f0b7\n    type: STATUS_CHANGE\n \n5- Status progress 60%\n    [0]\n    createdAt: 1617034916863\n    description: progress 60%\n    jobId: 6061fea38031257fe109f0b7\n    type: STEP_CHANGE\n\n\n6- Status CALCULATE_PLANNING\n    [0]\n    createdAt: 1617034917633\n    description: CALCULATE_PLANNING\n    jobId: 6061fea38031257fe109f0b7\n    type: STATUS_CHANGE\n\n\n    [1]\n    createdAt: 1617034917740\n    description: 60\n    jobId: 6061fea38031257fe109f0b7\n    type: PERCENT_CHANGE\n \n7- Status PRE_TREATMENTS\n    [0]\n    createdAt: 1617034918058\n    description: PRE_TREATMENTS\n    jobId: 6061fea38031257fe109f0b7\n    type: STEP_CHANGE\n \n8- Status INITIAL_CONSTRUCTION\n    [0]\n    createdAt: 1617034918207\n    description: INITIAL_CONSTRUCTION\n    jobId: 6061fea38031257fe109f0b7\n    type: STEP_CHANGE\n \n9- Status IMPROVEMENT\n    [0]\n    createdAt: 1617034918346\n    description: IMPROVEMENT\n    jobId: 6061fea38031257fe109f0b7\n    type: STEP_CHANGE\n \n10- Status POST_TREATMENTS\n    [0]\n    createdAt: 1617034918535\n    description: POST_TREATMENTS\n    jobId: 6061fea38031257fe109f0b7\n    type: STEP_CHANGE\n \n11- Status SOLVED\n    [0]\n    createdAt: 1617034918777\n    description: SOLVED\n    jobId: 6061fea38031257fe109f0b7\n    type: STATUS_CHANGE\n\n\n    [1]\n    createdAt: 1617034918885\n    description: 100\n    jobId: 6061fea38031257fe109f0b7\n    type: PERCENT_CHANGE\n\n\n    [2]\n    createdAt: 1617034918992\n    description: TERMINATE\n    jobId: 6061fea38031257fe109f0b7\n    type: STEP_CHANGE<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The Planning API works asynchronously . This means that when a problem is sent, an ID is returned and through this ID it will be possible to consult the current state of processing and, when completed, the solution to the problem. Using the parameter callback in the request to Planning, you can inform a webhook [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[160],"tags":[],"class_list":["post-2497","post","type-post","status-publish","format-standard","hentry","category-planning-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/comments?post=2497"}],"version-history":[{"count":7,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2497\/revisions"}],"predecessor-version":[{"id":2505,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2497\/revisions\/2505"}],"wp:attachment":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/media?parent=2497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/categories?post=2497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/tags?post=2497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}