> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clipstake.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Create an API key, list your campaigns and read their metrics and clips.

## 1. Create an API key

1. Sign in to the ClipStake web app.
2. Open **Settings**, then **API keys**.
3. Select **Create API key** and give the key a name.
4. Copy the key. ClipStake shows it only once.

Store the key on your server, for example in an environment variable.

```bash theme={null}
export CLIPSTAKE_API_KEY="cb_live_..."
```

## 2. List your campaigns

```bash curl theme={null}
curl "https://app.clipstake.com/api/v1/brand/campaigns" \
  --header "Authorization: Bearer $CLIPSTAKE_API_KEY"
```

```javascript JavaScript theme={null}
const response = await fetch("https://app.clipstake.com/api/v1/brand/campaigns", {
  headers: { Authorization: `Bearer ${process.env.CLIPSTAKE_API_KEY}` },
});
const { data, next_cursor } = await response.json();
```

Each campaign in `data` has an `id` that starts with `cmp_`. Copy one ID for
the next steps.

To list the campaigns of one brand, add `brand_id`:

```bash theme={null}
curl "https://app.clipstake.com/api/v1/brand/campaigns?brand_id=brd_..." \
  --header "Authorization: Bearer $CLIPSTAKE_API_KEY"
```

## 3. Read the campaign metrics

```bash curl theme={null}
curl "https://app.clipstake.com/api/v1/brand/campaigns/$CAMPAIGN_ID/metrics" \
  --header "Authorization: Bearer $CLIPSTAKE_API_KEY"
```

```javascript JavaScript theme={null}
const response = await fetch(
  `https://app.clipstake.com/api/v1/brand/campaigns/${campaignId}/metrics`,
  { headers: { Authorization: `Bearer ${process.env.CLIPSTAKE_API_KEY}` } },
);
const metrics = await response.json();
```

The metrics are the same figures that the campaign dashboard shows.

## 4. Page through the clips

To list only some clips, add `status` or `platform`. For example,
`?status=approved&platform=instagram` lists the approved Instagram clips.

A list returns up to 25 items by default. Send `next_cursor` back as `cursor`
to get the next page. Stop when `next_cursor` is `null`.

```bash curl theme={null}
curl "https://app.clipstake.com/api/v1/brand/campaigns/$CAMPAIGN_ID/clips?limit=100" \
  --header "Authorization: Bearer $CLIPSTAKE_API_KEY"

curl "https://app.clipstake.com/api/v1/brand/campaigns/$CAMPAIGN_ID/clips?limit=100&cursor=$NEXT_CURSOR" \
  --header "Authorization: Bearer $CLIPSTAKE_API_KEY"
```

```javascript JavaScript theme={null}
const clips = [];
let cursor = null;

do {
  const url = new URL(
    `https://app.clipstake.com/api/v1/brand/campaigns/${campaignId}/clips`,
  );
  url.searchParams.set("limit", "100");
  if (cursor) url.searchParams.set("cursor", cursor);

  const response = await fetch(url, {
    headers: { Authorization: `Bearer ${process.env.CLIPSTAKE_API_KEY}` },
  });
  const page = await response.json();
  clips.push(...page.data);
  cursor = page.next_cursor;
} while (cursor);
```

## Next steps

* Read [Pagination](https://docs.clipstake.com/brand-api/pagination.md) before you follow a cursor with
  filters.
* Read [Errors](https://docs.clipstake.com/brand-api/errors.md) to handle each error code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.