> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Introduction

## Article: Introduction

## Article Link: https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/introduction.md

## Article Content:

# About the Quiz API

The Quiz API manages quiz definitions used by quiz steps in Wix Online Programs. A definition contains quiz settings and its active questions, including the input type, answer key, feedback messages, and optional per-answer score. Creating or cloning a quiz definition requires at least one active question.

With the Quiz API, you can:

+ Create one or more quiz definitions.
+ Retrieve a quiz definition by ID.
+ Clone a definition for reuse in another developer-defined workflow.
+ Permanently delete one or more definitions.

## How quizzes relate to Online Programs

A quiz definition is separate from an Online Programs step. Creating or cloning a quiz doesn't add it to a program. To make the quiz available in a program:

1. Create or clone the quiz definition.
2. Read the new quiz ID from the response.
3. Create a quiz-type step with the Steps API and set `step.quizOptions.id` to the quiz ID.
4. Use the Quiz Submissions API to submit and evaluate participant answers.

The Quiz API intentionally doesn't provide a List or Query method. Discover an existing quiz ID by querying or retrieving its quiz-type step and reading `step.quizOptions.id`.

## Quiz definitions and submissions

Each item in `quiz.fields` defines one active question and its answer input. Creating or cloning a quiz requires at least one active question. A retrieved quiz can have an empty `fields` list after all its questions have been deleted. Check for active questions before displaying or reusing it.

When creating a definition, callers provide:

+ A stable question GUID in `fields.id`.
+ A stable submission key in `fields.target`. Quiz submissions use this key to match an answer to its question; it isn't the question's correct answer.
+ Exactly one input object, such as `numeric`, `shortText`, `longText`, `singleChoice`, `multiChoice`, or `fileUpload`.

New submissions are evaluated against the definition that exists when the submission is created. If a definition changes through another supported workflow, previously stored submissions retain their recorded grades and answer evaluations, while future submissions use the changed definition.

For single-choice questions, a supplied `rightAnswer` must exactly match an entry in `options`. For multi-choice questions, every supplied `rightAnswer` value must exactly match an entry in `options`. An answer key containing an unavailable option causes creation to fail with `INVALID_QUIZ`.

Existing image-choice questions from Wix Forms are returned as `multiChoice`, including questions whose original settings allow only one selection. The Quiz API doesn't expose image-choice-specific settings; the returned `multiChoice` shape doesn't establish that the original question allowed multiple selections.

See [Quiz Grading](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/quiz-grading.md) for matching, scoring, and attempt-limit behavior.

## Permissions and answer-key visibility

Callers with permission to create and clone quizzes can view their answer keys. Permission to retrieve a quiz alone doesn't grant access to its answer keys.

These rules apply to quiz definitions returned by the Quiz API. When the caller can't access answer keys, numeric, short-text, and single-choice `rightAnswer` fields are omitted, and multi-choice `rightAnswer` is an empty list. Questions, options, targets, IDs, and other metadata remain available.

Filtering affects responses only. It doesn't remove answers supplied in write requests, erase stored answer keys, or change server-side grading. An absent answer in a filtered response doesn't establish that the stored question has no correct answer. Don't use a filtered definition to reconstruct or overwrite answer keys.

Participants submit their own answers through the Quiz Submissions API. They don't need access to answer keys for server-side grading.

## Bulk operations and errors

An invalid quiz definition causes bulk creation to fail before any quizzes are created. Otherwise, a successful bulk request can still contain individual failures. Check each result's `itemMetadata.success` and `itemMetadata.error`, even when the request succeeds. Use `itemMetadata.originalIndex` to correlate results with inputs, and attach only successfully created quizzes to steps.

See [Bulk Create Quizzes](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/bulk-create-quizzes.md) and [Bulk Delete Quizzes](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/bulk-delete-quizzes.md) for request limits and response options.

