---
title: "Chat | Docs | Private AI Workspace by R&D Copilot"
description: "Read the chat resources and their request and response fields."
canonical: "https://private-ai.rdcopilot.com/docs/api-reference/chat/"
language: en
updated: 2026-11-22
---

# Chat

Read the chat resources and their request and response fields.

## Ask a question

POST `/private-ai/v1/chat`

Create a chat with expectedRevision 0. The caller identity and permissions come from authentication. The question is answered from the indexed files the caller may read, by a loaded model that the caller’s team may use; nothing leaves the installation. Send Prefer: wait=10 to get the finished chat in the 202 answer when it is ready in time; otherwise read the operation, then read aggregateId. A question that no readable file answers is an answered chat with no answer and no citation. A new intent needs a new operationId.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `Prefer` | header | `string` | Nooptional | wait=<seconds>, up to 30: the answer holds the finished chat when it is ready in time. Without it, read the operation. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A new UUID for a new intent; reuse it after a timeout. |
| `expectedRevision` | `integer` | Yesrequired | The revision you last read. |
| `spaceId` | `string` | Yesrequired | Stable record identifier. |
| `modelId` | `string` | Yesrequired | Stable record identifier. |
| `question` | `string` | Yesrequired | Question. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The operation was accepted. With Prefer: wait and an answer ready in time, the result carries the finished chat. | `ChatOperationResult` |
| `400` | invalid\_request | `Error` |
| `401` | unauthorized | `Error` |
| `403` | forbidden | `Error` |
| `404` | record\_not\_found | `Error` |
| `409` | revision\_conflict | `Error` |
| `422` | invalid\_transition | `Error` |
| `429` | rate\_limited | `Error` |
| `503` | unavailable | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/private-ai/v1/chat" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "8a000001-0000-4000-8000-000000000001",
  "expectedRevision": 0,
  "spaceId": "warehouse",
  "modelId": "model-primary",
  "question": "What do we do with damaged goods at receiving?"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/private-ai/v1/chat`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "8a000001-0000-4000-8000-000000000001",
    "expectedRevision": 0,
    "spaceId": "warehouse",
    "modelId": "model-primary",
    "question": "What do we do with damaged goods at receiving?"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/private-ai/v1/chat',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '8a000001-0000-4000-8000-000000000001',
        'expectedRevision': 0,
        'spaceId': 'warehouse',
        'modelId': 'model-primary',
        'question': 'What do we do with damaged goods at receiving?',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "8a000001-0000-4000-8000-000000000001",
  "expectedRevision": 0,
  "spaceId": "warehouse",
  "modelId": "model-primary",
  "question": "What do we do with damaged goods at receiving?"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/private-ai/v1/chat');
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")}/private-ai/v1/chat");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "8a000001-0000-4000-8000-000000000001",
  "expectedRevision": 0,
  "spaceId": "warehouse",
  "modelId": "model-primary",
  "question": "What do we do with damaged goods at receiving?"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "8a000001-0000-4000-8000-000000000001",
  "status": "completed",
  "aggregateId": "8a000002-0000-4000-8000-000000000001",
  "aggregateRevision": 1,
  "chat": {
    "id": "8a000002-0000-4000-8000-000000000001",
    "revision": 1,
    "spaceId": "warehouse",
    "modelId": "model-primary",
    "question": "What do we do with damaged goods at receiving?",
    "status": "answered",
    "path": [
      "received",
      "authorized",
      "retrieved",
      "drafted",
      "answered"
    ],
    "answer": "Photograph the damaged goods, move them to the quarantine bay and report them to the supplier within one working day.",
    "citations": [
      {
        "documentId": "doc-procedure",
        "title": "Receiving procedure",
        "locator": "Section 4, Damaged goods",
        "passage": "Damaged goods are photographed, moved to the quarantine bay and reported to the supplier within one working day."
      }
    ],
    "documentIds": [
      "doc-procedure"
    ],
    "code": null
  }
}
```

## Read an answer or refusal

GET `/private-ai/v1/chat/{chatId}`

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `chatId` | path | `string` | Yesrequired | Record identifier. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | Current record state. | `Chat` |
| `401` | unauthorized | `Error` |
| `403` | forbidden | `Error` |
| `404` | Record not found in this installation. | `Error` |
| `429` | rate\_limited | `Error` |
| `503` | unavailable | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/private-ai/v1/chat/8a000002-0000-4000-8000-000000000001" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/private-ai/v1/chat/8a000002-0000-4000-8000-000000000001`, {
  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"]}/private-ai/v1/chat/8a000002-0000-4000-8000-000000000001',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/private-ai/v1/chat/8a000002-0000-4000-8000-000000000001');
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")}/private-ai/v1/chat/8a000002-0000-4000-8000-000000000001");
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

```json
{
  "id": "8a000002-0000-4000-8000-000000000001",
  "revision": 1,
  "spaceId": "warehouse",
  "modelId": "model-primary",
  "question": "What do we do with damaged goods at receiving?",
  "status": "answered",
  "path": [
    "received",
    "authorized",
    "retrieved",
    "drafted",
    "answered"
  ],
  "answer": "Photograph the damaged goods, move them to the quarantine bay and report them to the supplier within one working day.",
  "citations": [
    {
      "documentId": "doc-procedure",
      "title": "Receiving procedure",
      "locator": "Section 4, Damaged goods",
      "passage": "Damaged goods are photographed, moved to the quarantine bay and reported to the supplier within one working day."
    }
  ],
  "documentIds": [
    "doc-procedure"
  ],
  "code": null
}
```
