Planning

How to receive the current status of the problem via webhook?

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 to receive a request at each change of state in the processing of the problem.

This way you don’t have to check the status of the problem to see if it has been processed. The API will notify the webhook when the solution is available for consultation.

The following parameters are required:

  • url – URL with the address that will receive the callback.
  • user – (Optional) Text with the user name if the endpoint requires authentication.
  • password – (Optional) Password text if the endpoint requires authentication.

Below is an example of how the callback is used:

"callback": {
    "password": "nome_usuario",
    "url": "https://enqkbfcos3dhgchuikd.webhook.net",
    "user": "senha"
},

The HTTP method is a POST. The user and password information goes in headers user and password. A JSON will be sent with the format and fields below:

[{
    id: String,
    jobId: String,
    type: Enum (STATUS_CHANGE, ERROR, STEP_CHANGE, PERCENT_CHANGE, WARNING),
    description: String,
    createdAt: Date
}] 

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 "SOLVED", you can create a trigger to get the solution. Below is the list of all the states sent in:

1- Status ENQUEUED
    [0]
    createdAt: 1617034915185
    description: ENQUEUED
    jobId: 6061fea38031257fe109f0b7
    type: STATUS_CHANGE


    [1]
    createdAt: 1617034915255
    description: 1
    jobId: 6061fea38031257fe109f0b7
    type: PERCENT_CHANGE
 
2-Status CONVERT_TO_MATRIX
    [0]
    createdAt: 1617034915164
    description: CONVERT_TO_MATRIX
    jobId: 6061fea38031257fe109f0b7
    type: STATUS_CHANGE
 
3- Status PROCESSING
    [0]
    createdAt: 1617034915335
    description: PROCESSING
    jobId: 6061fea38031257fe109f0b7
    type: STATUS_CHANGE
 
4- Status MATRIX_CALCULATION
    [0]
    createdAt: 1617034915608
    description: MATRIX_CALCULATION
    jobId: 6061fea38031257fe109f0b7
    type: STATUS_CHANGE
 
5- Status progress 60%
    [0]
    createdAt: 1617034916863
    description: progress 60%
    jobId: 6061fea38031257fe109f0b7
    type: STEP_CHANGE


6- Status CALCULATE_PLANNING
    [0]
    createdAt: 1617034917633
    description: CALCULATE_PLANNING
    jobId: 6061fea38031257fe109f0b7
    type: STATUS_CHANGE


    [1]
    createdAt: 1617034917740
    description: 60
    jobId: 6061fea38031257fe109f0b7
    type: PERCENT_CHANGE
 
7- Status PRE_TREATMENTS
    [0]
    createdAt: 1617034918058
    description: PRE_TREATMENTS
    jobId: 6061fea38031257fe109f0b7
    type: STEP_CHANGE
 
8- Status INITIAL_CONSTRUCTION
    [0]
    createdAt: 1617034918207
    description: INITIAL_CONSTRUCTION
    jobId: 6061fea38031257fe109f0b7
    type: STEP_CHANGE
 
9- Status IMPROVEMENT
    [0]
    createdAt: 1617034918346
    description: IMPROVEMENT
    jobId: 6061fea38031257fe109f0b7
    type: STEP_CHANGE
 
10- Status POST_TREATMENTS
    [0]
    createdAt: 1617034918535
    description: POST_TREATMENTS
    jobId: 6061fea38031257fe109f0b7
    type: STEP_CHANGE
 
11- Status SOLVED
    [0]
    createdAt: 1617034918777
    description: SOLVED
    jobId: 6061fea38031257fe109f0b7
    type: STATUS_CHANGE


    [1]
    createdAt: 1617034918885
    description: 100
    jobId: 6061fea38031257fe109f0b7
    type: PERCENT_CHANGE


    [2]
    createdAt: 1617034918992
    description: TERMINATE
    jobId: 6061fea38031257fe109f0b7
    type: STEP_CHANGE