# com.getorbyt.community.saveRole

> Published by [getorbyt.com](https://lexicon.garden/identity/did:plc:2xrqztnmzlckb3xfuuukupso)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:2xrqztnmzlckb3xfuuukupso/com.getorbyt.community.saveRole)
- [Documentation](https://lexicon.garden/lexicon/did:plc:2xrqztnmzlckb3xfuuukupso/com.getorbyt.community.saveRole/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:2xrqztnmzlckb3xfuuukupso/com.getorbyt.community.saveRole/examples)

## Definitions

### `com.getorbyt.community.saveRole`

**Type**: `procedure`

Creates a Community role, or changes one. Without a key it creates a role; with one it replaces that role's name and permissions. The key moderator changes what the built-in moderator role may do, and keeps its name. Only an administrator may define roles. Recorded in the moderation log.

#### Input

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `community` | `string` (at-uri) | Yes |  |
| `key` | `string` | No | The role to change. Absent creates a role. |
| `name` | `string` | No | Required for a role the Community defined. Ignored for moderator. |
| `permissions` | `array` | Yes |  |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `role` | `ref` → `com.getorbyt.community.defs#roleView` | Yes |  |

#### Errors

- **AuthenticationRequired**
- **CommunityNotFound**
- **InsufficientRole**
- **InvalidRequest**
- **RoleNotFound**: No role with this key exists in the Community.
- **TooManyRoles**: The Community already defines the most roles it may.

## Raw Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Creates a Community role, or changes one. Without a key it creates a role; with one it replaces that role's name and permissions. The key moderator changes what the built-in moderator role may do, and keeps its name. Only an administrator may define roles. Recorded in the moderation log.",
      "errors": [
        {
          "name": "AuthenticationRequired"
        },
        {
          "name": "CommunityNotFound"
        },
        {
          "name": "InsufficientRole"
        },
        {
          "name": "InvalidRequest"
        },
        {
          "description": "No role with this key exists in the Community.",
          "name": "RoleNotFound"
        },
        {
          "description": "The Community already defines the most roles it may.",
          "name": "TooManyRoles"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "community": {
              "format": "at-uri",
              "type": "string"
            },
            "key": {
              "description": "The role to change. Absent creates a role.",
              "maxLength": 64,
              "type": "string"
            },
            "name": {
              "description": "Required for a role the Community defined. Ignored for moderator.",
              "maxGraphemes": 32,
              "maxLength": 320,
              "type": "string"
            },
            "permissions": {
              "items": {
                "knownValues": [
                  "manage-posts",
                  "manage-reports",
                  "manage-members",
                  "manage-roles",
                  "manage-settings",
                  "manage-mail",
                  "view-log"
                ],
                "type": "string"
              },
              "maxLength": 16,
              "type": "array"
            }
          },
          "required": [
            "community",
            "permissions"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "role": {
              "ref": "com.getorbyt.community.defs#roleView",
              "type": "ref"
            }
          },
          "required": [
            "role"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "id": "com.getorbyt.community.saveRole",
  "lexicon": 1
}
```
