### Upsert a broadcast

Updates a broadcast of a given key, or creates a new one if it does not yet exist.


#### Endpoint

`PUT /v1/broadcasts/{broadcast_key}`

#### Path parameters

- **broadcast_key** (string) *required* - The key of the broadcast.

#### Query parameters

- **environment** (string) - The environment slug. When omitted, the account's default environment is used.
- **branch** (string) - The slug of a branch to use. When `environment` is omitted, the branch is resolved from Development after the account default is injected. When `environment` is supplied, it must be `"development"`.
- **annotate** (boolean) - Whether to annotate the resource. Only used in the Knock CLI.

#### Request body

Wraps the BroadcastRequest request under the broadcast key.

##### Example

```json
{
  "broadcast": {
    "categories": [
      "announcement"
    ],
    "description": "A broadcast to all users",
    "name": "My Broadcast",
    "settings": {
      "is_commercial": true,
      "override_preferences": false
    },
    "steps": [
      {
        "channel_key": "in-app-feed",
        "name": "Channel 1",
        "ref": "channel_1",
        "template": {
          "action_url": "{{ vars.app_url }}",
          "markdown_body": "Hello **{{ recipient.name }}**"
        },
        "type": "channel"
      }
    ],
    "tags": [
      "in-review"
    ],
    "target_audience_key": "all-users"
  }
}
```

#### Responses

##### 200

OK

###### Example

```json
{
  "broadcast": {
    "categories": [
      "marketing",
      "promotions"
    ],
    "created_at": "2022-12-16T19:07:50.027113Z",
    "description": "Holiday promotion broadcast for December",
    "environment": "development",
    "key": "december-promotion",
    "name": "December Promotion",
    "scheduled_at": null,
    "sent_at": null,
    "settings": {
      "is_commercial": true,
      "override_preferences": false
    },
    "sha": "f7e9d3b2a1c8e6m4k5j7h9g0i2l3n4p6q8r0t1u3v5w7x9y",
    "status": "draft",
    "steps": [
      {
        "channel_key": "in-app-feed",
        "description": "Main in-app feed",
        "name": "In-app step",
        "ref": "in_app_feed_1",
        "template": {
          "action_url": "{{ vars.app_url }}",
          "markdown_body": "Hello **{{ recipient.name }}**"
        },
        "type": "channel"
      }
    ],
    "tags": [
      "in-review"
    ],
    "target_audience_key": "premium-users",
    "updated_at": "2023-02-08T22:15:19.846681Z",
    "valid": true
  }
}
```

