---
descriptions:
  assign_role:
    organization_membership_id: The ID of the organization membership.
    role_slug: The slug of the role to assign.
    resource_id: >-
      The ID of the resource to assign the role on. Use either this or
      resource_external_id + resource_type_slug.
    resource_external_id: The external ID of the resource. Requires resource_type_slug.
    resource_type_slug: The resource type slug. Required with resource_external_id.
reference:
  curl:
    - key: assign_role
      id: assign_role
      url: /reference/fga/role-assignment/create
      title: >-
        /authorization/organization_memberships/:organization_membership_id/role_assignments
      type: POST
      parameters:
        - key: organization_membership_id
          type: string
          description: (assign_role.organization_membership_id)
        - key: role_slug
          type: string
          description: (assign_role.role_slug)
        - key: resource_id
          type: string
          optional: true
          description: (assign_role.resource_id)
        - key: resource_external_id
          type: string
          optional: true
          description: (assign_role.resource_external_id)
        - key: resource_type_slug
          type: string
          optional: true
          description: (assign_role.resource_type_slug)
      returns:
        - (role_assignment)
  js:
    - key: assignRole
      id: assign_role
      url: /reference/fga/role-assignment/create
      title: authorization.assignRole()
      parameters:
        - key: options
          type: object
          unwrap: true
          properties:
            - key: organizationMembershipId
              type: string
              description: (assign_role.organization_membership_id)
            - key: roleSlug
              type: string
              description: (assign_role.role_slug)
            - key: resourceId
              type: string
              optional: true
              description: (assign_role.resource_id)
            - key: resourceExternalId
              type: string
              optional: true
              description: (assign_role.resource_external_id)
            - key: resourceTypeSlug
              type: string
              optional: true
              description: (assign_role.resource_type_slug)
      returns:
        - key: RoleAssignment
          description: (role_assignment.self)
originalPath: >-
  .tmp-workos-clone/packages/docs/content/reference/fga/role-assignment/create.mdx
---

## Assign a role

Assign a role to an organization membership on a specific resource. The user will immediately gain all permissions included in that role on the resource and its descendants.

You must provide either `resource_id` or both `resource_external_id` and `resource_type_slug` to identify the resource.

<Callout type="info">
  The role must be scoped to the resource type of the target resource. You
  cannot assign a project role on a workspace resource.
</Callout>

<CodeBlock referenceId="assign_role">
  <CodeBlockTab title="Request" file="assign-role-request" />
  <CodeBlockTab title="Response" file="assign-role-response" />
</CodeBlock>
