# Update a topic

`PUT /t/-/{id}.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

- `topic` (optional)
  Type: object
  
  - `title` (optional)
    Type: string
  
  - `category_id` (optional)
    Type: integer

Responses:

- 200: topic updated

Content type: application/json

Type: object

- `basic_topic` (optional)
  Type: object
  
  - `id` (optional)
    Type: integer
  
  - `title` (optional)
    Type: string
  
  - `fancy_title` (optional)
    Type: string
  
  - `slug` (optional)
    Type: string
  
  - `posts_count` (optional)
    Type: integer

## Examples

### cURL

```bash
curl -X PUT 'https://discourse.example.com/t/-/string.json' \
  -H 'Api-Key: string' \
  -H 'Api-Username: string' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "topic": {
    "title": "string",
    "category_id": 0
  }
}'
```

### JavaScript

```javascript
const body = `{
  "topic": {
    "title": "string",
    "category_id": 0
  }
}`;

const response = await fetch('https://discourse.example.com/t/-/string.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 = '''{
  "topic": {
    "title": "string",
    "category_id": 0
  }
}'''

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