---
title: "Returns | Docs | Tax Filing by R&D Copilot"
description: "Build a return from the ledger, read its rows and findings, rebuild it when the ledger changes and correct it after the authority answered."
canonical: "https://declarations.rdcopilot.com/docs/api-reference/returns/"
language: en
updated: 2026-11-22
---

# Returns

Build a return from the ledger, read its rows and findings, rebuild it when the ledger changes and correct it after the authority answered.

## List returns

GET `/declarations/v1/returns`

Returns every version of the returns of a company, newest period first. `status` keeps only the returns in one status, for example the rejected ones.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `companyId` | query | `string (uuid)` | Yesrequired | The company whose records you want. It is the `id` of a company of your account. |
| `form` | query | `string` | Nooptional | Only returns of this form. One of `D300`, `D390`, `D394`, `D406` |
| `period` | query | `string` | Nooptional | Only this period, as `YYYY-MM`. |
| `status` | query | `string` | Nooptional | Only returns in this status. One of `draft`, `generated`, `validated`, `signed`, `authorized`, `queued`, `submitted`, `processing`, `accepted`, `rejected`, `manual_review` |
| `limit` | query | `integer` | Nooptional | Records per page, from 1 to 500. Default `100` Range `1` – `500` |
| `cursor` | query | `string` | Nooptional | The `nextCursor` of the previous page. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | A page of returns. | `ReturnPage` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data. | `Error` |
| `404` | The company does not exist in your account. | `Error` |
| `429` | Too many requests. `Retry-After` gives the seconds to wait; the request was not processed. | `Error` |
| `503` | The service cannot answer now. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/declarations/v1/returns?companyId=a79a302d-e7f0-4fde-9086-48c003b9709a&limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns?companyId=a79a302d-e7f0-4fde-9086-48c003b9709a&limit=20`, {
  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"]}/declarations/v1/returns?companyId=a79a302d-e7f0-4fde-9086-48c003b9709a&limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns?companyId=a79a302d-e7f0-4fde-9086-48c003b9709a&limit=20');
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")}/declarations/v1/returns?companyId=a79a302d-e7f0-4fde-9086-48c003b9709a&limit=20");
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
{
  "items": [
    {
      "id": "3b559a77-5de4-4b9a-9e2e-ca6625d123f2",
      "obligationId": "254fd08e-0d65-4719-9e6f-a7d07db2a448",
      "companyId": "a79a302d-e7f0-4fde-9086-48c003b9709a",
      "form": "D300",
      "period": "2026-10",
      "version": 1,
      "status": "signed",
      "owner": {
        "id": "adacf598-0e46-4866-a3c6-ba0234ecacc4",
        "name": "Ioana Marin",
        "role": "Chief accountant"
      },
      "dueDate": "2026-11-25",
      "snapshot": 1,
      "amountToPay": "975.02",
      "amountToRecover": "0.00",
      "currency": "RON",
      "supersedes": null,
      "approval": null,
      "uploadIndex": null,
      "revision": 4
    },
    {
      "id": "d595ff94-75e0-4dbf-8663-f53351cb08ae",
      "obligationId": "2931b99e-afe1-44b0-8031-8ff16466c5b9",
      "companyId": "a79a302d-e7f0-4fde-9086-48c003b9709a",
      "form": "D390",
      "period": "2026-10",
      "version": 1,
      "status": "generated",
      "owner": {
        "id": "adacf598-0e46-4866-a3c6-ba0234ecacc4",
        "name": "Ioana Marin",
        "role": "Chief accountant"
      },
      "dueDate": "2026-11-25",
      "snapshot": 2,
      "amountToPay": null,
      "amountToRecover": null,
      "currency": "RON",
      "supersedes": null,
      "approval": null,
      "uploadIndex": null,
      "revision": 4
    },
    {
      "id": "6e95eb18-450e-4cca-8671-f3edaaa04d8d",
      "obligationId": "43553e25-0119-4430-98ab-3fa7a9af0a50",
      "companyId": "a79a302d-e7f0-4fde-9086-48c003b9709a",
      "form": "D394",
      "period": "2026-10",
      "version": 1,
      "status": "rejected",
      "owner": {
        "id": "adacf598-0e46-4866-a3c6-ba0234ecacc4",
        "name": "Ioana Marin",
        "role": "Chief accountant"
      },
      "dueDate": "2026-12-02",
      "snapshot": 1,
      "amountToPay": null,
      "amountToRecover": null,
      "currency": "RON",
      "supersedes": null,
      "approval": {
        "approvedBy": {
          "id": "a0eaa217-d9ed-4f3e-b95a-c4b3176cf035",
          "name": "Ana Rusu",
          "role": "Finance director, approver"
        },
        "approvedAt": "2026-11-20T09:00:00Z"
      },
      "uploadIndex": "5013480209",
      "revision": 9
    },
    {
      "id": "6e1e206c-d65e-48d6-8fa8-628da226d100",
      "obligationId": "5b37c7a3-d395-4aff-9e1c-db383b74e36d",
      "companyId": "a79a302d-e7f0-4fde-9086-48c003b9709a",
      "form": "D406",
      "period": "2026-10",
      "version": 1,
      "status": "authorized",
      "owner": {
        "id": "adacf598-0e46-4866-a3c6-ba0234ecacc4",
        "name": "Ioana Marin",
        "role": "Chief accountant"
      },
      "dueDate": "2026-12-02",
      "snapshot": 2,
      "amountToPay": null,
      "amountToRecover": null,
      "currency": "RON",
      "supersedes": null,
      "approval": {
        "approvedBy": {
          "id": "a0eaa217-d9ed-4f3e-b95a-c4b3176cf035",
          "name": "Ana Rusu",
          "role": "Finance director, approver"
        },
        "approvedAt": "2026-11-22T16:40:00Z"
      },
      "uploadIndex": null,
      "revision": 5
    }
  ],
  "nextCursor": null
}
```

