---
title: "REST API: Assign Space Role"
type: "wiki"
space: "Axero Documentation"
author: "Anonymous User"
created: 2011-03-29T06:40:29Z
updated: 2026-09-28T01:07:33Z
tags: ["API"]
url: "https://my.axerosolutions.com/spaces/5/axero-documentation/wiki/view/512/rest-api-assign-space-role"
---

# REST API: Assign Space Role

[Open API Guide](https://my.axerosolutions.com/spaces/5/axero-documentation/api-guide?id=512)
POST/api/users/\{UserID\}/spaces/\{SpaceID\}/roles

Assign a space role to an existing space user

## Request

### Request Header
| Header | Required | Value | Description |
| :--- | :--- | :--- | :--- |
| `Authorization` | YES | `Bearer YOUR_TOKEN` | Bearer token for the authenticated user. [Learn how to create Bearer tokens](https://my.axerosolutions.com/spaces/5/axero-documentation/wiki/view/108973/creating-bearer-tokens) |
| `Content-Type` | YES | `application/json` | Must be set to `application/json` |
### Required Parameters
| Parameter | Type | Required | Location | Description |
| :--- | :--- | :--- | :--- | :--- |
| `UserID` | Integer | YES | Path | Unique identifier for a particular user |
| `SpaceID` | Integer | YES | Path | ID of the space. Do not send 0: with SpaceID 0 the role IDs are read as site roles, and the user's site roles change instead. |
| `RoleID` | String | YES | Body | ID of the role to assign, sent as a JSON string in the request body \(for example "123"\). Several IDs separated by commas or pipes \("12,15"\) replace the user's space roles with that set. The last space administrator cannot be removed from the Administrator role. A list that holds no number, such as "abc,xyz", leaves the user with only the space's Guest role. A single value that is not a number answers 500. |
### Optional Parameters
| Parameter | Type | Required | Location | Description |
| :--- | :--- | :--- | :--- | :--- |
| `IsRoleList` | Boolean | NO | Query | Set to true to treat a single RoleID as the user's complete set of space roles, removing every other space role. Default: false. A value that is not true or false is read as false. |
## Example

### Request Header

```
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
```

### Request URL

`https://your-site.com/api/users/156/spaces/2/roles`

### Request Body

```
"123"
```

### Success Response

```
{
  "IsError": false,
  "ResponseMessage": "",
  "ResponseData": true
}
```

### Error Response

```
HTTP 500 with an empty body
```

## Error Handling

| Status Code | Likely Cause | Next Action |
| :--- | :--- | :--- |
| 500 Server Error | RoleID is missing from the body \(for example, sent in the query string instead\), or a single RoleID is not a number. The endpoint fails with an empty body instead of reporting the problem. | Verify the request against the required parameters before treating the 500 as a server fault. |
| 401 Unauthorized | Missing or invalid Bearer token | Check token validity. [Learn how to create Bearer tokens →](https://my.axerosolutions.com/spaces/5/axero-documentation/wiki/view/108973/creating-bearer-tokens) |
| 403 Forbidden | The caller is not a site administrator and does not have the Manage Role permission in the space. | Confirm the user has the required roles for this action |
| 200 with IsError | The role list is empty, or the change would remove the space's last administrator; ResponseMessage says which. | Send at least one role and keep one Administrator in the space. |

## Rate Limits

While Axero does not enforce hard rate limits by default, we recommend the following best practices to ensure optimal performance:

- **Sustained Request Rate:** Do not exceed 5 API calls per second
- **Sequential Processing:** Wait for each request to complete before sending the next in automated workflows
- **Concurrent Connections:** If parallel processing is required, limit to 3 or fewer simultaneous requests
- **Response Timeout:** Ensure API responses complete within 15 seconds during testing

Axero may implement temporary rate restrictions if excessive API usage affects overall site performance. For high-volume integrations, contact Axero to discuss your requirements.
