# Lock a post from being edited

`PUT /posts/{id}/locked.json`

Authentication: no security requirement declared for this operation.

Parameters:

- `Api-Key` (header, string, required)
  Type: string

- `Api-Username` (header, string, required)
  Type: string

- `id` (path, string, required)
  Type: string

Request body: application/json

Type: object

- `locked` (required)
  Type: string
  
  Whether to lock the post (true/false)

Responses:

- 200: post updated

Content type: application/json

Type: object

- `locked` (required)
  Type: boolean
  
  Whether the post is locked

## Examples

### cURL

```bash
curl -X PUT 'https://discourse.example.com/posts/string/locked.json' \
  -H 'Api-Key: string' \
  -H 'Api-Username: string' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "locked": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "locked": "string"
}`;

const response = await fetch('https://discourse.example.com/posts/string/locked.json', {
  method: 'PUT',
  headers: {
    'Api-Key': 'string',
    'Api-Username': 'string',
    'Content-Type': 'application/json',
  },
  body,
});

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

### Python

```python
import requests

body = '''{
  "locked": "string"
}'''

response = requests.put(
    'https://discourse.example.com/posts/string/locked.json',
    data=body.encode('utf-8'),
    headers={
        'Api-Key': 'string',
        'Api-Username': 'string',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