## Get a return

GET `/declarations/v1/returns/{returnId}`

Returns the return at its current revision: status, due date, amount, the ledger snapshot it was built from, its approval and the upload index.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `returnId` | path | `string (uuid)` | Yesrequired | The return. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | The return. | `Return` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data. | `Error` |
| `404` | The return does not exist in your account. | `Error` |
| `429` | Too many requests. `Retry-After` gives the seconds to wait; the request was not processed. | `Error` |
| `503` | The service cannot answer now. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2`, {
  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"]}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2');
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")}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2");
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": "3b559a77-5de4-4b9a-9e2e-ca6625d123f2",
  "obligationId": "254fd08e-0d65-4719-9e6f-a7d07db2a448",
  "companyId": "a79a302d-e7f0-4fde-9086-48c003b9709a",
  "form": "D300",
  "period": "2026-10",
  "version": 1,
  "status": "signed",
  "owner": {
    "id": "adacf598-0e46-4866-a3c6-ba0234ecacc4",
    "name": "Ioana Marin",
    "role": "Chief accountant"
  },
  "dueDate": "2026-11-25",
  "snapshot": 1,
  "amountToPay": "975.02",
  "amountToRecover": "0.00",
  "currency": "RON",
  "supersedes": null,
  "approval": null,
  "uploadIndex": null,
  "revision": 4
}
```

## List the rows of a return

GET `/declarations/v1/returns/{returnId}/rows`

