> For the complete documentation index, see [llms.txt](https://documentation.ocsinventory-ng.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.ocsinventory-ng.org/open-api-reference/users.md).

# Users

## GET /users/

> This class will define the view behavior\
> \
> Args:\
> &#x20;   viewsets (\[OCSVIewSet])

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"PaginatedUserList":{"type":"object","required":["count","results"],"properties":{"count":{"type":"integer"},"next":{"type":"string","nullable":true,"format":"uri"},"previous":{"type":"string","nullable":true,"format":"uri"},"results":{"type":"array","items":{"$ref":"#/components/schemas/User"}}}},"User":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"username":{"type":"string","description":"Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.","pattern":"^[\\w.@+-]+$","maxLength":150},"email":{"title":"Email address","oneOf":[{"type":"string","format":"email","maxLength":254},{"type":"string","maxLength":0}]},"first_name":{"type":"string","maxLength":150},"last_name":{"type":"string","maxLength":150},"password":{"type":"string","writeOnly":true,"maxLength":128},"is_superuser":{"type":"boolean","title":"Superuser status","description":"Designates that this user has all permissions without explicitly assigning them."},"groups":{"type":"array","items":{"type":"integer"},"description":"The groups this user belongs to. A user will get all permissions granted to each of their groups."},"group_assignments":{"type":"string","readOnly":true},"user_permissions":{"type":"array","items":{"type":"integer"},"description":"Specific permissions for this user."}},"required":["group_assignments","id","password","username"]}}},"paths":{"/users/":{"get":{"operationId":"users_list","description":"This class will define the view behavior\n\nArgs:\n    viewsets ([OCSVIewSet])","parameters":[{"in":"query","name":"date_joined","schema":{"type":"string","format":"date-time"}},{"in":"query","name":"email","schema":{"type":"string"}},{"in":"query","name":"first_name","schema":{"type":"string"}},{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"query","name":"groups","schema":{"type":"array","items":{"type":"integer"}},"explode":true,"style":"form"},{"in":"query","name":"is_active","schema":{"type":"boolean"}},{"in":"query","name":"is_staff","schema":{"type":"boolean"}},{"in":"query","name":"is_superuser","schema":{"type":"boolean"}},{"in":"query","name":"last_login","schema":{"type":"string","format":"date-time"}},{"in":"query","name":"last_name","schema":{"type":"string"}},{"name":"limit","required":false,"in":"query","description":"Number of results to return per page.","schema":{"type":"integer"}},{"name":"offset","required":false,"in":"query","description":"The initial index from which to return the results.","schema":{"type":"integer"}},{"name":"ordering","required":false,"in":"query","description":"Which field to use when ordering the results.","schema":{"type":"string"}},{"in":"query","name":"password","schema":{"type":"string"}},{"name":"search","required":false,"in":"query","description":"A search term.","schema":{"type":"string"}},{"in":"query","name":"user_permissions","schema":{"type":"array","items":{"type":"integer"}},"explode":true,"style":"form"},{"in":"query","name":"username","schema":{"type":"string"}}],"tags":["users"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedUserList"}},"application/xml":{"schema":{"$ref":"#/components/schemas/PaginatedUserList"}}},"description":""}}}}}}
```

## POST /users/

> Handle post request, suitable for single and multi creation\
> \
> Args:\
> &#x20;   request (\[dict]): can be dict or list of dicts\
> \
> Returns:\
> &#x20;   \[type]: \[description]

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"User":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"username":{"type":"string","description":"Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.","pattern":"^[\\w.@+-]+$","maxLength":150},"email":{"title":"Email address","oneOf":[{"type":"string","format":"email","maxLength":254},{"type":"string","maxLength":0}]},"first_name":{"type":"string","maxLength":150},"last_name":{"type":"string","maxLength":150},"password":{"type":"string","writeOnly":true,"maxLength":128},"is_superuser":{"type":"boolean","title":"Superuser status","description":"Designates that this user has all permissions without explicitly assigning them."},"groups":{"type":"array","items":{"type":"integer"},"description":"The groups this user belongs to. A user will get all permissions granted to each of their groups."},"group_assignments":{"type":"string","readOnly":true},"user_permissions":{"type":"array","items":{"type":"integer"},"description":"Specific permissions for this user."}},"required":["group_assignments","id","password","username"]}}},"paths":{"/users/":{"post":{"operationId":"users_create","description":"Handle post request, suitable for single and multi creation\n\nArgs:\n    request ([dict]): can be dict or list of dicts\n\nReturns:\n    [type]: [description]","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}}],"tags":["users"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/User"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/User"}},"application/json":{"schema":{"$ref":"#/components/schemas/User"}},"application/xml":{"schema":{"$ref":"#/components/schemas/User"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}},"application/xml":{"schema":{"$ref":"#/components/schemas/User"}}},"description":""}}}}}}
```

## GET /users/{id}/

> This class will define the view behavior\
> \
> Args:\
> &#x20;   viewsets (\[OCSVIewSet])

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"User":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"username":{"type":"string","description":"Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.","pattern":"^[\\w.@+-]+$","maxLength":150},"email":{"title":"Email address","oneOf":[{"type":"string","format":"email","maxLength":254},{"type":"string","maxLength":0}]},"first_name":{"type":"string","maxLength":150},"last_name":{"type":"string","maxLength":150},"password":{"type":"string","writeOnly":true,"maxLength":128},"is_superuser":{"type":"boolean","title":"Superuser status","description":"Designates that this user has all permissions without explicitly assigning them."},"groups":{"type":"array","items":{"type":"integer"},"description":"The groups this user belongs to. A user will get all permissions granted to each of their groups."},"group_assignments":{"type":"string","readOnly":true},"user_permissions":{"type":"array","items":{"type":"integer"},"description":"Specific permissions for this user."}},"required":["group_assignments","id","password","username"]}}},"paths":{"/users/{id}/":{"get":{"operationId":"users_retrieve","description":"This class will define the view behavior\n\nArgs:\n    viewsets ([OCSVIewSet])","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"path","name":"id","schema":{"type":"integer"},"description":"A unique integer value identifying this user.","required":true}],"tags":["users"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}},"application/xml":{"schema":{"$ref":"#/components/schemas/User"}}},"description":""}}}}}}
```

## PUT /users/{id}/

> This class will define the view behavior\
> \
> Args:\
> &#x20;   viewsets (\[OCSVIewSet])

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"User":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"username":{"type":"string","description":"Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.","pattern":"^[\\w.@+-]+$","maxLength":150},"email":{"title":"Email address","oneOf":[{"type":"string","format":"email","maxLength":254},{"type":"string","maxLength":0}]},"first_name":{"type":"string","maxLength":150},"last_name":{"type":"string","maxLength":150},"password":{"type":"string","writeOnly":true,"maxLength":128},"is_superuser":{"type":"boolean","title":"Superuser status","description":"Designates that this user has all permissions without explicitly assigning them."},"groups":{"type":"array","items":{"type":"integer"},"description":"The groups this user belongs to. A user will get all permissions granted to each of their groups."},"group_assignments":{"type":"string","readOnly":true},"user_permissions":{"type":"array","items":{"type":"integer"},"description":"Specific permissions for this user."}},"required":["group_assignments","id","password","username"]}}},"paths":{"/users/{id}/":{"put":{"operationId":"users_update","description":"This class will define the view behavior\n\nArgs:\n    viewsets ([OCSVIewSet])","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"path","name":"id","schema":{"type":"integer"},"description":"A unique integer value identifying this user.","required":true}],"tags":["users"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/User"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/User"}},"application/json":{"schema":{"$ref":"#/components/schemas/User"}},"application/xml":{"schema":{"$ref":"#/components/schemas/User"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}},"application/xml":{"schema":{"$ref":"#/components/schemas/User"}}},"description":""}}}}}}
```

## DELETE /users/{id}/

> This class will define the view behavior\
> \
> Args:\
> &#x20;   viewsets (\[OCSVIewSet])

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}}},"paths":{"/users/{id}/":{"delete":{"operationId":"users_destroy","description":"This class will define the view behavior\n\nArgs:\n    viewsets ([OCSVIewSet])","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"path","name":"id","schema":{"type":"integer"},"description":"A unique integer value identifying this user.","required":true}],"tags":["users"],"responses":{"204":{"description":"No response body"}}}}}}
```

## PATCH /users/{id}/

> This class will define the view behavior\
> \
> Args:\
> &#x20;   viewsets (\[OCSVIewSet])

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"PatchedUser":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"username":{"type":"string","description":"Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.","pattern":"^[\\w.@+-]+$","maxLength":150},"email":{"title":"Email address","oneOf":[{"type":"string","format":"email","maxLength":254},{"type":"string","maxLength":0}]},"first_name":{"type":"string","maxLength":150},"last_name":{"type":"string","maxLength":150},"password":{"type":"string","writeOnly":true,"maxLength":128},"is_superuser":{"type":"boolean","title":"Superuser status","description":"Designates that this user has all permissions without explicitly assigning them."},"groups":{"type":"array","items":{"type":"integer"},"description":"The groups this user belongs to. A user will get all permissions granted to each of their groups."},"group_assignments":{"type":"string","readOnly":true},"user_permissions":{"type":"array","items":{"type":"integer"},"description":"Specific permissions for this user."}}},"User":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"username":{"type":"string","description":"Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.","pattern":"^[\\w.@+-]+$","maxLength":150},"email":{"title":"Email address","oneOf":[{"type":"string","format":"email","maxLength":254},{"type":"string","maxLength":0}]},"first_name":{"type":"string","maxLength":150},"last_name":{"type":"string","maxLength":150},"password":{"type":"string","writeOnly":true,"maxLength":128},"is_superuser":{"type":"boolean","title":"Superuser status","description":"Designates that this user has all permissions without explicitly assigning them."},"groups":{"type":"array","items":{"type":"integer"},"description":"The groups this user belongs to. A user will get all permissions granted to each of their groups."},"group_assignments":{"type":"string","readOnly":true},"user_permissions":{"type":"array","items":{"type":"integer"},"description":"Specific permissions for this user."}},"required":["group_assignments","id","password","username"]}}},"paths":{"/users/{id}/":{"patch":{"operationId":"users_partial_update","description":"This class will define the view behavior\n\nArgs:\n    viewsets ([OCSVIewSet])","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"path","name":"id","schema":{"type":"integer"},"description":"A unique integer value identifying this user.","required":true}],"tags":["users"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/PatchedUser"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/PatchedUser"}},"application/json":{"schema":{"$ref":"#/components/schemas/PatchedUser"}},"application/xml":{"schema":{"$ref":"#/components/schemas/PatchedUser"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}},"application/xml":{"schema":{"$ref":"#/components/schemas/User"}}},"description":""}}}}}}
```

## POST /users/{id}/group-assignments/

> Create or update one user group assignment and resync effective groups

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"User":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"username":{"type":"string","description":"Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.","pattern":"^[\\w.@+-]+$","maxLength":150},"email":{"title":"Email address","oneOf":[{"type":"string","format":"email","maxLength":254},{"type":"string","maxLength":0}]},"first_name":{"type":"string","maxLength":150},"last_name":{"type":"string","maxLength":150},"password":{"type":"string","writeOnly":true,"maxLength":128},"is_superuser":{"type":"boolean","title":"Superuser status","description":"Designates that this user has all permissions without explicitly assigning them."},"groups":{"type":"array","items":{"type":"integer"},"description":"The groups this user belongs to. A user will get all permissions granted to each of their groups."},"group_assignments":{"type":"string","readOnly":true},"user_permissions":{"type":"array","items":{"type":"integer"},"description":"Specific permissions for this user."}},"required":["group_assignments","id","password","username"]}}},"paths":{"/users/{id}/group-assignments/":{"post":{"operationId":"users_group_assignments_create","description":"Create or update one user group assignment and resync effective groups","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"path","name":"id","schema":{"type":"integer"},"description":"A unique integer value identifying this user.","required":true}],"tags":["users"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/User"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/User"}},"application/json":{"schema":{"$ref":"#/components/schemas/User"}},"application/xml":{"schema":{"$ref":"#/components/schemas/User"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}},"application/xml":{"schema":{"$ref":"#/components/schemas/User"}}},"description":""}}}}}}
```

## DELETE /users/{id}/group-assignments/{assignment\_id}/

> Delete one user group assignment and resync effective groups

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}}},"paths":{"/users/{id}/group-assignments/{assignment_id}/":{"delete":{"operationId":"users_group_assignments_destroy","description":"Delete one user group assignment and resync effective groups","parameters":[{"in":"path","name":"assignment_id","schema":{"type":"string"},"required":true},{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"path","name":"id","schema":{"type":"integer"},"description":"A unique integer value identifying this user.","required":true}],"tags":["users"],"responses":{"204":{"description":"No response body"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://documentation.ocsinventory-ng.org/open-api-reference/users.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
