> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zapnito.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Badge assignments API

> Assign a badge to a piece of content or a user in your Zapnito community and remove the assignment again through the API.

Give a badge to a piece of content or a user, and take it away again. To get a badge's ID, [list badges](/api/v1/badges#list-badges).

Before you start, read about [authentication](/api/v1/authentication), [pagination](/api/v1/pagination) and [responses and errors](/api/v1/errors). The [API overview](/api/v1/overview) covers the base URL and lists every resource.

## Assign a badge

Assign a badge to a piece of content or a user.

<ParamField path="badge_id" type="string" required>
  The ID of the badge to assign.
</ParamField>

<ParamField body="id" type="string" required>
  The ID of the record you're assigning the badge to.
</ParamField>

<ParamField body="type" type="string" required>
  The type of record you're assigning the badge to. Accepts `Content` or `User`.
</ParamField>

<ParamField body="verification_url" type="string">
  The URL of a certificate or other third-party verification.
</ParamField>

```bash title="Assign a badge" theme={null}
curl -X POST "https://your-community.zapnito.com/api/v1/badges/1/assign" \
  -H "Authorization: Token token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json; charset=utf-8" \
  -d '{"id": "2", "type": "Content", "verification_url": "https://example.com/certificate"}'
```

`POST https://your-community.zapnito.com/api/v1/badges/:badge_id/assign`

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "message": "Badge #1 assigned to Content #2"
  }
  ```
</ResponseExample>

## Remove a badge assignment

Remove a badge from a piece of content or a user.

<ParamField path="badge_id" type="string" required>
  The ID of the badge to remove.
</ParamField>

<ParamField body="id" type="string" required>
  The ID of the record you're removing the badge from.
</ParamField>

<ParamField body="type" type="string" required>
  The type of record you're removing the badge from. Accepts `Content` or `User`.
</ParamField>

```bash title="Remove a badge assignment" theme={null}
curl -X DELETE "https://your-community.zapnito.com/api/v1/badges/1/unassign" \
  -H "Authorization: Token token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json; charset=utf-8" \
  -d '{"id": "2", "type": "Content"}'
```

`DELETE https://your-community.zapnito.com/api/v1/badges/:badge_id/unassign`

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "message": "Badge #1 unassigned from Content #2"
  }
  ```
</ResponseExample>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.