> For the complete documentation index, see [llms.txt](https://docs.stellic.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stellic.com/stellic-partner-api/audits/remove-a-sub-requirement.md).

# Remove a sub-requirement

Use this endpoint to delete a requirement or course from under its parent in a draft audit. `{subrequirement_id}` must be a direct child of `{parent_req_id}`, and the parent must be in the draft `{audit_id}`; for a course, use the node's `id`, not `course_parent_id`. Students aren't affected until you publish.

## DELETE /audits/{audit\_id}/requirements/{parent\_req\_id}/subrequirements/{subrequirement\_id}

>

```json
{"openapi":"3.0.0","info":{"title":"Stellic for Developers","version":"1.0"},"tags":[{"name":"Audits","description":"Read, draft, edit, and publish an audit's requirement tree. Edits go to a draft; publishing recomputes student progress in the background."}],"servers":[{"url":"https://{institution}.stellic.com/partnerapi/v1","variables":{"institution":{"default":"{institution}","description":"Your institution's Stellic subdomain: the part before `.stellic.com` in the URL you use to sign in. It becomes the host in every request, as in `https://{institution}.stellic.com/partnerapi/v1/...`. Replace the `{institution}` placeholder with your subdomain before sending."}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Personal Access Token issued by your Stellic integration partner. Send it as `Authorization: Bearer <token>` on every request. One token per institution; do not share across environments."}},"schemas":{"RemoveSubrequirementResponse":{"type":"object","properties":{"success":{"type":"boolean"},"pending_change":{"type":"object","nullable":true,"allOf":[{"$ref":"#/components/schemas/PendingChange"}],"description":"`null` when the removal only undid an add made on this draft."},"issues":{"type":"array","description":"Warnings raised by the removal (today, milestone-related). Present only when a change record was written.","items":{"type":"object"}}}},"PendingChange":{"type":"object","description":"A draft change queued for replay onto the published version when the draft is published.","properties":{"user":{"$ref":"#/components/schemas/PendingChangeUser"},"text":{"type":"string","description":"Plain-language summary of the change."},"timestamp":{"type":"string","description":"When the change was recorded, as `YYYY-MM-DD HH:MM:SS.ffffff+00:00`."}}},"PendingChangeUser":{"type":"object","description":"The account that made the change, as recorded on the change record.","properties":{"username":{"type":"string"},"display_username":{"type":"string"},"userid":{"type":"string","nullable":true},"title":{"type":"string","nullable":true},"first_name":{"type":"string"},"last_name":{"type":"string"},"photo_url":{"type":"string","nullable":true},"email":{"type":"string"},"sms_alerts_enabled":{"type":"boolean"},"last_log_in":{"type":"string","nullable":true},"is_active":{"type":"boolean"},"is_admin":{"type":"boolean"},"role":{"type":"string","nullable":true},"mobile_number":{"type":"string","nullable":true},"hash":{"type":"string","description":"Opaque account token. Ignore it."}}},"ErrorMessage":{"type":"object","description":"Error envelope used by the programs, audits, and requirements endpoints.","properties":{"error":{"type":"string","description":"Human-readable reason. Match on it if you need to branch; the strings on each endpoint page are verbatim."}}}}},"paths":{"/audits/{audit_id}/requirements/{parent_req_id}/subrequirements/{subrequirement_id}":{"delete":{"tags":["Audits"],"parameters":[{"name":"audit_id","in":"path","required":true,"description":"Internal numeric ID of the draft audit you are editing.","schema":{"type":"integer"}},{"name":"parent_req_id","in":"path","required":true,"description":"Internal numeric ID of the parent requirement. Must belong to `audit_id`.","schema":{"type":"integer"}},{"name":"subrequirement_id","in":"path","required":true,"description":"Internal numeric ID of the sub-requirement to remove. Must currently sit under `parent_req_id`. For a course, use the course node's `id`, not its `course_parent_id`.","schema":{"type":"integer"}}],"responses":{"200":{"description":"Sub-requirement removed from the draft. `pending_change` is the change record that will be replayed on publish; it is `null` when the removal simply undoes an add you made on this draft. `issues` lists follow-up warnings (today: milestone-related) and is present only when a change record was written.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveSubrequirementResponse"}}}},"400":{"description":"Validation failure.\n\nCommon causes:\n- Parent is not in this audit, including a parent with no audit - returns `Parent requirement {parent_req_id} does not belong to audit {audit_id}`\n- Not a child of that parent - returns `Requirement {subrequirement_id} is not a subrequirement of parent {parent_req_id}`\n- A double-count constraint outside the subtree being removed has a destination reference to the node or one of its descendants, including course nodes - returns `In order to delete [{name}] please remove it from double count constraint on [{other name}].` When several such references block removal, their messages are joined with spaces in the `error` string.\n- A program-dependent constraint on the parent still references it - returns `In order to remove {name} please first remove it from the Program-dependent constraint on {parent name}.`","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"401":{"description":"Missing or invalid Bearer token.","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}},"403":{"description":"Your IP address isn't on the allowlist for this endpoint. Contact Stellic to add it; the response includes the `client_ip` Stellic saw. Also returned, with only `error` set, when the audit isn't a draft (`Can only remove subrequirements from draft audits.`) or belongs to a compliance requirement (`Compliance requirements are not available via the API.`).","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"client_ip":{"type":"string"}}}}}},"404":{"description":"Audit, parent requirement, or sub-requirement not found. `detail` is `No Audit matches the given query.` or `No Requirement matches the given query.`.","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"}}}}}}}}}}}
```

#### What happens after the call

* A requirement is deleted from the draft along with everything under it. A course or a linked shared requirement is only detached; the course and the shared requirement are unchanged.
* The removal is recorded and applied when you publish. If you're removing a requirement you added on its own in this draft, the add is dropped instead, and `pending_change` is `null`.
* Publishing checks whether removed requirements held student exceptions or planned courses. If they did, the API publish returns a 400, and the draft has to be published in Stellic.

#### Notes

* **Clear the rules that point at the node or its descendants first.** Remove double-count destination references to the node or anything under it, including course nodes, from rules outside the subtree being removed. Also remove references to the node from program-dependent rules on the parent.
* **To keep a shared requirement's content, unlink it instead.** [Unlinking](/stellic-partner-api/audits/unlink-a-shared-requirement.md) leaves an editable copy; removing drops the block.
* **Only drafts can be edited.** A published or under-review audit returns a 403 with `Can only remove subrequirements from draft audits.`
* **Mismatched IDs return 400s that name the problem,** such as `Parent requirement <id> does not belong to audit <id>` or `Requirement <id> is not a subrequirement of parent <id>`. A compliance requirement's audit returns a 403.

#### Related APIs

* [`GET /audits/{audit_id}`](/stellic-partner-api/audits/read-an-audit.md) to confirm the IDs.
* [`DELETE /requirements/{requirement_id}/constraints/{constraint_id}`](/stellic-partner-api/requirements/remove-a-requirement-constraint.md) to remove a rule that blocks the removal.
* [`POST /audits/{audit_id}/publish`](/stellic-partner-api/audits/publish-a-draft-audit.md) to publish the draft.
