# Create broadcasts

URL: https://docs.hanzo.ai/docs/openapi/marketing/post-marketing-broadcasts

> Composes a broadcast to one of the org's lists, or a segment of it, and answers 201 with it.

`POST /v1/marketing/broadcasts`

> [Marketing →](https://docs.hanzo.ai/docs/openapi/marketing) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                                |
| ------------- | ---------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/marketing/broadcasts` |
| **Method**    | `POST`                                         |
| **Operation** | `post_marketing_broadcasts`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`         |

Composes a broadcast to one of the org's lists, or a segment
of it, and answers 201 with it. With scheduledAt it is scheduled; without, a
draft until sent.

Org admin only.

## Request

27 fields, body `application/json` (required).

| Field                    | In   | Type             | Required | Description                                                                                                          |
| ------------------------ | ---- | ---------------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| `filter`                 | body | marketing.Filter | —        |                                                                                                                      |
| `filter.basis`           | body | string           | —        | Basis keeps subscribers by the consent basis recorded for them: explicit, legitimate\_interest or unverified.        |
| `filter.clickedAfter`    | body | integer (int64)  | —        | ClickedAfter keeps subscribers who clicked a link at or after this time.                                             |
| `filter.confirmedAfter`  | body | integer (int64)  | —        | ConfirmedAfter and ConfirmedBefore bound when the subscription was confirmed, unix seconds, inclusive.               |
| `filter.confirmedBefore` | body | integer (int64)  | —        | ConfirmedBefore is the upper bound of ConfirmedAfter's range.                                                        |
| `filter.createdAfter`    | body | integer (int64)  | —        | CreatedAfter and CreatedBefore bound when the subscriber joined the list, unix seconds, inclusive.                   |
| `filter.createdBefore`   | body | integer (int64)  | —        | CreatedBefore is the upper bound of CreatedAfter's range.                                                            |
| `filter.field`           | body | string           | —        | Field names a custom field, and Value keeps subscribers whose value for it is exactly this.                          |
| `filter.notOpenedSince`  | body | integer (int64)  | —        | NotOpenedSince keeps subscribers who have opened nothing since this time, including those who never opened anything. |
| `filter.openedAfter`     | body | integer (int64)  | —        | OpenedAfter keeps subscribers who opened a broadcast at or after this time.                                          |
| `filter.q`               | body | string           | —        | Q keeps subscribers whose address or name begins with it, case-insensitively.                                        |
| `filter.ref`             | body | string           | —        | Ref keeps subscribers from one source instance: a form id, a page, an import batch id.                               |
| `filter.source`          | body | string           | —        | Source keeps subscribers that came from this kind of source: form, page, api, import or commerce.                    |
| `filter.status`          | body | string           | —        | Status is one status or several, comma-separated: pending, subscribed, unsubscribed, bounced, complained, cleaned.   |
| `filter.tag`             | body | string           | —        | Tag keeps subscribers carrying this tag.                                                                             |
| `filter.value`           | body | string           | —        | Value is the custom field's value Field keeps.                                                                       |
| `fromAddress`            | body | string           | —        | FromAddress overrides the list's sender address.                                                                     |
| `fromName`               | body | string           | —        | FromName overrides the list's sender name.                                                                           |
| `html`                   | body | string           | —        | HTML is the message as HTML; at most 1 MiB.                                                                          |
| `id`                     | body | string           | —        | ID is the broadcast to change, from the path; ignored on create.                                                     |
| `list`                   | body | string           | —        | List is the list to send to, by id or slug; on create only.                                                          |
| `provider`               | body | string           | —        | Provider is ses, sendgrid, or empty for the list's.                                                                  |
| `replyTo`                | body | string           | —        | ReplyTo overrides where replies go.                                                                                  |
| `scheduledAt`            | body | integer (int64)  | —        | ScheduledAt schedules it: unix seconds.                                                                              |
| `segment`                | body | string           | —        | Segment narrows it to a saved segment of the list.                                                                   |
| `subject`                | body | string           | —        | Subject is the subject line.                                                                                         |
| `text`                   | body | string           | —        | Text is the message as plain text; at most 256 KiB.                                                                  |

## Response

| Status    | Body                | Meaning |
| --------- | ------------------- | ------- |
| `201`     | marketing.Broadcast | created |
| `default` | problem-details     | refused |

`201` body — 34 fields.

| Field                    | In   | Type             | Always | Description                                                                                                          |
| ------------------------ | ---- | ---------------- | ------ | -------------------------------------------------------------------------------------------------------------------- |
| `audience`               | body | integer (int64)  | —      | Audience is how many subscribers it selected when it started.                                                        |
| `createdAt`              | body | integer (int64)  | —      | CreatedAt and UpdatedAt are unix seconds.                                                                            |
| `error`                  | body | string           | —      | Error is why a failed broadcast stopped.                                                                             |
| `filter`                 | body | marketing.Filter | —      |                                                                                                                      |
| `filter.basis`           | body | string           | —      | Basis keeps subscribers by the consent basis recorded for them: explicit, legitimate\_interest or unverified.        |
| `filter.clickedAfter`    | body | integer (int64)  | —      | ClickedAfter keeps subscribers who clicked a link at or after this time.                                             |
| `filter.confirmedAfter`  | body | integer (int64)  | —      | ConfirmedAfter and ConfirmedBefore bound when the subscription was confirmed, unix seconds, inclusive.               |
| `filter.confirmedBefore` | body | integer (int64)  | —      | ConfirmedBefore is the upper bound of ConfirmedAfter's range.                                                        |
| `filter.createdAfter`    | body | integer (int64)  | —      | CreatedAfter and CreatedBefore bound when the subscriber joined the list, unix seconds, inclusive.                   |
| `filter.createdBefore`   | body | integer (int64)  | —      | CreatedBefore is the upper bound of CreatedAfter's range.                                                            |
| `filter.field`           | body | string           | —      | Field names a custom field, and Value keeps subscribers whose value for it is exactly this.                          |
| `filter.notOpenedSince`  | body | integer (int64)  | —      | NotOpenedSince keeps subscribers who have opened nothing since this time, including those who never opened anything. |
| `filter.openedAfter`     | body | integer (int64)  | —      | OpenedAfter keeps subscribers who opened a broadcast at or after this time.                                          |
| `filter.q`               | body | string           | —      | Q keeps subscribers whose address or name begins with it, case-insensitively.                                        |
| `filter.ref`             | body | string           | —      | Ref keeps subscribers from one source instance: a form id, a page, an import batch id.                               |
| `filter.source`          | body | string           | —      | Source keeps subscribers that came from this kind of source: form, page, api, import or commerce.                    |
| `filter.status`          | body | string           | —      | Status is one status or several, comma-separated: pending, subscribed, unsubscribed, bounced, complained, cleaned.   |
| `filter.tag`             | body | string           | —      | Tag keeps subscribers carrying this tag.                                                                             |
| `filter.value`           | body | string           | —      | Value is the custom field's value Field keeps.                                                                       |
| `finishedAt`             | body | integer (int64)  | —      | FinishedAt is when it ended.                                                                                         |
| `fromAddress`            | body | string           | —      | FromAddress is the sender's address.                                                                                 |
| `fromName`               | body | string           | —      | FromName, FromAddress and ReplyTo override the list's sender.                                                        |
| `html`                   | body | string           | —      | HTML is the message as HTML.                                                                                         |
| `id`                     | body | string           | —      | ID is the broadcast's id ("brd\_" and 96 random bits in hex).                                                        |
| `list`                   | body | string           | —      | List is the list it goes to.                                                                                         |
| `provider`               | body | string           | —      | Provider is ses or sendgrid; empty takes the list's.                                                                 |
| `replyTo`                | body | string           | —      | ReplyTo is where replies go.                                                                                         |
| `scheduledAt`            | body | integer (int64)  | —      | ScheduledAt is when it is to start, unix seconds.                                                                    |
| `segment`                | body | string           | —      | Segment narrows it to a saved segment of the list; empty is the list.                                                |
| `startedAt`              | body | integer (int64)  | —      | StartedAt and FinishedAt are when sending began and ended.                                                           |
| `status`                 | body | string           | —      | Status is draft, scheduled, sending, sent, cancelled or failed.                                                      |
| `subject`                | body | string           | —      | Subject is the subject line.                                                                                         |
| `text`                   | body | string           | —      | Text is the message as plain text.                                                                                   |
| `updatedAt`              | body | integer (int64)  | —      | UpdatedAt is the last change.                                                                                        |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo marketing broadcasts create
```

**SDK**

**.ts**

```ts
import { Configuration, MarketingApi } from 'hanzoai';

const api = new MarketingApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postMarketingBroadcasts({ filter: {"basis":"<basis>","clickedAfter":0,"confirmedAfter":0,"confirmedBefore":0}, fromAddress: "<fromAddress>" });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import MarketingApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = MarketingApi(client).post_marketing_broadcasts(filter={"basis":"<basis>","clickedAfter":0,"confirmedAfter":0,"confirmedBefore":0}, from_address="<fromAddress>")
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.MarketingAPI.PostMarketingBroadcasts(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, marketing_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = marketing_api::post_marketing_broadcasts(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.MarketingApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new MarketingApi(client).postMarketingBroadcasts();
```

The method above is the one at the current release of the document. `hanzoai@8.5.914` (npm) and `hanzoai@8.5.914` (PyPI) were generated from an earlier release, where this operation carried a different id, so it spells the method differently — regenerating the clients is what makes the two agree. [SDKs →](https://docs.hanzo.ai/docs/sdks)

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/marketing/broadcasts \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "filter": {
         "basis": "<basis>",
         "clickedAfter": 0,
         "confirmedAfter": 0,
         "confirmedBefore": 0
       },
       "fromAddress": "<fromAddress>"
     }'
```

**MCP**

MCP reaches **marketing** through the `marketing` tool, which names its 82 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_marketing_audiences"
         }
       }
     }'
```

---

[Marketing API](https://docs.hanzo.ai/docs/openapi/marketing) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