Methods document errors such as `INVALID_QUIZ`, `QUIZ_NOT_FOUND`, and `QUIZ_CONFLICT`. Validation, authorization, temporary failures, and individual bulk results can return other error codes. Inspect the status and error details rather than handling only those three codes.

## Cloning

Cloning copies the quiz definition and returns a new quiz ID. It doesn't clone Online Programs step associations or quiz submissions. Attach the new ID to a step separately when needed.

Cloning requires a quiz with active questions. Avoid modifying the source quiz while cloning it. See [Clone Quiz](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/clone-quiz.md) for error details.

## Permanent deletion

`DeleteQuiz` and `BulkDeleteQuizzes` permanently delete quiz definitions. They don't check whether Online Programs steps reference those definitions. Coordinate deletion with the Steps API and remove known step references first. Otherwise, a step can retain a dangling quiz reference.

## Related APIs

+ [**Steps API**](https://dev.wix.com/docs/api-reference/business-management/online-programs/steps.md): Attaches a quiz definition to a section in an Online Program and provides the supported path for discovering quiz IDs.
+ [**Quiz Submissions API**](https://dev.wix.com/docs/api-reference/business-management/online-programs/quiz-submissions.md): Accepts participant answers, evaluates them against the current quiz definition, and stores the resulting grade and per-answer evaluations.
+ [**Sections API**](https://dev.wix.com/docs/api-reference/business-management/online-programs/sections.md): Supplies the parent section ID required when creating a step.

## Before you begin

It's important to note the following points before starting to code:

+ Install Wix Online Programs on the target site.
+ Obtain the parent section ID before creating a quiz step.
+ Generate stable, unique GUIDs for question `id` values and stable, unique `target` values within each quiz.
+ Provide a right answer for every question that should affect automatic grading.
+ Review [Quiz Grading](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/quiz-grading.md) before choosing passing grades or attempt limits. Non-evaluable answers count as correct, and question scores don't weight the earned-grade percentage.

## Use cases

+ Create a quiz, attach it to a program step, and evaluate participant answers, as described in [Sample Flows](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/sample-flows.md#add-a-quiz-assessment-to-a-program-step).

## Terminology

+ Quiz definition: The questions and settings that a participant's answers are evaluated against. Creating a definition doesn't attach it to a program step.
+ Quiz step: An Online Programs step that references a quiz definition through `quizOptions.id`.
+ Question target: The stable key that matches a submitted answer to a quiz question.
+ Answer key: A question's stored correct answer, distinct from its target and from a participant's submitted answer.
+ Quiz submission: A participant's answers and their recorded grade and answer evaluations.

## Examples

The cURL examples show REST requests and sample responses. The TypeScript examples use `quizzes` from `@wix/online-programs` and show sample SDK responses in `Promise resolves to` comments. Generate unique question GUIDs and replace sample quiz IDs with IDs returned by your own requests. SDK timestamps are JavaScript Dates, shown as ISO strings in the response comments.

Each method's reference page includes its request and response examples:

+ [Create Quiz](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/create-quiz.md)
+ [Get Quiz](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/get-quiz.md)
+ [Clone Quiz](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/clone-quiz.md)
+ [Bulk Create Quizzes](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/bulk-create-quizzes.md)
+ [Delete Quiz](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/delete-quiz.md)
+ [Bulk Delete Quizzes](https://dev.wix.com/docs/api-reference/business-management/online-programs/quizzes/bulk-delete-quizzes.md)

### REST and SDK field names

REST quiz and question IDs use `id`; the TypeScript SDK uses `_id`. Bulk result metadata follows the same convention: `itemMetadata.id` in REST and `itemMetadata._id` in the SDK. REST timestamps use `createdDate` and `updatedDate`; the SDK uses `_createdDate` and `_updatedDate`.

REST Create Quiz and Get Quiz responses wrap the definition in `quiz`. The SDK's `createQuiz()` and `getQuiz()` return the definition directly. SDK `cloneQuiz()` and `deleteQuiz()` responses retain the `quiz` wrapper.

@sdk_package_setup