Students

Add domain memberships to a student

Changed on

Grant the student membership to one or more domains.

The request body is the canonical {data: [{type: "domains", id: ...}]} envelope — each item is a domain resource identifier (the student is in the path). This is the (re)activation path (there is no PATCH): a new membership is created active, an inactive membership (e.g. after a prior DELETE) is reactivated, and an already-active membership is a idempotent no-op — returned as succeeded with no separate already_exists code and no event. See batch_add_domain_memberships for the create-vs-reactivate semantics and the delegation to Domain.add_member.

Within-batch duplicate detection is first-wins on id (the domain id), with the JSON:API source pointer at /data/{i}/id. Response is 200 if all items succeed, 207 if any fail, 400 if the request envelope is empty or over the cap.

The student lookup runs before the envelope guard so a missing student is reported as 404 regardless of body content.

exclude_none=True matches the batch-envelope convention shared by every sibling batch endpoint (assets, courses, lessons): null attributes such as an unset expires_at are omitted here, whereas the GET list renders them as null. Same resource, two serializers — the drift is inherent to the batch-vs-list convention across api_v2, not specific to this route.

See api_v2/docs/batch-responses.md for the envelope shape and api_v2/docs/domain-memberships.md for the design.

Required OAuth scope: students:write

post/v2/students/{id}/relationships/domain-memberships/

Request

Path parameters

idstring required

Request body

Response

OK

Changes

    • warning

      added the new already_in_path enum value to the //// response property for the response status

    • warning

      added the new already_in_path enum value to the //// response property for the response status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      endpoint added