Create Tag
POST /v1/nextexams/tags
Create a tag
Scope questions:write.
Request
POST https://your-site.example/api/index.php/v1/nextexams/tags
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
title |
string |
No | Required on create. |
alias |
string |
No | |
published |
integer |
No | One of 0, 1. |
{
"title": "Calculator allowed"
}
Responses
201 — Created. data.id is the new record.
{
"data": {
"id": 42
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
Errors
| Status | Code | When |
|---|---|---|
400 |
BAD_REQUEST |
The body failed validation, or is not a JSON object (INVALID_JSON). |
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). |
Examples
curl
curl -s -X POST "https://your-site.example/api/index.php/v1/nextexams/tags" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title":"Calculator allowed"}'
PHP
<?php
$ch = curl_init('https://your-site.example/api/index.php/v1/nextexams/tags');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('API_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => '{"title":"Calculator allowed"}',
]);
$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/tags", {
method: 'POST',
headers: {
"Authorization": `Bearer ${API_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"title": "Calculator allowed"
}),
});
const data = await response.json();