# Audience routes: update, delete

URL: /code/api/audience/records-update · Id: `page:code/api/audience/records-update`

> The Audience Verbs update, delete as api.sb routes, with inputs, result, refusals and an example.

Reference for [Audience](/business/nouns/audience), one group of [Audience routes](/code/api/audience).

### Audience.update
Changes the given properties of an Audience. [Verb page](/business/nouns/audience/update?interface=api).

```text
PATCH /{namespace}/audiences/{id}
```

Path: `id`. Body, as JSON: the other inputs. Emits `Audience.updated`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Audience. |
| `type` | list of [Noun](/business/nouns/noun) | No | The Nouns this Thing is an instance of. |
| `outside` | `json` | No | The ids this Thing has in outside tools, one per Integration, so a re-run matches instead of duplicating. |
| `query` | `json` | No | The saved query that defines a dynamic Collection. |
| `size` | `integer` | No | How many people match. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `audience` | [Audience](/business/nouns/audience) | Yes | The Audience. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X PATCH https://api.sb/leaseline.app/audiences/audience_vmVkEYrXCN \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"size":1}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "audience": {
    "$id": "https://api.sb/leaseline.app/audiences/audience_vmVkEYrXCN",
    "$type": "Audience",
    "id": "Example id",
    "type": [
      "noun_v0akLUrXCN"
    ],
    "size": 1
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Audience.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Audience.delete
Deletes an Audience: a soft delete that keeps its history, undone by `Thing.restore`. [Verb page](/business/nouns/audience/delete?interface=api).

```text
DELETE /{namespace}/audiences/{id}
```

Path: `id`. Emits `Audience.deleted`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Audience. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `audience` | [Audience](/business/nouns/audience) | Yes | The Audience. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X DELETE https://api.sb/leaseline.app/audiences/audience_vmVkEYrXCN \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "audience": {
    "$id": "https://api.sb/leaseline.app/audiences/audience_vmVkEYrXCN",
    "$type": "Audience",
    "id": "Example id",
    "type": [
      "noun_v0akLUrXCN"
    ]
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Audience.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```