# Grant a badge to a user

`POST /user_badges.json`

Authentication: no security requirement declared for this operation.

Request body: application/json

Type: any

- `username` (required)
  Type: string
  
  The username of the user to grant the badge to.

- `badge_id` (optional)
  Type: integer
  
  The ID of the badge to grant. Either badge_id or badge_name
  is required.

- `badge_name` (optional)
  Type: string
  
  The name of the badge to grant. Either badge_id or
  badge_name is required.

- `reason` (optional)
  Type: string
  
  Optional URL of a post or topic associated with the
  grant. Cannot be used together with post_id.

- `post_id` (optional)
  Type: integer
  
  Optional ID of a visible, non-deleted post associated
  with the grant. Cannot be used together with reason.
  
  minimum: 1

- `suppress_notification` (optional)
  Type: boolean
  
  Suppress the notification for this grant only. Omit
  or set to false to preserve normal notification behavior, including
  existing suppression rules. The badge is still granted and grant
  events still occur.
  
  default: false

anyOf:
  Type: any

  Type: any

Additional properties: false

Responses:

- 200: badge granted

## Examples

### cURL

```bash
curl -X POST 'https://discourse.example.com/user_badges.json'
```

### JavaScript

```javascript
const response = await fetch('https://discourse.example.com/user_badges.json', {
  method: 'POST',
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.post('https://discourse.example.com/user_badges.json')
print(response.text)
```
