Set Exam Status
POST /v1/nextexams/exams/{id}/status
Publish or unpublish an exam
Scope exams:publish; the role needs exams.publish.
Request
POST https://your-site.example/api/index.php/v1/nextexams/exams/{id}/status
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
id |
integer |
path |
Yes | The record's id. (min 1) |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
published |
boolean |
Yes |
{
"published": true
}
Responses
200 — The new state.
{
"data": {
"id": 1,
"published": true
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
|
data.published |
boolean |
Errors
| Status | Code | When |
|---|---|---|
401 |
INVALID_TOKEN |
No token (MISSING_TOKEN), or one that is wrong, expired, revoked, or whose owner can no longer sign in (INVALID_TOKEN). |
403 |
MISSING_SCOPE |
The token is valid but this request is not allowed, and code says why: MISSING_SCOPE (the token lacks the scope), FORBIDDEN (the owner's role does not allow it), ACCESS_DENIED (the owner cannot manage Next Exams), API_DISABLED (the API Tokens app is off), APP_DISABLED (the feature's app is off — meta.app names it), ACCOUNT_UNUSABLE (the owner is blocked or must reset their password), DEMO_LOCKED (a demo site). |
404 |
NOT_FOUND |
No record has this id. |
Examples
curl
curl -s -X POST "https://your-site.example/api/index.php/v1/nextexams/exams/1/status" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"published":true}'
PHP
<?php
$ch = curl_init('https://your-site.example/api/index.php/v1/nextexams/exams/1/status');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('API_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => '{"published":true}',
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
JavaScript
const API_TOKEN = process.env.API_TOKEN;
const response = await fetch("https://your-site.example/api/index.php/v1/nextexams/exams/1/status", {
method: 'POST',
headers: {
"Authorization": `Bearer ${API_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"published": true
}),
});
const data = await response.json();