---
title: "Tasks with approval | Docs | AI Assistant by R&D Copilot"
description: "Prepare an offer, review the lines and record a decision."
canonical: "https://ai.rdcopilot.com/docs/guides/tasks-with-approval/"
language: en
updated: 2026-11-22
---

# Tasks with approval

Prepare an offer, review the lines and record a decision.

## Prepare the draft

Use the CRM request identifier and choose a fresh run identifier. Once the operation completes, read the run. When it reaches `waiting_for_approval`, the draft carries quantities, ERP unit prices and the net total.

curl

```bash
curl -X POST "$RDC_BASE_URL/ai/v1/tasks/runs" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "1b5201ad-39eb-4cc1-889c-2dd2d43ffc57",
  "expectedRevision": 0,
  "runId": "run-1042",
  "requestId": "CV-1042"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/ai/v1/tasks/runs`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "1b5201ad-39eb-4cc1-889c-2dd2d43ffc57",
    "expectedRevision": 0,
    "runId": "run-1042",
    "requestId": "CV-1042"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/ai/v1/tasks/runs',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '1b5201ad-39eb-4cc1-889c-2dd2d43ffc57',
        'expectedRevision': 0,
        'runId': 'run-1042',
        'requestId': 'CV-1042',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "1b5201ad-39eb-4cc1-889c-2dd2d43ffc57",
  "expectedRevision": 0,
  "runId": "run-1042",
  "requestId": "CV-1042"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/ai/v1/tasks/runs');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/ai/v1/tasks/runs");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "1b5201ad-39eb-4cc1-889c-2dd2d43ffc57",
  "expectedRevision": 0,
  "runId": "run-1042",
  "requestId": "CV-1042"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "1b5201ad-39eb-4cc1-889c-2dd2d43ffc57",
  "status": "accepted",
  "aggregateRevision": 1
}
```

curl

```bash
curl "$RDC_BASE_URL/ai/v1/tasks/runs/run-1042" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/ai/v1/tasks/runs/run-1042`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/ai/v1/tasks/runs/run-1042',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/ai/v1/tasks/runs/run-1042');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/ai/v1/tasks/runs/run-1042");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 200

```json
{
  "status": "waiting_for_approval",
  "draft": {
    "net": "399.81",
    "lines": [
      {
        "sku": "DT-0412",
        "name": "Dishwashing liquid, 5 l",
        "quantity": "12",
        "unitPrice": "23.47",
        "net": "281.64"
      },
      {
        "sku": "AM-0518",
        "name": "Paper bags, pack of 100",
        "quantity": "9",
        "unitPrice": "13.13",
        "net": "118.17"
      }
    ]
  },
  "revision": 2,
  "steps": [
    {
      "id": "read_request",
      "tool": "CRM",
      "status": "done",
      "output": "CV-1042"
    },
    {
      "id": "price_offer",
      "tool": "ERP",
      "status": "done"
    },
    {
      "id": "send_offer",
      "tool": "CRM",
      "status": "waiting_for_approval"
    }
  ],
  "id": "run-1042"
}
```

## Edit or decide

A reviewer with the `finance` role can edit a quantity and recalculate the draft. Read the revision after each edit. Submit an approval or rejection against that revision using a fresh operation UUID.

curl

```bash
curl -X PATCH "$RDC_BASE_URL/ai/v1/tasks/runs/run-1042/draft" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "68549b88-bb2a-449e-a341-79d16f31f897",
  "expectedRevision": 2,
  "sku": "DT-0412",
  "quantity": "7"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/ai/v1/tasks/runs/run-1042/draft`, {
  method: 'PATCH',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "68549b88-bb2a-449e-a341-79d16f31f897",
    "expectedRevision": 2,
    "sku": "DT-0412",
    "quantity": "7"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'PATCH',
    f'{os.environ["RDC_BASE_URL"]}/ai/v1/tasks/runs/run-1042/draft',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '68549b88-bb2a-449e-a341-79d16f31f897',
        'expectedRevision': 2,
        'sku': 'DT-0412',
        'quantity': '7',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "68549b88-bb2a-449e-a341-79d16f31f897",
  "expectedRevision": 2,
  "sku": "DT-0412",
  "quantity": "7"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/ai/v1/tasks/runs/run-1042/draft');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Patch, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/ai/v1/tasks/runs/run-1042/draft");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "68549b88-bb2a-449e-a341-79d16f31f897",
  "expectedRevision": 2,
  "sku": "DT-0412",
  "quantity": "7"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "68549b88-bb2a-449e-a341-79d16f31f897",
  "status": "accepted",
  "aggregateRevision": 3
}
```

curl

```bash
curl -X POST "$RDC_BASE_URL/ai/v1/tasks/runs/run-1042/decision" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "423a61ed-2ea7-40fd-a31e-da3baa387eac",
  "expectedRevision": 2,
  "decision": "approved"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/ai/v1/tasks/runs/run-1042/decision`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "423a61ed-2ea7-40fd-a31e-da3baa387eac",
    "expectedRevision": 2,
    "decision": "approved"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/ai/v1/tasks/runs/run-1042/decision',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '423a61ed-2ea7-40fd-a31e-da3baa387eac',
        'expectedRevision': 2,
        'decision': 'approved',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "423a61ed-2ea7-40fd-a31e-da3baa387eac",
  "expectedRevision": 2,
  "decision": "approved"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/ai/v1/tasks/runs/run-1042/decision');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/ai/v1/tasks/runs/run-1042/decision");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "423a61ed-2ea7-40fd-a31e-da3baa387eac",
  "expectedRevision": 2,
  "decision": "approved"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Response 202

```json
{
  "operationId": "423a61ed-2ea7-40fd-a31e-da3baa387eac",
  "status": "accepted",
  "aggregateRevision": 3
}
```

## Verify dispatch

Read the run again. A successful dispatch has status `done` and a `receiptId`. A rejected run retains the draft and the decision. A failed dispatch retains approval in the audit record and reports `dispatch_failed` without a receipt.
