---
title: "Assign Role to Agent"
method: POST
path: "/agents/{agentId}/roles"
tags: ["agents"]
---

# Assign Role to Agent

`POST /agents/{agentId}/roles`

Assigns a role to a agent.

## Path parameters

- `agentId` string, required — Agent ID

## Headers

- `Authorization` string, required
- `X-Disable-Hooks` 'true', required

## Request body

- TypeRolesAssignActorRoleRequest
  - `roleId` string, required — Role ID
  - `resourceId` union, required
    - string — Account ID
    - string — Environment ID
    - string — Space ID

## Response `200`

Response with status 200

- TypeRolesAssignRoleResponse
  - `data` TypeRolesAssignRoleResponseData, required
    - `id` string, required — Actor Role ID
    - `roleId` string, required — Role ID
    - `actorId` union, required
      - string — User ID
      - string — Agent ID
      - string — Guest ID
    - `resourceId` union, required
      - string — Account ID
      - string — Environment ID
      - string — Space ID
    - `createdAt` string, date-time, required
    - `updatedAt` string, date-time, required

## Other responses

- `400` — Error response with status 400
- `403` — Error response with status 403
- `404` — Error response with status 404

---

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