# Your audience

> An audience is a named contact list. Build one, fill it with contacts, and send a campaign to everyone on it.

An **audience** is a named list of contacts — the people you send marketing email to. Each audience is a simple container: it has a `name`, a generated `id`, and a `created_at` timestamp. Contacts live **inside** an audience, addressed at `/audiences/:audience_id/contacts`.

You build audiences in the dashboard under **Audiences**, or through the [API](https://www.mailblastr.com/docs/api/audiences-create). When you send a campaign, you point it at one audience and MailBlastr delivers a copy to every subscribed contact on the list.

## What an audience holds

An audience brings together everything you need to send marketing email to a group of people:

- **[Contacts](https://www.mailblastr.com/docs/audiences/contacts)** — the individual email addresses on the list. Each contact is associated with a single email address, can carry custom properties, can belong to zero or more [segments](https://www.mailblastr.com/docs/segments/overview), and can be opted in or out of individual [topics](https://www.mailblastr.com/docs/topics/overview).
- **[Properties](https://www.mailblastr.com/docs/audiences/properties)** — the fields stored on each contact. Every contact has the default properties `email`, `first_name`, `last_name`, and `unsubscribed`; you can also add custom properties to store extra data and personalize campaigns.
- **[Segments](https://www.mailblastr.com/docs/segments/overview)** — saved filters that resolve to a subset of the audience, so you can send to a specific group rather than the whole list.
- **[Topics](https://www.mailblastr.com/docs/topics/overview)** — subscription categories within the audience that let a contact opt out of one kind of email without unsubscribing from everything.

> **Note:** Each contact keeps a history of its marketing interactions (sends, opens, clicks, unsubscribes), so you can see how a person has engaged with your campaigns over time.

## Importing contacts in bulk

Beyond adding contacts one at a time, you can bulk-import an audience from a CSV (up to **5 MB / 10,000 contacts** per import). CSV columns map to contact fields — `email`, `first_name`, `last_name`, `unsubscribed` — or to any custom property. When a row matches an existing contact by email you choose how conflicts resolve: `upsert` (update the existing contact) or `skip` (leave it untouched). See [Managing contacts](https://www.mailblastr.com/docs/audiences/contacts#bulk-import-by-csv).

## The audience object

```json
{
  "object": "audience",
  "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
  "name": "Registered Users",
  "created_at": "2026-06-23T17:22:43.000Z"
}
```

## Creating an audience

Give the audience a `name` — that is the only field. The response is the new audience object, including the `id` you use to add contacts and send campaigns.

**Node.js**

```js
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.audiences.create({ "name": "Registered Users" });
console.log({ data, error });
```

**Ruby**

```ruby
require "mailblastr"

Mailblastr.api_key = "mb_xxxxxxxxx"

Mailblastr::Audiences.create({
  "name": "Registered Users"
})
```

**PHP**

```php
$mailblastr = Mailblastr::client('mb_xxxxxxxxx');

$mailblastr->audiences->create([
  'name' => "Registered Users"
]);
```

**Python**

```python
import mailblastr

mailblastr.api_key = "mb_xxxxxxxxx"

mailblastr.Audiences.create({
  "name": "Registered Users"
})
```

**Go**

```go
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    req, _ := http.NewRequest("POST", "https://api.mailblastr.com/audiences", strings.NewReader(`{ "name": "Registered Users" }`))
    req.Header.Set("Authorization", "Bearer mb_xxxxxxxxx")
    req.Header.Set("Content-Type", "application/json")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    out, _ := io.ReadAll(res.Body)
    fmt.Println(string(out))
}
```

**Rust**

```rust
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let res = Client::new()
        .post("https://api.mailblastr.com/audiences")
        .header("Authorization", "Bearer mb_xxxxxxxxx")
        .header("Content-Type", "application/json")
        .body(r#"{ "name": "Registered Users" }"#)
        .send()
        .await?;
    println!("{}", res.text().await?);
    Ok(())
}
```

**Java**

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.mailblastr.com/audiences"))
    .header("Authorization", "Bearer mb_xxxxxxxxx")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("""
{ "name": "Registered Users" }
"""))
    .build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

**.NET**

```csharp
using System.Net.Http;
using System.Text;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.mailblastr.com/audiences");
request.Headers.Add("Authorization", "Bearer mb_xxxxxxxxx");
request.Content = new StringContent(@"{ ""name"": ""Registered Users"" }", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

**cURL**

```bash
curl -X POST 'https://api.mailblastr.com/audiences' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "Registered Users" }'
```

**CLI**

```bash
mailblastr audiences create \
  --name 'Registered Users'
```

## How campaigns use an audience

- A campaign targets exactly **one audience** — every contact on the list receives a copy.
- Contacts marked **`unsubscribed`** are skipped, so opted-out recipients never get the send. See [Managing unsubscribed contacts](https://www.mailblastr.com/docs/audiences/unsubscribed).
- Each recipient gets a personal unsubscribe link; clicking it flips that contact to `unsubscribed` for future campaigns.

> **Note:** Deleting an audience is blocked while a campaign still references it — delete the campaign(s) first. See [Delete audience](https://www.mailblastr.com/docs/api/audiences-delete).

## Next steps

- [Manage contacts](https://www.mailblastr.com/docs/audiences/contacts) — add people to an audience and edit their details.
- [Manage unsubscribed contacts](https://www.mailblastr.com/docs/audiences/unsubscribed) — how opt-outs work.
- [Create an audience via the API](https://www.mailblastr.com/docs/api/audiences-create).
