# Role management API

The Roles Management API provides a consistent way to assign and revoke access control roles across users and groups within your organization. Use these endpoints to manage key roles like `viewer`, `manager`, or `owner` for individuals or teams.

{% file src="/files/X3sUVRXNbWON3Ok8E9i3" %}

## PUT /{role}/bindings/users/{email}

> Assign a role to a user

```json
{"openapi":"3.0.3","info":{"title":"P0 Roles Management API","version":"1.0.0"},"servers":[{"url":"https://api.p0.app/o/{orgId}/settings/roles","variables":{"orgId":{"default":"demo-org","description":"The organization ID"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key"}},"parameters":{"role":{"name":"role","in":"path","required":true,"schema":{"type":"string","enum":["viewer","iamViewer","iamOwner","manager","owner"]}},"email":{"name":"email","in":"path","required":true,"schema":{"type":"string","format":"email"}}},"responses":{"BadRequestError":{"description":"Bad request"},"UnauthorizedError":{"description":"Unauthorized"}}},"paths":{"/{role}/bindings/users/{email}":{"put":{"summary":"Assign a role to a user","parameters":[{"$ref":"#/components/parameters/role"},{"$ref":"#/components/parameters/email"}],"responses":{"204":{"description":"Role assigned"},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"}},"requestBody":{"required":false,"content":{"application/json":{}}}}}}}
```

## DELETE /{role}/bindings/users/{email}

> Remove a user's role

```json
{"openapi":"3.0.3","info":{"title":"P0 Roles Management API","version":"1.0.0"},"servers":[{"url":"https://api.p0.app/o/{orgId}/settings/roles","variables":{"orgId":{"default":"demo-org","description":"The organization ID"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key"}},"parameters":{"role":{"name":"role","in":"path","required":true,"schema":{"type":"string","enum":["viewer","iamViewer","iamOwner","manager","owner"]}},"email":{"name":"email","in":"path","required":true,"schema":{"type":"string","format":"email"}}},"responses":{"BadRequestError":{"description":"Bad request"},"UnauthorizedError":{"description":"Unauthorized"}}},"paths":{"/{role}/bindings/users/{email}":{"delete":{"summary":"Remove a user's role","parameters":[{"$ref":"#/components/parameters/role"},{"$ref":"#/components/parameters/email"}],"responses":{"204":{"description":"Role removed"},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"}}}}}}
```

## PUT /{role}/bindings/groups/{group}

> Assign a role to a group

```json
{"openapi":"3.0.3","info":{"title":"P0 Roles Management API","version":"1.0.0"},"servers":[{"url":"https://api.p0.app/o/{orgId}/settings/roles","variables":{"orgId":{"default":"demo-org","description":"The organization ID"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key"}},"parameters":{"role":{"name":"role","in":"path","required":true,"schema":{"type":"string","enum":["viewer","iamViewer","iamOwner","manager","owner"]}},"group":{"name":"group","in":"path","required":true,"schema":{"type":"string"}}},"responses":{"BadRequestError":{"description":"Bad request"},"UnauthorizedError":{"description":"Unauthorized"}}},"paths":{"/{role}/bindings/groups/{group}":{"put":{"summary":"Assign a role to a group","parameters":[{"$ref":"#/components/parameters/role"},{"$ref":"#/components/parameters/group"}],"responses":{"201":{"description":"Group role unchanged"},"204":{"description":"Role assigned to group"},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"}}}}}}
```

## DELETE /{role}/bindings/groups/{group}

> Remove a group role

```json
{"openapi":"3.0.3","info":{"title":"P0 Roles Management API","version":"1.0.0"},"servers":[{"url":"https://api.p0.app/o/{orgId}/settings/roles","variables":{"orgId":{"default":"demo-org","description":"The organization ID"}}}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key"}},"parameters":{"role":{"name":"role","in":"path","required":true,"schema":{"type":"string","enum":["viewer","iamViewer","iamOwner","manager","owner"]}},"group":{"name":"group","in":"path","required":true,"schema":{"type":"string"}}},"responses":{"BadRequestError":{"description":"Bad request"},"UnauthorizedError":{"description":"Unauthorized"}}},"paths":{"/{role}/bindings/groups/{group}":{"delete":{"summary":"Remove a group role","parameters":[{"$ref":"#/components/parameters/role"},{"$ref":"#/components/parameters/group"}],"responses":{"204":{"description":"Group role removed"},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.p0.dev/p0-management/management-api/role-management-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
