# Run a Process API calculation

Note: The time to run a calculation using the OLI Process API cannot be predicted accurately and also some calculations may take longer to compute than others. Hence, a polling mechanism is required to retrieve the result of each calculation. The steps for this mechanism are described below.

1. Send a **POST** request to the run URL below
2. If the request was successful(status:200), the JSON response back will contain a link to the results and status of the computation. The status inside the ***"data"*** array will be **IN QUEUE/IN PROGRESS**
3. Keep polling the returned results link with a **GET** request until the status member of the response changes from **IN PROGRESS to PROCESSED/FAILED/ERROR or COMPLETED**
4. When the status is **COMPLETED**, then response will also contain the result of the computation

###

## Run the selected process

<mark style="color:green;">`POST`</mark> `https://api.olisystems.com/process/run/{process_id}`

The input to run the calculation is provided in the body of the message as JSON, the input is  the data.flowsheet.properties object retrieved using the [Get input specs for Process API package](/group2/get-input-specs-for-process-api-package.md) call.

#### Headers

| Name          | Type   | Description            |
| ------------- | ------ | ---------------------- |
| Authorization | string | Bearer {access\_token} |
| Content-Type  | string | application/json       |

#### Request Body

| Name                               | Type | Description                                         |
| ---------------------------------- | ---- | --------------------------------------------------- |
| <mark style="color:red;">\*</mark> | JSON | <p>{ "properties" : { "input" " { ...}}}</p><p></p> |

{% tabs %}
{% tab title="200 " %}

```
{
	"code": 200,
	"data": {
		"file_id": "dee854a6-59db-487d-ad08-a20dee691133",
		"jobId": "f6b3375e-cd0f-4ace-a5ee-71e047b76754",
		"resultsLink": "https://api.olisystems.com/result/flash/f6b3375e-cd0f-4ace-a5ee-71e047b76754?context=engine",
		"status": "IN PROGRESS"
	},
	"message": "Process execution started Successfully",
	"status": "SUCCESS"
}
```

{% endtab %}
{% endtabs %}

### Response description

| field            | description                                                                                |
| ---------------- | ------------------------------------------------------------------------------------------ |
| data.jobId       | the current request job identifier                                                         |
| data.processId   | the processId used for the job being run                                                   |
| data.resultsLink | the https endpoint to poll to get the final result                                         |
| data.status      | <p>current status of the job<br><strong>IN QUEUE</strong>/<strong>IN PROGRESS</strong></p> |
| message          | message describing the request                                                             |
| status           | status of the current request, can be **SUCCESS** or **FAILED**                            |

```json
// Response from process-run call
{
    "data": {
        "jobId": "20978bbb-5f88-4ecd-ae90-582953afdedf",
        "processId": "a5c645fe-578b-4a48-a541-3d818d4ef564",
        "resultsLink": "https://api.olisystems.com/result/20978bbb-5f88-4ecd-ae90-582953afdedf?flash=&count=20",
        "status": "IN QUEUE"
    },
    "message": "Process execution started Successfully",
    "status": "SUCCESS"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devdocs.olisystems.com/group2/api-call-blueprint.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
