# Update topic

> PATCH /topics/:id — rename a topic or change its description.

`PATCH /topics/:id`

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `topic_id` | string | Yes | The topic ID. |

**Body parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | No | New display name (max 255 chars). |
| `description` | string | No | New description shown on the preference page. |
| `visibility` | string | No | New visibility on the preference page: `public` or `private`. |

> **Warning:** The `default_subscription` (opt-in vs opt-out) is fixed at creation and **cannot be updated**.

**Node.js**

```js
import { SendPing } from 'sendping';

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.topics.update('topic_9a2f...', { "name": "Newsletter" });
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Topics.update("topic_9a2f...", {
  "name": "Newsletter"
})
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

use SendPing\SendPing;

$sendping = SendPing::client('mb_xxxxxxxxx');

$sendping->topics->update('topic_9a2f...', [
  'name' => "Newsletter"
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Topics.update("topic_9a2f...", {
  "name": "Newsletter"
})
```

**Go**

```go
import "github.com/shekhu10/sendping-sdks/sendping-go"

client := sendping.NewClient("mb_xxxxxxxxx")

topic, err := client.Topics.Update("topic_9a2f...", &sendping.UpdateTopicRequest{
    Name: "Newsletter",
})
```

**Rust**

```rust
use sendping::{SendPing, UpdateTopicOptions};

let mb = SendPing::new("mb_xxxxxxxxx");

let params = UpdateTopicOptions::new().with_name("Newsletter");
let _topic = mb.topics.update("topic_9a2f...", params).await?;
```

**Java**

```java
import co.sendping.SendPing;
import co.sendping.SendPingResponse;
import co.sendping.requests.UpdateTopicRequest;

SendPing sendping = new SendPing("mb_xxxxxxxxx");

SendPingResponse response = sendping.topics().update(
        "topic_9a2f...",
        UpdateTopicRequest.builder().name("Newsletter").build());
```

**.NET**

```csharp
using SendPing;

ISendPing sendping = SendPingClient.Create("mb_xxxxxxxxx");

var resp = await sendping.TopicUpdateAsync(
    "topic_9a2f...",
    new TopicUpdateOptions { Name = "Newsletter" });
```

**cURL**

```bash
curl -X PATCH 'https://www.sendping.co/api/topics/topic_9a2f...' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "Newsletter" }'
```

**CLI**

```bash
sendping topics update topic_9a2f... \
  --name 'Newsletter'
```
