> For the complete documentation index, see [llms.txt](https://docs.flowretail.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flowretail.com/docs/developers/api-documentation/permission/assign-a-role-to-a-user.md).

# Assign a role to a user

Assigns a new role to the user. Can be a tenant-wide role or scoped to a specific store.

Required permissions: TENANT\_USER\_ROLE\_ASSIGNMENT

```json
{"openapi":"3.0.2","info":{"title":"Flow Retail API version 2","version":"2.0.0"},"tags":[{"name":"Permission","description":"Permission"}],"servers":[{"description":"Flow Retail Production","url":"https://api.flowretail.com/v2"},{"description":"Flow Retail Stage","url":"https://api.stage.flowretail.com/v2"}],"security":[{"accessToken":[]},{"authToken":[]},{"integrationToken":[]}],"components":{"securitySchemes":{"accessToken":{"description":"Access token recevied after user login with a deviceToken","scheme":"bearer","type":"http"},"authToken":{"description":"Token received from the auth service","scheme":"bearer","type":"http"},"integrationToken":{"scheme":"bearer","type":"http"}},"requestBodies":{"TenantUserRoleAssignmentRequest":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantUserRoleAssignmentRequestSchema"}}},"description":"Tenant user role assignment request"}},"schemas":{"TenantUserRoleAssignmentRequestSchema":{"title":"TenantUserRoleAssignmentRequestSchema","type":"object","required":["tenantRoleUid"],"properties":{"tenantRoleUid":{"$ref":"#/components/schemas/UID"},"storeUid":{"$ref":"#/components/schemas/UID"},"organizationUid":{"$ref":"#/components/schemas/UID"}},"description":"A tenantRole can be assigned at three levels:\n- Only set a tenantRoleUid in the request: The role will be assigned at tenant level\n- Set organizationUid and tenantRoleUid: The role will be assigned at organization level\n- Set storeUid and tenantRoleUid: The role will be assigned at store level\n\nAn error occurs if both storeUid and organizationUid is set in the request.\n\nThe levels are ranked this way, from top to bottom: tenant, organization, store\n\nA permission set at higher level overrides lower level assignments.\n"},"UID":{"title":"UID","type":"string","pattern":"^[A-Za-z0-9-_]+"},"TenantUserRoleAssignmentResponseSchema":{"title":"TenantUserRoleAssignmentResponseSchema","type":"object","required":["tenantRole","assignedAt","assignedBy","createdAt","lastModifiedAt","tenantUserRoleAssignmentUid","isSystemRole"],"properties":{"tenantRole":{"$ref":"#/components/schemas/BasicTenantRoleResponseSchema"},"organization":{"$ref":"#/components/schemas/BasicOrganizationResponseSchema"},"store":{"$ref":"#/components/schemas/BasicStoreResponseSchema"},"assignedAt":{"type":"string","format":"date-time","description":"When the role was assigned"},"assignedBy":{"$ref":"#/components/schemas/OptionalUID"},"createdAt":{"type":"string","format":"date-time"},"lastModifiedAt":{"type":"string","format":"date-time"},"tenantUserRoleAssignmentUid":{"$ref":"#/components/schemas/UID"},"isSystemRole":{"type":"boolean"}}},"BasicTenantRoleResponseSchema":{"title":"BasicTenantRoleResponseSchema","type":"object","required":["name","tenantRoleUid","isSystemRole"],"properties":{"name":{"type":"string"},"tenantRoleUid":{"$ref":"#/components/schemas/UID"},"isSystemRole":{"type":"boolean"}}},"BasicOrganizationResponseSchema":{"title":"BasicOrganizationResponseSchema","type":"object","required":["name","organizationUid"],"properties":{"name":{"type":"string"},"organizationUid":{"$ref":"#/components/schemas/UID"}}},"BasicStoreResponseSchema":{"title":"BasicStoreResponseSchema","type":"object","required":["name","storeUid","organizationUid","organizationName"],"properties":{"name":{"type":"string"},"storeUid":{"$ref":"#/components/schemas/UID"},"organizationUid":{"$ref":"#/components/schemas/UID"},"organizationName":{"type":"string"}}},"OptionalUID":{"title":"OptionalUID","type":"string","pattern":"^[A-Za-z0-9-_]*"}},"responses":{"TenantUserRoleAssignmentResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantUserRoleAssignmentResponseSchema"}}},"description":"Tenant user role assignment response"}}},"paths":{"/tenants/{tenantUid}/users/{tenantUserUid}/roles":{"post":{"summary":"Assign a role to a user","description":"Assigns a new role to the user. Can be a tenant-wide role or scoped to a specific store.\n\nRequired permissions: TENANT_USER_ROLE_ASSIGNMENT\n","tags":["Permission"],"requestBody":{"$ref":"#/components/requestBodies/TenantUserRoleAssignmentRequest"},"responses":{"201":{"$ref":"#/components/responses/TenantUserRoleAssignmentResponse"}},"operationId":"create-tenant-user-role-assignment"}}}}
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flowretail.com/docs/developers/api-documentation/permission/assign-a-role-to-a-user.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
