# social.colibri.beta.role.putBadgeImage

> Sets a role's badge to an uploaded image. The bytes are uploaded to the community's own repo, which is why this goes through the AppView: a space record must reference a blob living in the repo that holds the record. Replaces whatever badge was there before. Use social.colibri.beta.role.update with removeBadge to clear it.

- Kind: procedure
- Authority: role.beta.colibri.social
- Lexicon: 1
- Published by [colibri.social](https://lexicon.garden/identity/did:plc:mprdjqjluoswa7awzggaggj3), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:mprdjqjluoswa7awzggaggj3/social.colibri.beta.role.putBadgeImage)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:mprdjqjluoswa7awzggaggj3/social.colibri.beta.role.putBadgeImage/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:mprdjqjluoswa7awzggaggj3/social.colibri.beta.role.putBadgeImage/analytics)

## Procedure (`social.colibri.beta.role.putBadgeImage`)

Type: procedure · POST

### Parameters (query string)

- `community` (string · did, required): The community the role belongs to.
- `role` (string · record-key, required): The role's record key.

### Input (image/*)


### Output (application/json)

- `role` (ref, required): The role with the new badge resolved.
  - Reference: `social.colibri.beta.community.defs#roleView`

### Errors

- `AuthRequired`: The request is missing, malformed, or unverifiable service auth.
- `Forbidden`: The caller lacks the role.manage permission.
- `CommunityNotFound`: No community exists at the given DID.
- `RoleNotFound`: No role exists at the given record key.
- `RoleProtected`: The role is marked protected and cannot be modified.
- `RoleHierarchy`: The role is at or above the caller's highest role position.
- `UnsupportedImage`: The bytes are not one of the accepted image types.
- `ImageTooLarge`: The image exceeds 256 KB.
- `CredentialsUnavailable`: The AppView cannot act as the community because its stored credentials are missing or unusable.
- `UpstreamFailure`: A PDS or third-party call the AppView depends on failed.

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Sets a role's badge to an uploaded image. The bytes are uploaded to the community's own repo, which is why this goes through the AppView: a space record must reference a blob living in the repo that holds the record. Replaces whatever badge was there before. Use social.colibri.beta.role.update with removeBadge to clear it.",
      "errors": [
        {
          "description": "The request is missing, malformed, or unverifiable service auth.",
          "name": "AuthRequired"
        },
        {
          "description": "The caller lacks the role.manage permission.",
          "name": "Forbidden"
        },
        {
          "description": "No community exists at the given DID.",
          "name": "CommunityNotFound"
        },
        {
          "description": "No role exists at the given record key.",
          "name": "RoleNotFound"
        },
        {
          "description": "The role is marked protected and cannot be modified.",
          "name": "RoleProtected"
        },
        {
          "description": "The role is at or above the caller's highest role position.",
          "name": "RoleHierarchy"
        },
        {
          "description": "The bytes are not one of the accepted image types.",
          "name": "UnsupportedImage"
        },
        {
          "description": "The image exceeds 256 KB.",
          "name": "ImageTooLarge"
        },
        {
          "description": "The AppView cannot act as the community because its stored credentials are missing or unusable.",
          "name": "CredentialsUnavailable"
        },
        {
          "description": "A PDS or third-party call the AppView depends on failed.",
          "name": "UpstreamFailure"
        }
      ],
      "input": {
        "description": "The raw image bytes, at most 256 KB. The content type must be one of image/jpeg, image/png, image/gif or image/webp, and is sniffed rather than trusted.",
        "encoding": "image/*"
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "role": {
              "description": "The role with the new badge resolved.",
              "ref": "social.colibri.beta.community.defs#roleView",
              "type": "ref"
            }
          },
          "required": [
            "role"
          ],
          "type": "object"
        }
      },
      "parameters": {
        "properties": {
          "community": {
            "description": "The community the role belongs to.",
            "format": "did",
            "type": "string"
          },
          "role": {
            "description": "The role's record key.",
            "format": "record-key",
            "type": "string"
          }
        },
        "required": [
          "community",
          "role"
        ],
        "type": "params"
      },
      "type": "procedure"
    }
  },
  "id": "social.colibri.beta.role.putBadgeImage",
  "lexicon": 1
}
```
