The quiz creation API turns a quiz you can export from the dashboard into a workflow you can automate—from content creation through custom links and publishing—without maintaining a second data format.
From dashboard export to API request
Create quizzes programmatically with the same schema-version 3 JSON package produced by QuizMachine export.
- Export a representative quiz from the dashboard and save the JSON as your schema-version 3 starting point.
POST /api/v1/auth/token→POST /api/v1/mfa/verifyPOST /api/v1/quizzes
Two-step verification
This self-contained PowerShell example needs no repository files. If MFA is already set up, enter the current six-digit authenticator code, not its setup secret. Do not enroll again.
After MFA verification, an API token remains verified until it expires (up to 60 minutes). Each new API token needs MFA; browser sign-in does not verify it.
# PowerShell 5.1+; run locally. Do not paste passwords, codes, or tokens into chat.
# MFA must already be enrolled. This example authenticates; it does not enroll/reset MFA.
$baseUrl = 'https://dev-quizmachine.covecode.net'
$email = Read-Host 'QuizMachine email'
$useMfa = $true # Set false only if your account/operation does not require MFA.
$securePassword = Read-Host 'Password (hidden)' -AsSecureString
$secureCode = $null
$candidate = $null
try {
$password = [pscredential]::new('user', $securePassword).GetNetworkCredential().Password
$payload = @{
email = $email
password = $password
scopes = @('quiz:read','quiz:write','topic:read','topic:write','media:write')
} | ConvertTo-Json -Compress
$login = Invoke-RestMethod -Method Post -Uri "$baseUrl/api/v1/auth/token" `
-ContentType 'application/json' -Body $payload `
-TimeoutSec 30 -MaximumRedirection 0 -ErrorAction Stop
$password = $payload = $null
$candidate = [string]$login.access_token
if ([string]::IsNullOrWhiteSpace($candidate)) { throw 'Missing login token.' }
if ($useMfa) {
# Get a CURRENT six-digit code after login. Keep it a string: leading zeroes matter.
$secureCode = Read-Host 'Current six-digit authenticator code (hidden)' -AsSecureString
$code = [pscredential]::new('user', $secureCode).GetNetworkCredential().Password.Trim()
if ($code -notmatch '^[0-9]{6}$') { throw 'Expected six digits.' }
$verified = Invoke-RestMethod -Method Post -Uri "$baseUrl/api/v1/mfa/verify" `
-Headers @{ Authorization = "Bearer $candidate" } `
-ContentType 'application/json' `
-Body (@{ code = $code; operation = 1 } | ConvertTo-Json -Compress) `
-TimeoutSec 30 -MaximumRedirection 0 -ErrorAction Stop
# operation 1 = Authenticate. This response uses accessToken, NOT access_token.
$candidate = [string]$verified.accessToken
if ([string]::IsNullOrWhiteSpace($candidate)) { throw 'Missing verified token.' }
}
# Replace the current process token only after every required step succeeds.
$env:QUIZMACHINE_TOKEN = $candidate
Write-Host 'API token ready in this PowerShell session.'
}
catch {
# Do not dump HTTP bodies/headers or secrets. The old environment token is unchanged.
throw 'Authentication failed; no new token saved. Check credentials, MFA code, clock, and connectivity. Wait for a new code before retrying.'
}
finally {
$password = $payload = $code = $candidate = $login = $verified = $null
$securePassword.Dispose()
if ($null -ne $secureCode) { $secureCode.Dispose() }
}
# Read-only check. Authentication alone does not grant missing scopes or plan access.
$headers = @{ Authorization = "Bearer $env:QUIZMACHINE_TOKEN" }
$quizzes = Invoke-RestMethod -Uri "$baseUrl/api/v1/quizzes?pageSize=1" `
-Headers $headers -TimeoutSec 30 -MaximumRedirection 0 -ErrorAction Stop
Write-Host 'Quiz read access confirmed.'
# After MFA verification, this API token stays verified until its expiry (at most 60 minutes).
# Expiry, revocation, and missing scopes still prevent access. A new token needs MFA again.
# Optional Windows persistence AFTER successful authentication:
# User environment variables are not a credential vault. Anyone able to read the value can use it.
[Environment]::SetEnvironmentVariable('QUIZMACHINE_TOKEN', $env:QUIZMACHINE_TOKEN, 'User')
# An already running application does not automatically inherit the new User value.
# Restart it, or explicitly reload the value in its PowerShell process:
$env:QUIZMACHINE_TOKEN = [Environment]::GetEnvironmentVariable('QUIZMACHINE_TOKEN', 'User')
Manual MFA needs no stored setup secret. Unattended refresh requires the enrolled secret and password in a protected credential store. Keeping both on one device reduces factor separation. A scheduled password-only login cannot renew MFA.
# Optional unattended workflow; implement in your own trusted automation client:
# 1. Read the account password and EXISTING enrolled TOTP secret from a protected vault.
# Windows Credential Manager is one option; the scheduled account must have access.
# 2. POST /api/v1/auth/token with the required scopes.
# 3. Generate a current six-digit TOTP and POST /api/v1/mfa/verify with operation: 1.
# 4. Replace the stored token only after a non-empty accessToken is returned.
# On any failure, preserve the previous token and alert the operator without logging secrets.
# Refresh near token expiry; for a 60-minute token, 55 minutes leaves a small scheduling margin.
# Every replacement token needs MFA. Neither scheduling nor a browser login supplies API proof.
# A setup secret is the long Base32 key originally enrolled in the authenticator, not a six-digit
# code, recovery code, or otpauth URI. Storing it is OPTIONAL; manual MFA works without it.
# If you no longer have that secret, continue with manual codes. Do not reset MFA just for this example.
# Troubleshooting:
# 401: token expired/invalid, or login credentials rejected. Authenticate again.
# 403 + mfa_required: this API token needs MFA verification. Use the returned accessToken.
# 403 + mfa_invalid_or_throttled: check the account and device clock; wait for a fresh code/backoff.
# Other 403: inspect the safe error code for scope, role, plan, or ownership restrictions.
# Never assume every 403 is MFA, and never print the Authorization header while diagnosing.
Keep the returned access token secret. API tokens expire after 60 minutes, are invalidated by password changes or email-confirmation revocation, and should only be sent over HTTPS.
curl -X POST https://dev-quizmachine.covecode.net/api/v1/quizzes \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
--data-binary @quiz-export.json
Read and update the quizzes you already have
A GET returns the same schema-version 3 package the create endpoint accepts, plus publication status, custom link, and share URL. Scripts can edit, publish, close, and share a quiz without opening the browser editor.
GET /api/v1/quizzesGET /api/v1/quizzes/{id}PUT /api/v1/quizzes/{id}PUT /api/v1/quizzes/{id}/slugPUT /api/v1/quizzes/{id}/status
curl https://dev-quizmachine.covecode.net/api/v1/quizzes?pageSize=25 -H "Authorization: Bearer <access_token>"
curl https://dev-quizmachine.covecode.net/api/v1/quizzes/<quiz_id> -H "Authorization: Bearer <access_token>" > quiz-export.json
curl -X PUT https://dev-quizmachine.covecode.net/api/v1/quizzes/<quiz_id> -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" --data-binary @quiz-export.json
curl -X PUT https://dev-quizmachine.covecode.net/api/v1/quizzes/<quiz_id>/slug \
-H "Authorization: Bearer <access_token>" -H "If-Match: "3"" \
-H "Content-Type: application/json" -d '{"slug":"training-basics"}'
curl -X PUT https://dev-quizmachine.covecode.net/api/v1/quizzes/<quiz_id>/status \
-H "Authorization: Bearer <access_token>" -H "If-Match: "4"" \
-H "Content-Type: application/json" -d '{"status":"Open"}'
An update replaces the quiz definition: settings, pages, canvas blocks, and questions. The quiz keeps its ID, owner, publication state, custom link, AI providers, paywall, folder, and collected responses.
Update one question field
Every read returns an ETag header and, inside the package, stable ids for each question, option, and image. Granular edits, publishing or closing, and custom-link changes require an If-Match header naming the revision you last read; a stale value is refused with 412 Precondition Failed instead of silently overwriting a concurrent change.
PATCH a single question with a JSON Merge Patch body to change its body, bodyAllowMarkdown, points, isRequired, isDisabled, randomizeOptions, caseSensitiveMatch, matchingImmediateFeedback, immediateFeedback (for Matching, MatchingText, FillInTheBlanks, PictureChoice, Math, or HierarchyGraph), immediateFeedbackMaxAttempts (for Math or HierarchyGraph), allowNegativeScore, showFeedback, feedbackText, feedbackAllowMarkdown, aiEvaluationEnabled, modelAnswer, rubric, aiOnlyCodeEvaluation, codeStarterCode, codeReferenceSolution, codeTestCasesJson, mathWorkingAiFeedbackEnabled, mathExpectedWorking, mathWorkingRubric, childPictureChoiceResponseMode, childPictureChoiceMaxAttempts, tilesShuffleDepth, tilesMaximumMoves, tilesConfigurationVersion, tilesEngineVersion, or graphSearchDraftJson field without touching anything else — its id, options, images, topics, and page placement all stay exactly as they were.
curl -X PATCH https://dev-quizmachine.covecode.net/api/v1/quizzes/<quiz_id>/questions/<question_id> \
-H "Authorization: Bearer <access_token>" \
-H "If-Match: \"3\"" \
-H "Content-Type: application/merge-patch+json" \
-d '{"aiEvaluationEnabled":true,"modelAnswer":"Expected answer","rubric":"Key concepts"}'
Add media=references to a GET request to omit embedded image bytes and receive only metadata and a mediaAssetId where one exists. Use media=embedded, the default, for the complete portable package.
For a complete create-then-patch example with an inline base64 feedback image, see Embed images directly in question feedback.
POST /api/v1/quizzes/{id}/questions
This endpoint adds one question without replacing existing questions, options, images, or Topics. pageNumber must identify an existing page unless newPage is true. Embedded media is rejected; upload it first, then attach the returned media id.
curl -X POST https://dev-quizmachine.covecode.net/api/v1/quizzes/<quiz_id>/questions \
-H "Authorization: Bearer <access_token>" -H "If-Match: \"4\"" -H "Content-Type: application/json" \
-d '{"pageNumber":1,"order":2,"type":"FreeText","body":"Explain the result","points":1}'
POST · DELETE /api/v1/quizzes/{id}/pages
Create a page at position with type Standard or SectionBreak and an optional timeLimitSeconds. Set newPage on question creation to create and use a new page. Deleting a non-empty page requires deleteContents=true.
POST /api/v1/quizzes/<quiz_id>/pages
If-Match: "5"
{"position":2,"type":"SectionBreak","timeLimitSeconds":60}
POST /api/v1/quizzes/<quiz_id>/questions
If-Match: "6"
{"newPage":true,"type":"FreeText","body":"Explain the result","points":1}
DELETE /api/v1/quizzes/<quiz_id>/pages/2?deleteContents=true
If-Match: "7"
POST · PATCH · DELETE /api/v1/quizzes/{id}/text-media-blocks
Create, patch, move or reorder, and delete Text, Image, YouTube, Mermaid, and LatexArticle canvas blocks by stable id. PATCH applies only the fields relevant to each block type: Text (textContent, textAllowMarkdown, isHeader, presentation, tone, joinWithPrevious, layoutColumns, alignment, pageNumber, order), Image (mediaAssetId, altText, isIntroImage, presentation, tone, joinWithPrevious, layoutColumns, alignment, pageNumber, order), YouTube (youTubeVideoId, layoutColumns, alignment, pageNumber, order), Mermaid/LatexArticle (textContent, alignment, pageNumber, order). Use If-Match on every write; Image mediaAssetId changes also need media:write. newPage inserts a Standard page. LaTeX preview returns PDF or Problem Details, and paid-block entitlement follows the quiz owner's effective plan. Batch types are createBlock, patchBlock, and deleteBlock, reorderPage.
POST /api/v1/quizzes/<quiz_id>/text-media-blocks
If-Match: "8"
{"pageNumber":1,"order":2,"blockType":"Text","textContent":"## Context","textAllowMarkdown":true,"isHeader":true,"alignment":"Left","layoutColumns":2}
PATCH /api/v1/quizzes/<quiz_id>/text-media-blocks/<block_id>
Content-Type: application/merge-patch+json
{"pageNumber":2,"order":1,"alignment":"Center","layoutColumns":3}
POST /api/v1/quizzes/<quiz_id>/text-media-blocks/latex-preview
{"textContent":"\\documentclass{article}..."}
POST /api/v1/quizzes/<quiz_id>/text-media-blocks/latex-preview?format=pdf
{"textContent":"\\documentclass{article}..."}
DELETE /api/v1/quizzes/<quiz_id>/text-media-blocks/<block_id>
Topics
List and search your organization's Topics with topic:read; creating or assigning Topics requires topic:write. Send topicIds when creating a package or question, or topicNames to reuse existing Topics case-insensitively and create missing ones. PUT on a question's topics endpoint still replaces its Topic set atomically.
curl https://dev-quizmachine.covecode.net/api/v1/topics?search=heap -H "Authorization: Bearer <access_token>"
curl -X POST https://dev-quizmachine.covecode.net/api/v1/quizzes/<quiz_id>/questions \
-H "Authorization: Bearer <access_token>" -H "If-Match: \"4\"" -H "Content-Type: application/json" \
-d '{"pageNumber":1,"type":"FreeText","body":"What is minimax?","points":1,"topicIds":["<topic_id>"],"topicNames":["Game trees"]}'
curl -X PUT https://dev-quizmachine.covecode.net/api/v1/quizzes/<quiz_id>/questions/<question_id>/topics \
-H "Authorization: Bearer <access_token>" -H "If-Match: \"4\"" -H "Content-Type: application/json" \
-d '{"topicIds": ["<topic_id>"]}'
/operations · /validate
Validation is read-only. Mutating batches are atomic and require an Idempotency-Key, which clients should reuse only when retrying the same request body.
POST /api/v1/quizzes/<quiz_id>/validate
If-Match: "5"
POST /api/v1/quizzes/<quiz_id>/operations
If-Match: "5"
Idempotency-Key: <client-generated-value>
{"operations":[{"type":"createBlock","blockId":"<stable_id>","block":{"pageNumber":1,"blockType":"Mermaid","textContent":"graph TD; A-->B"}},{"type":"patchBlock","blockId":"<stable_id>","patch":{"order":3}},{"type":"deleteBlock","blockId":"<old_block_id>"}]}
POST /api/v1/media
Upload one PNG, JPEG, GIF, or WebP image, up to 5 MB, in the multipart/form-data field file. Send media:write and an Idempotency-Key; then attach the returned id to a supported image placement.
# Request media:write when minting the token for this call.
curl -X POST https://dev-quizmachine.covecode.net/api/v1/media \
-H "Authorization: Bearer <access_token>" -H "Idempotency-Key: <client-generated-value>" \
-F "file=@diagram.png"
POST /api/v1/quizzes/<quiz_id>/questions/<question_id>/images
PATCH /api/v1/quizzes/<quiz_id>/questions/<question_id>/images/<image_id>
PUT /api/v1/quizzes/<quiz_id>/questions/<question_id>/images/order
DELETE /api/v1/quizzes/<quiz_id>/questions/<question_id>/images/<image_id>
# Feedback images: attach the returned media id instead of base64 in feedbackText.
POST /api/v1/quizzes/{quizId}/questions/{questionId}/feedback-images
{"mediaAssetId":"<returned_media_id>","alignment":"Center","altText":"Worked solution"}
PATCH /api/v1/quizzes/{quizId}/questions/{questionId}/feedback-images/{imageId}
PUT /api/v1/quizzes/{quizId}/questions/{questionId}/feedback-images/order
DELETE /api/v1/quizzes/{quizId}/questions/{questionId}/feedback-images/{imageId}
# Option images; side is required for Matching questions.
PUT /api/v1/quizzes/{quizId}/questions/{questionId}/options/{optionId}/image
{"mediaAssetId":"<returned_media_id>","side":"Left"}
DELETE /api/v1/quizzes/{quizId}/questions/{questionId}/options/{optionId}/image
PUT /api/v1/quizzes/{quizId}/questions/{questionId}/diagram-reference-image
DELETE /api/v1/quizzes/{quizId}/questions/{questionId}/diagram-reference-image
PUT /api/v1/quizzes/{quizId}/text-media-blocks/{blockId}/image
Use the interactive API reference at /api/v1/docs, or consume the complete machine-readable contract at /api/v1/openapi.json.
/api/v1/docs
/api/v1/openapi.json
/api/v1/schema.json
Responses and limits
- 200 OK returns the requested quiz package, or the updated quiz ID, title, and editor URL.
- 201 Created returns the quiz ID, title, and editor URL.
- 400 rejects malformed schemas, invalid configuration, base64, or image signatures.
- 400 also rejects question body or feedback text over 65,536 characters and option text over 1,000 characters.
- 401 means the bearer token is missing or invalid.
- 403 means the account, plan, question type, or effective organization subscription is not eligible.
- 404 means no quiz with that ID exists inside your organization.
- 409 means that user already owns a quiz with the requested title.
- 412 Precondition Failed means If-Match is stale. Every granular and batch write can return it; fetch the current quiz, reapply the change, and retry.
- 429 means the edge rate limit or durable account creation quota has been reached. Wait before retrying.
- All API errors use application/problem+json Problem Details with standard title, detail, status, and instance fields.
Question body and feedback text are limited to 65,536 characters; option text is limited to 1,000. Uploading media or changing question, feedback, option, diagram-reference, or block images requires media:write; without it, media upload returns 403. Prefer feedback-image attachments to base64 data URLs, which count toward the text limit. Attachments appear below feedback in Take, Preview, Embed, results, and result PDFs, and can be managed in the question editor.
Plan for production limits
Requests are limited to 32 MB, 20 creations per minute at the edge, and 200 creations per day in durable account state. A reached creation limit returns 429.
Embedded PNG, JPEG, GIF, and WebP images are verified by content, limited to 2 MB each, and charged to the effective account's storage quota. Exceeding storage returns 403.
Mermaid diagrams in questions and feedback
Read the complete Quiz Creation API help guide