Contents
On this page

Update Subject - Plugixa Exam

PUT /plugixa-exam/v1/subjects/{id}

Replace a subject’s fields, and move it under another parent if parent_id changes.

Scope subjects:write; the token’s user needs the subjects:edit permission.

Note. This is a full replace, not a merge. A field you leave out goes back to its create default: published becomes false, description becomes empty, code becomes null, slug is made again from the title, and a missing parent_id is 0, which moves the subject to the top level. Read the subject first with Get Subject and send every field back.

Request

PUT https://your-site.example/wp-json/plugixa-exam/v1/subjects/12

Path parameters

Name Type Description
id integer The subject’s id

Request body

Content type: application/json

Field Type Required Description
title string Yes Must not be blank.
slug string No Made from the title when empty. Made unique by appending -2, -3, …
code string No Your own reference. Must be unique among live subjects. Empty or omitted clears it to null.
description string No HTML. Tags outside the question-text allow-list are stripped. Omitted means empty.
parent_id integer No 0 for the top level, which is also what omitting it means. Must be an existing subject, not this subject or one of its descendants. Subjects nest at most 10 levels deep.
published boolean No Omitted means false: the subject becomes unpublished.

When parent_id changes, the subject moves with its whole branch: the path and level of every descendant are rewritten, and the subject is placed last under its new parent. When parent_id stays the same, its position is kept. level, path and ordering are worked out for you; values sent for them are ignored. To change the order of siblings, use Reorder Subjects.

{
  "title": "Algebra",
  "slug": "algebra",
  "code": "MATH-ALG",
  "description": "<p>Equations, expressions and functions.</p>",
  "parent_id": 3,
  "published": true
}

Responses

200 OK. data is the updated subject.

{
  "success": true,
  "data": {
    "id": 12,
    "parent_id": 3,
    "path": "3/12",
    "level": 2,
    "code": "MATH-ALG",
    "title": "Algebra",
    "slug": "algebra",
    "description": "<p>Equations, expressions and functions.</p>",
    "ordering": 4,
    "published": true,
    "created_at": "2026-11-12 09:30:00",
    "modified_at": "2026-11-12 10:15:00",
    "created_by": 1,
    "modified_by": 1,
    "deleted_at": null
  }
}
Field Type Meaning
data.parent_id integer 0 at the top level
data.path string The ids from the top level down to this subject, rewritten after a move
data.level integer Depth, from 1
data.ordering integer Position among its siblings: last after a move
data.published boolean Whether the subject is published
data.modified_at string UTC datetime of this change

Errors

Status Code When
404 plugixa_exam_not_found No subject with that id, or the subject is in the trash.
400 plugixa_exam_title_required title is missing or blank.
400 plugixa_exam_invalid_parent parent_id is not an existing subject.
400 plugixa_exam_circular_parent parent_id is this subject or one of its descendants.
400 plugixa_exam_too_deep The subject would sit more than 10 levels deep.
409 plugixa_exam_code_taken Another subject already uses code.

Plus the errors every endpoint can return.

Examples

curl -s -X PUT "https://your-site.example/wp-json/plugixa-exam/v1/subjects/12" \
  -H "Authorization: Bearer $PLUGIXA_EXAM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title":"Algebra","slug":"algebra","code":"MATH-ALG","description":"<p>Equations, expressions and functions.</p>","parent_id":3,"published":true}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-exam/v1/subjects/12');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'PUT',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Bearer ' . getenv('PLUGIXA_EXAM_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS     => json_encode([
        'title'       => 'Algebra',
        'slug'        => 'algebra',
        'code'        => 'MATH-ALG',
        'description' => '<p>Equations, expressions and functions.</p>',
        'parent_id'   => 3,
        'published'   => true,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-exam/v1/subjects/12', {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${process.env.PLUGIXA_EXAM_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    title: 'Algebra',
    slug: 'algebra',
    code: 'MATH-ALG',
    description: '<p>Equations, expressions and functions.</p>',
    parent_id: 3,
    published: true,
  }),
});
const { data } = await response.json();

Quick Links

Share