---
title: "Submits answers to an attempt and grades it."
---

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

Path: Sherpo customer API › quiz

`POST /v1/stores/{store}/products/{product}/attempts/{attempt}/submit`

## Authentication

- `bearer`, http, header `Authorization`, scopes: `quiz:write`

## Path parameters

- `store` (`submitAttempt.path.store`; string, required) — A hostname of the store.
- `product` (`submitAttempt.path.product`; string, required) — An id, or `slug:<slug>`.
  - minLength 1
- `attempt` (`submitAttempt.path.attempt`; string, required)
  - minLength 1

## Request body

_Required._

- `answers` (`submitAttempt.answers`; map<any of>, required) — Each text answer at most 4000 characters.
- `preview` (`submitAttempt.preview`; string, optional) — A token a seller made for the quiz's product's page, which opens the quiz of a published entry of the product unpublished, or for the quiz's entry, which opens it unpublished too, gated as ever; with it, a sitting on any quiz it does not open is `not_found` `preview`.
  - minLength 1; maxLength 128

## Example request

```json
{
  "answers": {
    "property1": true,
    "property2": true
  },
  "preview": "string"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.sherpo.io/customer/v1/stores/<store>/products/<product>/attempts/<attempt>/submit' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "answers": {
    "property1": true,
    "property2": true
  },
  "preview": "string"
}
'
```

### TypeScript

```typescript
const url = 'https://api.sherpo.io/customer/v1/stores/<store>/products/<product>/attempts/<attempt>/submit';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({answers: {property1: true, property2: true}, preview: 'string'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.sherpo.io/customer/v1/stores/<store>/products/<product>/attempts/<attempt>/submit"

payload = {
    "answers": {
        "property1": True,
        "property2": True
    },
    "preview": "string"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Submits answers to an attempt and grades it.

#### Example

```json
{
  "attempt": {
    "id": "string",
    "product_id": "string",
    "quiz_id": "string",
    "entry_id": "string",
    "attempt": 0,
    "status": "string",
    "score": 0,
    "correct": 0,
    "started_at": "string",
    "finished_at": "string",
    "access": "string"
  },
  "score": 0,
  "correct": 0,
  "total": 0,
  "results": [
    {
      "question_id": "string",
      "answer": true,
      "correct": true,
      "key": {
        "correct_option_id": "string",
        "correct_answer": true,
        "correct_value": 0,
        "accepted_answers": [
          "string"
        ],
        "explanation": "string"
      }
    }
  ],
  "certificate": {
    "id": "string",
    "product_id": "string",
    "certificate_id": "string",
    "score": 0,
    "attempt": 0,
    "issued_at": "string"
  },
  "certificates": [
    {
      "id": "string",
      "product_id": "string",
      "certificate_id": "string",
      "score": 0,
      "attempt": 0,
      "issued_at": "string"
    }
  ]
}
```

- `attempt` (`submitAttempt.response.200.attempt`; object, required)
  - `id` (`submitAttempt.response.200.attempt.id`; string, required)
  - `product_id` (`submitAttempt.response.200.attempt.product_id`; string, required)
  - `quiz_id` (`submitAttempt.response.200.attempt.quiz_id`; string, required)
  - `entry_id` (`submitAttempt.response.200.attempt.entry_id`; string, required)
  - `attempt` (`submitAttempt.response.200.attempt.attempt`; number, required)
  - `status` (`submitAttempt.response.200.attempt.status`; string, required)
  - `score` (`submitAttempt.response.200.attempt.score`; any of, required)
    - any of: `number`, `null`
  - `correct` (`submitAttempt.response.200.attempt.correct`; any of, required)
    - any of: `number`, `null`
  - `started_at` (`submitAttempt.response.200.attempt.started_at`; string, required)
  - `finished_at` (`submitAttempt.response.200.attempt.finished_at`; any of, required)
    - any of: `string`, `null`
  - `access` (`submitAttempt.response.200.attempt.access`; string, required)
- `score` (`submitAttempt.response.200.score`; number, required)
- `correct` (`submitAttempt.response.200.correct`; number, required)
- `total` (`submitAttempt.response.200.total`; number, required)
- `results` (`submitAttempt.response.200.results`; array<object>, required)
  - `question_id` (`submitAttempt.response.200.results.question_id`; string, required)
  - `answer` (`submitAttempt.response.200.results.answer`; any of, required)
    - any of: `boolean`, `string`, `number`, `null`
  - `correct` (`submitAttempt.response.200.results.correct`; any of, required)
    - any of: `boolean`, `null`
  - `key` (`submitAttempt.response.200.results.key`; any of, required)
    - any of: `object`, `null`
- `certificate` (`submitAttempt.response.200.certificate`; any of, required)
  - any of: `object`, `null`
- `certificates` (`submitAttempt.response.200.certificates`; array<object>, required)
  - `id` (`submitAttempt.response.200.certificates.id`; string, required)
  - `product_id` (`submitAttempt.response.200.certificates.product_id`; string, required)
  - `certificate_id` (`submitAttempt.response.200.certificates.certificate_id`; string, required)
  - `score` (`submitAttempt.response.200.certificates.score`; any of, required)
    - any of: `number`, `null`
  - `attempt` (`submitAttempt.response.200.certificates.attempt`; any of, required)
    - any of: `number`, `null`
  - `issued_at` (`submitAttempt.response.200.certificates.issued_at`; string, required)

### default

A problem; see https://api.sherpo.io/customer/docs/errors.

#### Example

```json
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "context": {},
  "reached_core": true,
  "core_answer": "string"
}
```

- `type` (`submitAttempt.response.default.type`; string, required)
  - format `uri`
- `title` (`submitAttempt.response.default.title`; string, required)
- `status` (`submitAttempt.response.default.status`; integer, required)
- `detail` (`submitAttempt.response.default.detail`; string, required)
- `code` (`submitAttempt.response.default.code`; string, optional)
- `context` (`submitAttempt.response.default.context`; object, optional)
- `reached_core` (`submitAttempt.response.default.reached_core`; boolean, optional)
- `core_answer` (`submitAttempt.response.default.core_answer`; string, optional)


Source: https://docs.sherpo.io/customer-api/reference/submit-attempt/index.md
