> ## Documentation Index
> Fetch the complete documentation index at: https://docs.braintest.ir/llms.txt
> Use this file to discover all available pages before exploring further.

# Submit Test Answers

> Submit participant answers to score a test record and mark it as finished.

Use this endpoint to submit the participant's answers for a test record. After successful submission, the record is scored and marked as finished. You can then retrieve results via the JSON or HTML result endpoints.

## Prerequisites

* The profile must be authenticated (`auth_required: false`).
* The record must not already be finished (`is_finished: false`).
* Billing checks must pass (sufficient credits or active plan).

## Endpoint

```http theme={"dark"}
POST https://braintest.ir/api/v2/record/{token}/
```

## Headers

| Header         | Value                                 |
| -------------- | ------------------------------------- |
| `API-KEY`      | Your API key from the organizer panel |
| `Content-Type` | `application/json`                    |

## Path parameters

<ParamField path="token" type="string" required>
  The UUID token of the test record.
</ParamField>

## Body parameters

<ParamField body="record" type="array | object" required>
  The answers payload. The format must match the structure returned by the questions endpoint.

  **Array format:** ordered array of option IDs, one per question.

  **Object format:** object with section keys, each containing an ordered array of option IDs.
</ParamField>

<ParamField body="doing_duration_in_minutes" type="integer" required>
  Time the participant spent on the test, in minutes.
</ParamField>

## Answer formats

### Array format

Use this when the questions endpoint returned a flat list of questions without sections.

```json theme={"dark"}
{
  "record": [
    "opt_2",
    "opt_3",
    "opt_1",
    "opt_4"
  ],
  "doing_duration_in_minutes": 25
}
```

### Object format

Use this when the questions endpoint returned questions grouped by sections.

```json theme={"dark"}
{
  "record": {
    "clinical": [
      "opt_2",
      "opt_3",
      "opt_1"
    ],
    "severe": [
      "opt_4",
      "opt_2"
    ]
  },
  "doing_duration_in_minutes": 25
}
```

## Example request

```bash theme={"dark"}
curl -X POST "https://braintest.ir/api/v2/record/a1b2c3d4-e5f6-7890-abcd-ef1234567890/" \
  -H "API-KEY: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "record": {
      "clinical": ["opt_2", "opt_3", "opt_1"],
      "severe": ["opt_4", "opt_2"]
    },
    "doing_duration_in_minutes": 25
  }'
```

## Success response

```json theme={"dark"}
{
  "data": {},
  "successful": true,
  "messages": []
}
```

## Error responses

| Status | Meaning                   | What to do                                               |
| ------ | ------------------------- | -------------------------------------------------------- |
| `403`  | Profile not authenticated | Call `POST /record/{token}/auth/` first.                 |
| `409`  | Record already completed  | Results are already available; use the result endpoints. |