Returns the rows of the form, each with the figure, the VAT and the ledger balances it was summed from. A return that is not built has no rows.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `returnId` | path | `string (uuid)` | Yesrequired | The return. |
| `limit` | query | `integer` | Nooptional | Records per page, from 1 to 500. Default `100` Range `1` – `500` |
| `cursor` | query | `string` | Nooptional | The `nextCursor` of the previous page. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | A page of rows. | `RowPage` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data. | `Error` |
| `404` | The return does not exist in your account. | `Error` |
| `429` | Too many requests. `Retry-After` gives the seconds to wait; the request was not processed. | `Error` |
| `503` | The service cannot answer now. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/rows?limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/rows?limit=20`, {
  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"]}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/rows?limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/rows?limit=20');
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")}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/rows?limit=20");
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
{
  "items": [
    {
      "key": "sales-21",
      "label": "Supplies at 21%",
      "ref": null,
      "unit": "amount",
      "value": "2947.04",
      "vat": "618.89",
      "partner": null,
      "code": null,
      "from": [
        "707 credit, 21%",
        "4427 credit, 21%"
      ]
    },
    {
      "key": "sales-11",
      "label": "Supplies at 11%",
      "ref": null,
      "unit": "amount",
      "value": "57329.70",
      "vat": "6306.27",
      "partner": null,
      "code": null,
      "from": [
        "707 credit, 11%",
        "4427 credit, 11%"
      ]
    },
    {
      "key": "ic-acquisitions",
      "label": "Acquisitions from other member states",
      "ref": null,
      "unit": "amount",
      "value": "5252.00",
      "vat": "1102.92",
      "partner": null,
      "code": null,
      "from": [
        "371 debit",
        "4427 credit"
      ]
    },
    {
      "key": "purchases-21",
      "label": "Domestic purchases at 21%",
      "ref": null,
      "unit": "amount",
      "value": "3067.50",
      "vat": "644.18",
      "partner": null,
      "code": null,
      "from": [
        "371 debit, 21%",
        "4426 debit, 21%"
      ]
    },
    {
      "key": "purchases-11",
      "label": "Domestic purchases at 11%",
      "ref": null,
      "unit": "amount",
      "value": "48236.00",
      "vat": "5305.96",
      "partner": null,
      "code": null,
      "from": [
        "371 debit, 11%",
        "4426 debit, 11%"
      ]
    },
    {
      "key": "deductible-ic",
      "label": "Deductible VAT on acquisitions from other member states",
      "ref": null,
      "unit": "amount",
      "value": null,
      "vat": "1102.92",
      "partner": null,
      "code": null,
      "from": [
        "4426 debit"
      ]
    },
    {
      "key": "total-collected",
      "label": "Total VAT collected",
      "ref": 19,
      "unit": "amount",
      "value": null,
      "vat": "8028.08",
      "partner": null,
      "code": null,
      "from": [
        "4427 credit"
      ]
    },
    {
      "key": "total-deductible",
      "label": "Total VAT deductible",
      "ref": 30,
      "unit": "amount",
      "value": null,
      "vat": "7053.06",
      "partner": null,
      "code": null,
      "from": [
        "4426 debit"
      ]
    },
    {
      "key": "total-deducted",
      "label": "Total VAT deducted",
      "ref": 35,
      "unit": "amount",
      "value": null,
      "vat": "7053.06",
      "partner": null,
      "code": null,
      "from": [
        "4426 debit"
      ]
    },
    {
      "key": "recoverable",
      "label": "Negative amount of VAT of the period",
      "ref": 36,
      "unit": "amount",
      "value": null,
      "vat": "0.00",
      "partner": null,
      "code": null,
      "from": [
        "4427 credit",
        "4426 debit"
      ]
    },
    {
      "key": "payable",
      "label": "VAT payable in the period",
      "ref": 37,
      "unit": "amount",
      "value": null,
      "vat": "975.02",
      "partner": null,
      "code": null,
      "from": [
        "4427 credit",
        "4426 debit"
      ]
    }
  ],
  "nextCursor": null
}
```

## Get the findings of a return

GET `/declarations/v1/returns/{returnId}/findings`

