> For the complete documentation index, see [llms.txt](https://guide.fariaedu.com/integrations-portal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.fariaedu.com/integrations-portal/managebac/public-rest-apis/v2p0/memberships.md).

# Memberships

A membership defines the kind of association between a class and a student or teacher

## Get Students for a Class

> This endpoint retrieves all students belonging to a class as specified by class ID.\
> \
> The response includes an array of student IDs and, for classes with subject levels enabled,\
> a mapping of student IDs to their level (SL or HL).<br>

```json
{"openapi":"3.0.3","info":{"title":"API V2P0","version":"v2p0"},"tags":[{"name":"Memberships","description":"A membership defines the kind of association between a class and a student or teacher"}],"servers":[{"url":"https://api.managebac.com","description":"CA ManageBac API server."},{"url":"https://api.managebac.cn","description":"CN ManageBac API server."},{"url":"https://api.us.managebac.com","description":"US1 ManageBac API server."},{"url":"https://api.managebac.us","description":"US2 ManageBac API server."},{"url":"https://api.managebactest.com","description":"UAT ManageBac API server."},{"url":"https://{Host}","variables":{"Host":{"default":"api.devel.managebac.com","enum":["api.devel.managebac.com","api-faria.devel.managebac.com","api.managebac.dev"]}}}],"security":[{"bearerAuth":[]},{"authTokenQuery":[]},{"authTokenHeader":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"OAuth 2.0 Bearer token obtained via client credentials grant. Pass the token in the Authorization header as `Bearer <token>`."},"authTokenQuery":{"type":"apiKey","name":"auth_token","in":"query","description":"Your V2 API authentication token may be passed in the parameters. To protect your key, use [environment variables](https://cloud.google.com/docs/authentication/api-keys#securing_an_api_key)."},"authTokenHeader":{"type":"apiKey","name":"auth-token","in":"header","description":"Your V2 API authentication token may be passed in the header. To protect your key, use [environment variables](https://cloud.google.com/docs/authentication/api-keys#securing_an_api_key)."}}},"paths":{"/v2p0/classes/{class_id}/students":{"get":{"summary":"Get Students for a Class","operationId":"getStudentsForClass","tags":["Memberships"],"description":"This endpoint retrieves all students belonging to a class as specified by class ID.\n\nThe response includes an array of student IDs and, for classes with subject levels enabled,\na mapping of student IDs to their level (SL or HL).\n","parameters":[{"name":"class_id","in":"path","description":"Unique identifier for class.","required":true,"schema":{"type":"integer"}},{"name":"include_archived_students","in":"query","required":false,"schema":{"type":"boolean","default":false}},{"name":"student_ids","in":"query","required":false,"description":"List of student ids. Accepts repeated params or a comma-separated string.","style":"form","explode":true,"schema":{"type":"array","items":{"type":"integer"}}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"401":{"description":"Unauthorized"},"404":{"description":"Not Found"}}}}}}
```

## Get all Memberships

> Retrieves all class memberships for the school, including students, teachers, and administrators.\
> Each record contains the class ID, user ID, user role, and timestamps. Results can be filtered\
> by class IDs, user IDs, modification date, deletion date, and date range.<br>

```json
{"openapi":"3.0.3","info":{"title":"API V2P0","version":"v2p0"},"tags":[{"name":"Memberships","description":"A membership defines the kind of association between a class and a student or teacher"}],"servers":[{"url":"https://api.managebac.com","description":"CA ManageBac API server."},{"url":"https://api.managebac.cn","description":"CN ManageBac API server."},{"url":"https://api.us.managebac.com","description":"US1 ManageBac API server."},{"url":"https://api.managebac.us","description":"US2 ManageBac API server."},{"url":"https://api.managebactest.com","description":"UAT ManageBac API server."},{"url":"https://{Host}","variables":{"Host":{"default":"api.devel.managebac.com","enum":["api.devel.managebac.com","api-faria.devel.managebac.com","api.managebac.dev"]}}}],"security":[{"bearerAuth":[]},{"authTokenQuery":[]},{"authTokenHeader":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"OAuth 2.0 Bearer token obtained via client credentials grant. Pass the token in the Authorization header as `Bearer <token>`."},"authTokenQuery":{"type":"apiKey","name":"auth_token","in":"query","description":"Your V2 API authentication token may be passed in the parameters. To protect your key, use [environment variables](https://cloud.google.com/docs/authentication/api-keys#securing_an_api_key)."},"authTokenHeader":{"type":"apiKey","name":"auth-token","in":"header","description":"Your V2 API authentication token may be passed in the header. To protect your key, use [environment variables](https://cloud.google.com/docs/authentication/api-keys#securing_an_api_key)."}},"schemas":{"Membership":{"type":"object","description":"Represents a user’s enrollment in a class, with their role and level.","properties":{"id":{"type":"integer","description":"Unique numeric identifier for this membership record."},"user_id":{"type":"integer","description":"ManageBac ID of the user (student or teacher) in this membership."},"level":{"type":"integer","description":"Course level for IB Diploma classes. 0 = Standard Level (SL), 1 = Higher Level (HL). Not applicable for non-IB programs.","enum":[0,1]},"created_at":{"type":"string","description":"When this membership was created, in ISO 8601 format."},"updated_at":{"type":"string","description":"When this membership was last modified, in ISO 8601 format."},"class_id":{"type":"integer","description":"ManageBac ID of the class this membership belongs to."},"user_email":{"type":"string","description":"Email address of the enrolled user."},"uniq_class_id":{"type":"string","description":"The school’s own unique identifier for the class (set by the school, not by ManageBac)."},"uniq_student_id":{"type":"string","description":"The school’s own unique identifier for the student (same as student_id on the Student schema)."},"role":{"type":"string","description":"The user’s role in this class, either \"student\" or \"teacher\"."}}},"Meta":{"type":"object","description":"Pagination metadata included in all list (index) responses.","properties":{"current_page":{"type":"integer","description":"The page number of the current result set, starting from 1."},"total_pages":{"type":"integer","description":"The total number of pages available for this query."},"total_count":{"type":"integer","description":"The total number of records matching the query across all pages."},"per_page":{"type":"integer","description":"The number of records returned per page. Defaults to 100; can be overridden with the per_page query parameter (max 200)."}}},"AccessDeniedError":{"type":"object","description":"Returned when the API token is missing, invalid, or has been disabled.","properties":{"error":{"type":"string","description":"Always returns \"Access Denied\" when authentication fails. Check that your API token is valid and enabled."}}}}},"paths":{"/v2p0/memberships":{"get":{"summary":"Get all Memberships","operationId":"listMemberships","tags":["Memberships"],"description":"Retrieves all class memberships for the school, including students, teachers, and administrators.\nEach record contains the class ID, user ID, user role, and timestamps. Results can be filtered\nby class IDs, user IDs, modification date, deletion date, and date range.\n","parameters":[{"name":"class_ids[]","in":"query","required":false,"allowReserved":true,"style":"form","explode":true,"schema":{"type":"array","items":{"type":"integer"}},"description":"The list of class IDs to select membership for"},{"name":"modified_since","in":"query","description":"A timestamp to filter the modification date of results.","required":false,"schema":{"type":"string"}},{"name":"deleted_since","in":"query","description":"A timestamp to filter the deletion date of results.","required":false,"schema":{"type":"string"}},{"name":"page","in":"query","description":"An integer defining which page to display.","required":false,"schema":{"type":"string"}},{"name":"per_page","in":"query","description":"An integer defining the number of records to display per page.","required":false,"schema":{"type":"string"}},{"name":"user_ids[]","in":"query","description":"An integer list of users ids to filter by.","required":false,"schema":{"type":"array","items":{"type":"integer"}},"style":"form","explode":true},{"name":"user_ids","in":"query","description":"An integer list of users ids to filter by.","required":false,"schema":{"type":"array","items":{"type":"integer"}},"style":"form","explode":false},{"name":"class_happens_on","in":"query","description":"A date param to filter by start term and end term date range.","required":false,"schema":{"type":"string","format":"date"}},{"name":"student_ids","in":"query","required":false,"description":"List of student ids. Accepts repeated params or a comma-separated string.","style":"form","explode":true,"schema":{"type":"array","items":{"type":"integer"}}}],"responses":{"200":{"description":"successful","content":{"application/json":{"schema":{"type":"object","properties":{"memberships":{"type":"array","items":{"$ref":"#/components/schemas/Membership"}},"meta":{"$ref":"#/components/schemas/Meta"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessDeniedError"}}}}}}}}}
```

## Get a Student's memberships

> Retrieves all memberships for a student, organized by type: classes, groups, and year groups.\
> Each membership includes its ID, name, and archived status. Classes also include \<code>uniq\_id\</code>,\
> \<code>start\_term\_id\</code>, and \<code>end\_term\_id\</code>. Year groups include the \<code>program\</code> field.\
> By default only active (non-archived) memberships are returned.<br>

```json
{"openapi":"3.0.3","info":{"title":"API V2P0","version":"v2p0"},"tags":[{"name":"Memberships","description":"A membership defines the kind of association between a class and a student or teacher"}],"servers":[{"url":"https://api.managebac.com","description":"CA ManageBac API server."},{"url":"https://api.managebac.cn","description":"CN ManageBac API server."},{"url":"https://api.us.managebac.com","description":"US1 ManageBac API server."},{"url":"https://api.managebac.us","description":"US2 ManageBac API server."},{"url":"https://api.managebactest.com","description":"UAT ManageBac API server."},{"url":"https://{Host}","variables":{"Host":{"default":"api.devel.managebac.com","enum":["api.devel.managebac.com","api-faria.devel.managebac.com","api.managebac.dev"]}}}],"security":[{"bearerAuth":[]},{"authTokenQuery":[]},{"authTokenHeader":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"OAuth 2.0 Bearer token obtained via client credentials grant. Pass the token in the Authorization header as `Bearer <token>`."},"authTokenQuery":{"type":"apiKey","name":"auth_token","in":"query","description":"Your V2 API authentication token may be passed in the parameters. To protect your key, use [environment variables](https://cloud.google.com/docs/authentication/api-keys#securing_an_api_key)."},"authTokenHeader":{"type":"apiKey","name":"auth-token","in":"header","description":"Your V2 API authentication token may be passed in the header. To protect your key, use [environment variables](https://cloud.google.com/docs/authentication/api-keys#securing_an_api_key)."}},"schemas":{"AccessDeniedError":{"type":"object","description":"Returned when the API token is missing, invalid, or has been disabled.","properties":{"error":{"type":"string","description":"Always returns \"Access Denied\" when authentication fails. Check that your API token is valid and enabled."}}},"NotFound":{"type":"object","description":"Returned when the requested resource cannot be found by the given ID.","properties":{"error":{"type":"string","description":"A human-readable message indicating which resource could not be found, including the model name and the ID that was looked up."}}}}},"paths":{"/v2p0/students/{id}/memberships":{"get":{"summary":"Get a Student's memberships","operationId":"getStudentMemberships","tags":["Memberships"],"description":"Retrieves all memberships for a student, organized by type: classes, groups, and year groups.\nEach membership includes its ID, name, and archived status. Classes also include <code>uniq_id</code>,\n<code>start_term_id</code>, and <code>end_term_id</code>. Year groups include the <code>program</code> field.\nBy default only active (non-archived) memberships are returned.\n","parameters":[{"name":"id","in":"path","description":"Unique identifier of a student.","schema":{"type":"integer"},"required":true},{"name":"archived","in":"query","description":"Filter memberships by archived status. When <code>false</code> (default), returns only active memberships. When <code>true</code>, returns only archived memberships.","schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"memberships":{"type":"object","properties":{"classes":{"type":"array","items":{"allOf":[{"type":"object","properties":{"id":{"type":"integer"},"uniq_id":{"type":"string"},"name":{"type":"string"},"archived":{"type":"boolean"},"start_term_id":{"type":"integer"},"end_term_id":{"type":"integer"}}}]}},"groups":{"type":"array","items":{"allOf":[{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"archived":{"type":"boolean"}}}]}},"year_groups":{"type":"array","items":{"allOf":[{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"program":{"type":"string"},"archived":{"type":"boolean"}}}]}}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessDeniedError"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFound"}}}}}}}}}
```
