> For the complete documentation index, see [llms.txt](https://docs.roboteasy.tech/orquestrador/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboteasy.tech/orquestrador/geral/integracoes-via-api/executar-robos-e-runtimes.md).

# Executar Robôs e Runtimes

Lista de APIs disponíveis para execução de robôs e manipulação de filas de execução.

## Executar robô (com parâmetros)

<mark style="color:green;">`POST`</mark> `https://app.rpaidea.com/api/integration/v1/run/{ID_COMPUTER}/{ID_BOT}`

Start de execução de forma assíncrona do robô no runtime indicado, retornando o id da execução para futura requisição do resultado.

#### Headers

| Name                                            | Type   | Description              |
| ----------------------------------------------- | ------ | ------------------------ |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer {RESULT-OF-LOGIN} |
| Content-Type<mark style="color:red;">\*</mark>  | string | application/json         |
| x-api-key<mark style="color:red;">\*</mark>     | String | {token}                  |

#### Request Body

| Name | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                          |
| ---- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|      | object | <p>{<br>    "<strong>variables</strong>": \[ <br>        {<br>            "<strong>name</strong>":"CNPJ",<br>            "<strong>type</strong>": "text",<br>            "<strong>value</strong>":"{VALUE}"<br>        }, <br>        {<br>            "<strong>name</strong>":"IE", <br>            "<strong>type</strong>": "text",<br>            "<strong>value</strong>":"{IE}"<br>        } <br>    ]<br>}</p> |

{% tabs %}
{% tab title="200 Robô executado com sucesso" %}

```
{ID_EXECUTION}
```

{% endtab %}

{% tab title="401 Usuário não autorizado." %}

```javascript
{
  "timestamp": 1574970103297,
  "status": 401,
  "error": "Unauthorized",
  "message": "Unauthorized",
  "path": "/api/user/auth"
}S
```

{% endtab %}
{% endtabs %}

## Executar robô (com parâmetros) v2

<mark style="color:green;">`POST`</mark> `https://app.rpaidea.com/api/integration/v2/run/{ID_COMPUTER}/{ID_BOT}`

Start de execução de forma assíncrona do robô no runtime indicado, retornando o id da execução para futura requisição do resultado.

#### Headers

| Name                                            | Type   | Description              |
| ----------------------------------------------- | ------ | ------------------------ |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer {RESULT-OF-LOGIN} |
| Content-Type<mark style="color:red;">\*</mark>  | string | application/json         |
| x-api-key<mark style="color:red;">\*</mark>     | String | token                    |

#### Request Body

| Name | Type   | Description                                                                                                                       |
| ---- | ------ | --------------------------------------------------------------------------------------------------------------------------------- |
|      | object | <p>{<br>    "variables": \[<br>        "name": "CNPJ",<br>        "type": "text",<br>        "value": "{VALUE}"<br>    ]<br>}</p> |

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

```javascript
{
  "id": "execution_id",
}
```

{% endtab %}
{% endtabs %}

## Executar robô (sem parâmetros)

<mark style="color:blue;">`GET`</mark> `https://app.rpaidea.com/api/integration/v1/run/{ID_COMPUTER}/{ID_BOT}`

Start de execução de forma assíncrona do robô no runtime indicado, retornando o id da execução para futura requisição do resultado. Neste caso sem o envio de parâmetros iniciais via body, mantendo somente os parâmetros default.

#### Headers

| Name                                            | Type   | Description              |
| ----------------------------------------------- | ------ | ------------------------ |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer {RESULT-OF-LOGIN} |
| Content-Type<mark style="color:red;">\*</mark>  | string | application/json         |
| x-api-key<mark style="color:red;">\*</mark>     | String | Token                    |

{% tabs %}
{% tab title="200 Robô executado com sucesso" %}

```
{ID_EXECUTION}
```

{% endtab %}

{% tab title="401 Usuário não autorizado." %}

```javascript
{
  "timestamp": 1574970103297,
  "status": 401,
  "error": "Unauthorized",
  "message": "Unauthorized",
  "path": "/api/user/auth"
}
```

{% endtab %}
{% endtabs %}

## Buscar resultado da execução

<mark style="color:blue;">`GET`</mark> `https://app.rpaidea.com/api/integration/v1/result/{ID_COMPUTER}/{ID_EXECUTION}`

Buscar o resultado de forma parcial ou total da execução de um robô.

#### Headers

| Name                                            | Type   | Description              |
| ----------------------------------------------- | ------ | ------------------------ |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer {RESULT-OF-LOGIN} |
| Content-Type<mark style="color:red;">\*</mark>  | string | Application/json         |
| x-api-key<mark style="color:red;">\*</mark>     | String | token                    |

{% tabs %}
{% tab title="200 Requisição realizada com sucesso" %}

```javascript
{
    "idTask": "",
    "clientId": "",
    "tokenIntegration": "",
    "token": "",
    "dtAdd": "",
    "dtSentRuntime": "",
    "dtIni": "",
    "dtEnd": "",
    "returnValue": "",
    "parameters": "{\"variables\":[]}",
    "nameBot": "Nome do Robô no Orquestrador",
    "idBot": "",
    "versionBot": 0.01,
    "status": "FINISHED",
    "positive": true,
    "lastNotification": null,
    "progress": 1.0,
    "executionOrder": null,
    "localBot": "",
    "user": {},
    "taskOcr": [],
    "taskSteps": [],
    "scheduling": false
}
```

{% endtab %}
{% endtabs %}

## Deletar execução da fila

<mark style="color:red;">`DELETE`</mark> `https://app.rpaidea.com/api/integration/v1/delete/{ID_COMPUTER}/{ID_EXECUTION}`

Excluir execuções de uma fila de execução.

#### Headers

| Name                                            | Type   | Description              |
| ----------------------------------------------- | ------ | ------------------------ |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer {RESULT-OF-LOGIN} |
| Content-Type<mark style="color:red;">\*</mark>  | string | Application/json         |
| x-api-key<mark style="color:red;">\*</mark>     | String | token                    |

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

```
```

{% endtab %}
{% endtabs %}

### Obtendo ID do Robô e do Computador

Para utilização das requisições descritas acima será necessário capturar o código identificador do computador (runtime) em que se deseja executar a ação e do robô que deseja executar.

Para obter essas informações, acesse o Orquestrador e localize o robô que deseja executar no menu "Robôs. No menu ao lado direito do robô, utilize a opção "Usar via API". Uma tela será aberta contendo os dados para utilização na API.

Veja no exemplo a seguir:

<figure><img src="https://2928556787-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FizIEL0wcsfVfXd8Po0RW%2Fuploads%2F9yyyb6H4oAikCvvBtarK%2Fid%20api.gif?alt=media&amp;token=8fe96d8a-93c1-4d2b-bc86-a0edcbe181cc" alt=""><figcaption></figcaption></figure>