Returns what the checks find on the return now, including the comparison with the other forms of the same period. `canApprove` is true when no error remains. A warning does not block.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `returnId` | path | `string (uuid)` | Yesrequired | The return. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | The findings. | `Findings` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data. | `Error` |
| `404` | The return does not exist in your account. | `Error` |
| `429` | Too many requests. `Retry-After` gives the seconds to wait; the request was not processed. | `Error` |
| `503` | The service cannot answer now. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/findings" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/findings`, {
  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"]}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/findings',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/findings');
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")}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/findings");
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
{
  "returnId": "3b559a77-5de4-4b9a-9e2e-ca6625d123f2",
  "revision": 4,
  "canApprove": false,
  "errors": 1,
  "warnings": 0,
  "findings": [
    {
      "rule": "X-02",
      "severity": "error",
      "row": "ic-acquisitions",
      "message": "The acquisitions of D390 must equal the acquisitions from other member states in D300. This return has 5252.00; D390 has 8534.50."
    }
  ]
}
```

## List the history of a return

GET `/declarations/v1/returns/{returnId}/history`

Returns every change of status with its time, who did it and, where there is one, the upload index or the message of the authority. Oldest first.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `returnId` | path | `string (uuid)` | Yesrequired | The return. |
| `limit` | query | `integer` | Nooptional | Records per page, from 1 to 500. Default `100` Range `1` – `500` |
| `cursor` | query | `string` | Nooptional | The `nextCursor` of the previous page. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | A page of history entries. | `HistoryPage` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data. | `Error` |
| `404` | The return does not exist in your account. | `Error` |
| `429` | Too many requests. `Retry-After` gives the seconds to wait; the request was not processed. | `Error` |
| `503` | The service cannot answer now. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/history?limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/history?limit=20`, {
  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"]}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/history?limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/history?limit=20');
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")}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/history?limit=20");
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
{
  "items": [
    {
      "status": "draft",
      "at": "2026-11-19T09:00:00Z"
    },
    {
      "status": "generated",
      "at": "2026-11-19T09:05:00Z",
      "snapshot": 1
    },
    {
      "status": "validated",
      "at": "2026-11-19T09:06:00Z"
    },
    {
      "status": "signed",
      "at": "2026-11-19T09:20:00Z",
      "by": "Ioana Marin"
    }
  ],
  "nextCursor": null
}
```

## Build a return from the ledger

POST `/declarations/v1/returns/{returnId}/generate`

Builds the rows of a `draft` return from the newest ledger snapshot of its period and records the generation evidence. It is refused while the period is not over.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `returnId` | path | `string (uuid)` | Yesrequired | The return. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the return you read. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result: `aggregateId` is the record that was created or changed. | `OperationResult` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data. | `Error` |
| `404` | The return does not exist in your account. | `Error` |
| `409` | `revision_conflict`: The return changed since the revision you sent. Nothing was applied. `operation_reused`: The `operationId` was already used with a different request. `invalid_status`: The return is not in a status that allows this. `period_open`: The period of the return is not over, so there is nothing to build yet. | `Error` |
| `429` | Too many requests. `Retry-After` gives the seconds to wait; the request was not processed. | `Error` |
| `503` | The service cannot answer now. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/declarations/v1/returns/dff3b09f-8bbd-488b-8b7d-f71eb11ef3af/generate" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b",
  "expectedRevision": 1
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns/dff3b09f-8bbd-488b-8b7d-f71eb11ef3af/generate`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b",
    "expectedRevision": 1
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/declarations/v1/returns/dff3b09f-8bbd-488b-8b7d-f71eb11ef3af/generate',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b',
        'expectedRevision': 1,
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b",
  "expectedRevision": 1
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns/dff3b09f-8bbd-488b-8b7d-f71eb11ef3af/generate');
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")}/declarations/v1/returns/dff3b09f-8bbd-488b-8b7d-f71eb11ef3af/generate");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b",
  "expectedRevision": 1
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "4b6f8fbf-33e1-4464-9142-f9ed6bf73a4b",
  "status": "accepted",
  "aggregateId": "dff3b09f-8bbd-488b-8b7d-f71eb11ef3af",
  "aggregateRevision": 2
}
```

## Validate a return

POST `/declarations/v1/returns/{returnId}/validate`

Runs the checks on a `generated` return. With no error the return becomes `validated` and the validation evidence is recorded. With an error it stays `generated` and the run is written to its history; read the findings.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `returnId` | path | `string (uuid)` | Yesrequired | The return. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the return you read. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result: `aggregateId` is the record that was created or changed. | `OperationResult` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data. | `Error` |
| `404` | The return does not exist in your account. | `Error` |
| `409` | `revision_conflict`: The return changed since the revision you sent. Nothing was applied. `operation_reused`: The `operationId` was already used with a different request. `invalid_status`: The return is not in a status that allows this. | `Error` |
| `429` | Too many requests. `Retry-After` gives the seconds to wait; the request was not processed. | `Error` |
| `503` | The service cannot answer now. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/validate" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "87fbb260-7b9b-436b-bfd0-8ee38a87676e",
  "expectedRevision": 5
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/validate`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "87fbb260-7b9b-436b-bfd0-8ee38a87676e",
    "expectedRevision": 5
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/validate',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '87fbb260-7b9b-436b-bfd0-8ee38a87676e',
        'expectedRevision': 5,
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "87fbb260-7b9b-436b-bfd0-8ee38a87676e",
  "expectedRevision": 5
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/validate');
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")}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/validate");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "87fbb260-7b9b-436b-bfd0-8ee38a87676e",
  "expectedRevision": 5
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "87fbb260-7b9b-436b-bfd0-8ee38a87676e",
  "status": "accepted",
  "aggregateId": "3b559a77-5de4-4b9a-9e2e-ca6625d123f2",
  "aggregateRevision": 6
}
```

## Rebuild a return

POST `/declarations/v1/returns/{returnId}/regenerate`

Builds the return again from the newest ledger snapshot, before it is filed. The evidence and the approval of the old build are replaced and the history keeps it. It is refused when the ledger has no newer snapshot.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `returnId` | path | `string (uuid)` | Yesrequired | The return. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the return you read. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result: `aggregateId` is the record that was created or changed. | `OperationResult` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data. | `Error` |
| `404` | The return does not exist in your account. | `Error` |
| `409` | `revision_conflict`: The return changed since the revision you sent. Nothing was applied. `operation_reused`: The `operationId` was already used with a different request. `invalid_status`: The return is not in a status that allows this. `source_unchanged`: The ledger has no newer snapshot than the one the return was built from, so rebuilding or correcting changes nothing. | `Error` |
| `429` | Too many requests. `Retry-After` gives the seconds to wait; the request was not processed. | `Error` |
| `503` | The service cannot answer now. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/regenerate" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "e3f2c9a7-7037-4de9-bb01-7ad37d5f67af",
  "expectedRevision": 4
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/regenerate`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "e3f2c9a7-7037-4de9-bb01-7ad37d5f67af",
    "expectedRevision": 4
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/regenerate',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'e3f2c9a7-7037-4de9-bb01-7ad37d5f67af',
        'expectedRevision': 4,
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "e3f2c9a7-7037-4de9-bb01-7ad37d5f67af",
  "expectedRevision": 4
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/regenerate');
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")}/declarations/v1/returns/3b559a77-5de4-4b9a-9e2e-ca6625d123f2/regenerate");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "e3f2c9a7-7037-4de9-bb01-7ad37d5f67af",
  "expectedRevision": 4
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "e3f2c9a7-7037-4de9-bb01-7ad37d5f67af",
  "status": "accepted",
  "aggregateId": "3b559a77-5de4-4b9a-9e2e-ca6625d123f2",
  "aggregateRevision": 5
}
```

## Correct a return

POST `/declarations/v1/returns/{returnId}/correct`

Makes version 2 of a return that the authority accepted or rejected, as a new `draft` that points back to the first. The first version never changes. It is refused when a correction already exists and when the ledger has no newer snapshot. `aggregateId` of the answer is the new return.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `returnId` | path | `string (uuid)` | Yesrequired | The return. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the return you read. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result: `aggregateId` is the record that was created or changed. | `OperationResult` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data. | `Error` |
| `404` | The return does not exist in your account. | `Error` |
| `409` | `revision_conflict`: The return changed since the revision you sent. Nothing was applied. `operation_reused`: The `operationId` was already used with a different request. `invalid_status`: The return is not in a status that allows this. `already_corrected`: A correction of this return already exists. `source_unchanged`: The ledger has no newer snapshot than the one the return was built from, so rebuilding or correcting changes nothing. | `Error` |
| `429` | Too many requests. `Retry-After` gives the seconds to wait; the request was not processed. | `Error` |
| `503` | The service cannot answer now. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/declarations/v1/returns/6e95eb18-450e-4cca-8671-f3edaaa04d8d/correct" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "589f4cca-7f8a-4f18-a98b-89fd11ce69cf",
  "expectedRevision": 9
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/returns/6e95eb18-450e-4cca-8671-f3edaaa04d8d/correct`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "589f4cca-7f8a-4f18-a98b-89fd11ce69cf",
    "expectedRevision": 9
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/declarations/v1/returns/6e95eb18-450e-4cca-8671-f3edaaa04d8d/correct',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '589f4cca-7f8a-4f18-a98b-89fd11ce69cf',
        'expectedRevision': 9,
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "589f4cca-7f8a-4f18-a98b-89fd11ce69cf",
  "expectedRevision": 9
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/returns/6e95eb18-450e-4cca-8671-f3edaaa04d8d/correct');
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")}/declarations/v1/returns/6e95eb18-450e-4cca-8671-f3edaaa04d8d/correct");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "589f4cca-7f8a-4f18-a98b-89fd11ce69cf",
  "expectedRevision": 9
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "589f4cca-7f8a-4f18-a98b-89fd11ce69cf",
  "status": "accepted",
  "aggregateId": "dff3b09f-8bbd-488b-8b7d-f71eb11ef3af",
  "aggregateRevision": 1
}
```

## List the rules of the checks

GET `/declarations/v1/rules`

Returns the catalogue of the checks: the rule, its severity, the forms it applies to and what it requires.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `limit` | query | `integer` | Nooptional | Records per page, from 1 to 500. Default `100` Range `1` – `500` |
| `cursor` | query | `string` | Nooptional | The `nextCursor` of the previous page. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | A page of rules. | `RulePage` |
| `401` | The token is missing, not valid or has ended. | `Error` |
| `403` | The token does not give access to this data. | `Error` |
| `429` | Too many requests. `Retry-After` gives the seconds to wait; the request was not processed. | `Error` |
| `503` | The service cannot answer now. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/declarations/v1/rules?limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/declarations/v1/rules?limit=20`, {
  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"]}/declarations/v1/rules?limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/declarations/v1/rules?limit=20');
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")}/declarations/v1/rules?limit=20");
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
{
  "items": [
    {
      "rule": "X-01",
      "severity": "error",
      "forms": [
        "D300",
        "D394"
      ],
      "description": "The supplies and acquisitions of D394 must equal the rows of D300, by rate."
    },
    {
      "rule": "X-02",
      "severity": "error",
      "forms": [
        "D300",
        "D390"
      ],
      "description": "The acquisitions of D390 must equal the acquisitions from other member states in D300."
    },
    {
      "rule": "S-01",
      "severity": "error",
      "forms": [
        "D406"
      ],
      "description": "The total debit of the ledger must equal its total credit."
    },
    {
      "rule": "P-01",
      "severity": "error",
      "forms": [
        "D394"
      ],
      "description": "Every partner row must carry a tax code."
    },
    {
      "rule": "W-01",
      "severity": "warning",
      "forms": [
        "D300"
      ],
      "description": "The return shows VAT to recover."
    }
  ],
  "nextCursor": null
}
```
