# Brands

> Group each business's accounts and publish as that brand.

Source: https://postwire.io/docs/brands/ · Base URL: https://postwire.io · OpenAPI: https://postwire.io/openapi.json

A brand is one business: its own TikTok, its own Instagram, and so on. Pass `brand_id` when you publish or schedule. With one brand you never need it. When the same network is connected in two brands and no `brand_id` is sent, PostWire refuses (409 `ambiguous_brand`) instead of guessing.

- [`GET /api/brands`](#get-api-brands): List brands and the networks connected to each
- [`POST /api/brands`](#post-api-brands): Create a brand
- [`GET /api/brands/{id}`](#get-api-brands-id): One brand and its connected accounts
- [`PATCH /api/brands/{id}`](#patch-api-brands-id): Rename a brand
- [`DELETE /api/brands/{id}`](#delete-api-brands-id): Delete a brand and disconnect its networks (an account keeps at least one brand)

## List brands and the networks connected to each

`GET /api/brands`

A brand groups one business's accounts. Use a brand's id as `brand_id` when publishing.

Needs an API key: `Authorization: Bearer pw_live_…`.

**Responses**

| Status | Means |
|---|---|
| `200` | { brands: [{ id, name, platforms[], accounts: [{ platform, label, handle, display_name, avatar_url, profile_url, connected_at, needs }] }], limit, plan } — handle, display name and picture are what the network itself reports for that account. |

```bash
curl "https://postwire.io/api/brands" \
  -H "Authorization: Bearer $POSTWIRE_API_KEY"
```

```js
const res = await fetch("https://postwire.io/api/brands", {
  method: "GET",
  headers: { Authorization: `Bearer ${process.env.POSTWIRE_API_KEY}` },
});
console.log(res.status, await res.json());
```

```python
import os, requests

r = requests.get(
    "https://postwire.io/api/brands",
    headers={"Authorization": f"Bearer {os.environ['POSTWIRE_API_KEY']}"},
)
print(r.status_code, r.json())
```

## Create a brand

`POST /api/brands`

A brand groups one business's connected accounts. The plan sets how many brands an account has (Free 1, Starter 3, Pro 10, Agency 50, Scale 200); one more answers 400 brand_limit_reached with an upgrade link.

Needs an API key: `Authorization: Bearer pw_live_…`.

**Body (JSON)**

| Field | Type | Description |
|---|---|---|
| `name` (required) | string |  |

**Responses**

| Status | Means |
|---|---|
| `200` | { ok, brand: { id, name } } |
| `400` | name required, or code brand_limit_reached { brands_used, brands_allowed, upgrade } |

```bash
curl -X POST "https://postwire.io/api/brands" \
  -H "Authorization: Bearer $POSTWIRE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Corner Café"
}'
```

```js
const res = await fetch("https://postwire.io/api/brands", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.POSTWIRE_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "name": "Corner Café"
  }),
});
console.log(res.status, await res.json());
```

```python
import os, requests

r = requests.post(
    "https://postwire.io/api/brands",
    headers={"Authorization": f"Bearer {os.environ['POSTWIRE_API_KEY']}"},
    json={
        "name": "Corner Café",
    },
)
print(r.status_code, r.json())
```

## One brand and its connected accounts

`GET /api/brands/{id}`

Needs an API key: `Authorization: Bearer pw_live_…`.

**Parameters**

| Field | Type | Description |
|---|---|---|
| `id` (required) | path, string |  |

**Responses**

| Status | Means |
|---|---|
| `200` | { brand: { id, name, platforms[], accounts[] } } |
| `404` | brand_not_found |

```bash
curl "https://postwire.io/api/brands/b3f1c2d4-8a9e-4f6b-a1c2-3d4e5f6a7b8c" \
  -H "Authorization: Bearer $POSTWIRE_API_KEY"
```

```js
const res = await fetch("https://postwire.io/api/brands/b3f1c2d4-8a9e-4f6b-a1c2-3d4e5f6a7b8c", {
  method: "GET",
  headers: { Authorization: `Bearer ${process.env.POSTWIRE_API_KEY}` },
});
console.log(res.status, await res.json());
```

```python
import os, requests

r = requests.get(
    "https://postwire.io/api/brands/b3f1c2d4-8a9e-4f6b-a1c2-3d4e5f6a7b8c",
    headers={"Authorization": f"Bearer {os.environ['POSTWIRE_API_KEY']}"},
)
print(r.status_code, r.json())
```

## Rename a brand

`PATCH /api/brands/{id}`

Needs an API key: `Authorization: Bearer pw_live_…`.

**Parameters**

| Field | Type | Description |
|---|---|---|
| `id` (required) | path, string |  |

**Body (JSON)**

| Field | Type | Description |
|---|---|---|
| `name` (required) | string |  |

**Responses**

| Status | Means |
|---|---|
| `200` | { ok, brand } |
| `404` | brand not found |

```bash
curl -X PATCH "https://postwire.io/api/brands/b3f1c2d4-8a9e-4f6b-a1c2-3d4e5f6a7b8c" \
  -H "Authorization: Bearer $POSTWIRE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Corner Café Miraflores"
}'
```

```js
const res = await fetch("https://postwire.io/api/brands/b3f1c2d4-8a9e-4f6b-a1c2-3d4e5f6a7b8c", {
  method: "PATCH",
  headers: { Authorization: `Bearer ${process.env.POSTWIRE_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "name": "Corner Café Miraflores"
  }),
});
console.log(res.status, await res.json());
```

```python
import os, requests

r = requests.patch(
    "https://postwire.io/api/brands/b3f1c2d4-8a9e-4f6b-a1c2-3d4e5f6a7b8c",
    headers={"Authorization": f"Bearer {os.environ['POSTWIRE_API_KEY']}"},
    json={
        "name": "Corner Café Miraflores",
    },
)
print(r.status_code, r.json())
```

## Delete a brand and disconnect its networks (an account keeps at least one brand)

`DELETE /api/brands/{id}`

Needs an API key: `Authorization: Bearer pw_live_…`.

**Parameters**

| Field | Type | Description |
|---|---|---|
| `id` (required) | path, string |  |

**Responses**

| Status | Means |
|---|---|
| `200` | { ok } |
| `400` | the last brand |
| `404` | brand not found |

```bash
curl -X DELETE "https://postwire.io/api/brands/b3f1c2d4-8a9e-4f6b-a1c2-3d4e5f6a7b8c" \
  -H "Authorization: Bearer $POSTWIRE_API_KEY"
```

```js
const res = await fetch("https://postwire.io/api/brands/b3f1c2d4-8a9e-4f6b-a1c2-3d4e5f6a7b8c", {
  method: "DELETE",
  headers: { Authorization: `Bearer ${process.env.POSTWIRE_API_KEY}` },
});
console.log(res.status, await res.json());
```

```python
import os, requests

r = requests.delete(
    "https://postwire.io/api/brands/b3f1c2d4-8a9e-4f6b-a1c2-3d4e5f6a7b8c",
    headers={"Authorization": f"Bearer {os.environ['POSTWIRE_API_KEY']}"},
)
print(r.status_code, r.json())
```
