# Topics

A topic is a kind of email a contact can choose to get, such as product news or a weekly digest. Every campaign sends on one topic, and contacts turn topics on and off on the preference page.

## Create a Topic

Open Contacts › Topics and click New Topic. Each workspace starts with a Marketing topic, which is the default. A workspace can have up to 100 topics.

- On by default gives the topic to every contact until they turn it off.
- Show on preference page lets contacts see and change the topic.
- Double opt-in sends a confirmation email before the contact is subscribed.
- Sign-up form gives the topic a public form.

## Subscriptions

A contact gets a topic when their topic status is subscribed, or when they have no status and the topic is on by default. Set the status with the topics field of the contacts API.

```bash cURL
curl -X PATCH https://api.inboxjot.com/v1/contacts/riti@example.com \
  -H "Authorization: Bearer $INBOXJOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "topics": [{ "id": "<topic_id>", "status": "subscribed" }]
  }'
```

```javascript Node.js
import { Inboxjot } from 'inboxjot';

const inboxjot = new Inboxjot();

await inboxjot.contacts.update('riti@example.com', {
  topics: [{ id: '<topic_id>', status: 'subscribed' }],
});
```

```rust Rust
use inboxjot::{Inboxjot, TopicChoice, TopicStatus, UpdateContact};

let client = Inboxjot::from_env()?;

client
    .contacts()
    .update("riti@example.com", &UpdateContact {
        topics: Some(vec![TopicChoice {
            id: "<topic_id>".into(),
            status: TopicStatus::Subscribed,
        }]),
        ..Default::default()
    })
    .await?;
```

```go Go
client := inboxjot.NewClient("")

contact, err := client.Contacts.Update(ctx, "riti@example.com", inboxjot.UpdateContactParams{
	Topics: []inboxjot.TopicChoice{
		{ID: "<topic_id>", Status: inboxjot.TopicSubscribed},
	},
})
```

```python Python
from inboxjot import Inboxjot

inboxjot = Inboxjot()

inboxjot.contacts.update(
    "riti@example.com",
    {"topics": [{"id": "<topic_id>", "status": "subscribed"}]},
)
```

> The API cannot subscribe a contact to a topic they unsubscribed from. Only the
> contact can do that on the preference page.

## Preference Page

Every campaign and automation email has an unsubscribe link and one-click `List-Unsubscribe` headers. The link opens a preference page where the contact turns topics on and off, unsubscribes from all email, or pauses all email for 30 days.

Change the heading, the message and the options of this page in Settings › Unsubscribe Page.

## Sign-up Forms

Turn on the sign-up form of a public topic to collect contacts from your site. The form posts `email` and optional `first_name` and `last_name` to `POST /v1/forms/{topic_id}`.

```html HTML
<form method="POST" action="https://api.inboxjot.com/v1/forms/<topic_id>">
  <input type="email" name="email" required />
  <input type="text" name="first_name" />
  <button type="submit">Subscribe</button>
</form>
```

With double opt-in, the contact gets a confirmation link that works for 7 days. After they subscribe, the form can redirect to your own page.
