---
title: "Add a user to a role"
method: POST
path: "/api/v2/roles/{role_id}/users"
tags: ["Roles"]
---

# Add a user to a role

`POST /api/v2/roles/{role_id}/users`

Adds a user to a role.

## Path parameters

- `role_id` string, required

## Request body

- RelationshipToUser — Relationship to user.
  - `data` RelationshipToUserData, required — Relationship to user object.
    - `id` string, required — A unique identifier that represents the user.
    - `type` 'users', required — Users resource type.

## Response `200`

OK

- UsersResponse — Response containing information about multiple users.
  - `data` User[] — Array of returned users.
    - `attributes` UserAttributes — Attributes of user object returned by the API.
      - `created_at` string, date-time — The ISO 8601 timestamp of when the user account was created.
      - `disabled` boolean — Whether the user account is deactivated. Disabled users cannot log in.
      - `email` string — The email address of the user, used for login and notifications.
      - `handle` string — The unique handle (username) of the user, typically matching their email prefix.
      - `icon` string — URL of the user's profile icon, typically a Gravatar URL derived from the email address.
      - `last_login_time` string, date-time, nullable — The ISO 8601 timestamp of the user's most recent login, or null if the user has never logged in.
      - `mfa_enabled` boolean — Whether multi-factor authentication (MFA) is enabled for the user's account.
      - `modified_at` string, date-time — The ISO 8601 timestamp of when the user account was last modified.
      - `name` string, nullable — The full display name of the user as shown in the Datadog UI.
      - `service_account` boolean — Whether this is a service account rather than a human user. Service accounts are used for programmatic API access.
      - `status` string — The current status of the user account (for example, `Active`, `Pending`, or `Disabled`).
      - `title` string, nullable — The job title of the user (for example, "Senior Engineer" or "Product Manager").
      - `uuid` string — The globally unique identifier (UUID) of the user.
      - `verified` boolean — Whether the user's email address has been verified.
    - `id` string — ID of the user.
    - `relationships` UserResponseRelationships — Relationships of the user object returned by the API.
      - `org` RelationshipToOrganization — Relationship to an organization.
        - `data` RelationshipToOrganizationData, required — Relationship to organization object.
          - `id` string, required — ID of the organization.
          - `type` 'orgs', required — Organizations resource type.
      - `other_orgs` RelationshipToOrganizations — Relationship to organizations.
        - `data` RelationshipToOrganizationData[], required — Relationships to organization objects.
          - `id` string, required — ID of the organization.
          - `type` 'orgs', required — Organizations resource type.
      - `other_users` RelationshipToUsers — Relationship to users.
        - `data` RelationshipToUserData[], required — Relationships to user objects.
          - `id` string, required — A unique identifier that represents the user.
          - `type` 'users', required — Users resource type.
      - `roles` RelationshipToRoles — Relationship to roles.
        - `data` RelationshipToRoleData[] — An array containing type and the unique identifier of a role.
          - `id` string — The unique identifier of the role.
          - `type` 'roles' — Roles type.
    - `type` 'users' — Users resource type.
  - `included` UserResponseIncludedItem[] — Array of objects related to the users.
    - union — An object related to a user.
      - Organization — Organization object.
        - `attributes` OrganizationAttributes — Attributes of the organization.
          - `created_at` string, date-time — Creation time of the organization.
          - `description` string — Description of the organization.
          - `disabled` boolean — Whether or not the organization is disabled.
          - `modified_at` string, date-time — Time of last organization modification.
          - `name` string — Name of the organization.
          - `public_id` string — Public ID of the organization.
          - `sharing` string — Sharing type of the organization.
          - `url` string — URL of the site that this organization exists at.
        - `id` string — ID of the organization.
        - `type` 'orgs', required — Organizations resource type.
      - Permission — Permission object.
        - `attributes` PermissionAttributes — Attributes of a permission.
          - `created` string, date-time — Creation time of the permission.
          - `description` string — Description of the permission.
          - `display_name` string — Displayed name for the permission.
          - `display_type` string — Display type.
          - `group_name` string — Name of the permission group.
          - `name` string — Name of the permission.
          - `name_aliases` string[] — List of alias names for the permission.
          - `restricted` boolean — Whether or not the permission is restricted.
        - `id` string — ID of the permission.
        - `type` 'permissions', required — Permissions resource type.
      - Role — Role object returned by the API.
        - `attributes` RoleAttributes — Attributes of the role.
          - `created_at` string, date-time — Creation time of the role.
          - `modified_at` string, date-time — Time of last role modification.
          - `name` string — The name of the role. The name is neither unique nor a stable identifier of the role.
          - `receives_permissions_from` string[] — The managed role from which this role automatically inherits new permissions. Specify one of the following: "Datadog Admin Role", "Datadog Standard Role", or "Datadog Read Only Role". If empty or not specified, the role does not automatically inherit permissions from any managed role.
          - `user_count` integer — Number of users with that role.
        - `id` string — The unique identifier of the role.
        - `relationships` RoleResponseRelationships — Relationships of the role object returned by the API.
          - `permissions` RelationshipToPermissions — Relationship to multiple permissions objects.
            - `data` RelationshipToPermissionData[] — Relationships to permission objects.
              - …
        - `type` 'roles', required — Roles type.
  - `meta` ResponseMetaAttributes — Object describing meta attributes of response.
    - `page` Pagination — Pagination object.
      - `total_count` integer — Total count.
      - `total_filtered_count` integer — Total count of elements matched by the filter.

## Other responses

- `400` — Bad Request
- `403` — Authentication error
- `404` — Not found
- `429` — Too many requests

---

[API](https://skmtc.net/datadog/apis/api-v2.md) · [All operations](https://skmtc.net/datadog/apis/api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/datadog/api-v2/versions/da68bf029e4c/schema)
