> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opigno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Assign user context to hierarchy level

<Warning>
  Only users with the <b>ADMINISTRATOR</b> scope in the current context can assign user contexts to hierarchy levels. Make sure your API token grants administrator privileges.
  See [Understanding Scopes](/OpignoEnterpriseAPI/UserContextManagement#understanding-scopes) for more information.
</Warning>

To assign a user context to a specific hierarchy level, use the `assignUserContextToLevel` mutation.

**Access policy:**

* The API user context must have permission to manage user assignments.
* The specified `userContextUuid` must exist and be accessible.
* The specified `hierarchyLevelId` must exist and be accessible.

The mutation accepts the following arguments:

| Argument           | Type | Description                                                                              | Default |
| :----------------- | :--- | :--------------------------------------------------------------------------------------- | :------ |
| `userContextUuid`  | `ID` | Optional. User context UUID to assign. If omitted, the current API user context is used. | —       |
| `hierarchyLevelId` | `ID` | Required. The unique identifier of the hierarchy level to assign the user context to.    | —       |

<Note>
  This operation creates a relationship between a user context and a hierarchy level, which affects the user's access permissions and organizational structure visibility.
</Note>

<CodeGroup>
  ```filename GraphQL [expandable] theme={null}
  mutation assignUserContextToLevel {
    assignUserContextToLevel(
      userContextUuid: "5acfc440-88e0-4286-b089-c0f03575ed9a"
      hierarchyLevelId: 1
    ) {
      errors
      response
    }
  }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "assignUserContextToLevel": {
        "errors": [],
        "response": true
      }
    }
  }
  ```
</CodeGroup>
