# Introduction (/api-reference)

The Plunk API is JSON over HTTPS. Every request goes to one base URL and authenticates with one of your project's two keys.

```text title="Base URL"
{{API_URL}}
```

## Authentication [#authentication]

Send your key as a bearer token in the `Authorization` header:

```http
Authorization: Bearer sk_your_secret_key
```

| Key    | Prefix | Works with                    | Use it from         |
| ------ | ------ | ----------------------------- | ------------------- |
| Secret | `sk_`  | Every endpoint but `/v1/track` | Your server only    |
| Public | `pk_`  | `POST /v1/track` only         | Browsers and apps   |

The project is derived from the key, so requests never carry a project ID. See [API keys](/api-keys) for rotation and revocation.

## Your first request [#your-first-request]

<Tabs groupId="language" persist items={["cURL","Node.js","Python"]}>
<Tab value="cURL">
```bash
curl {{API_URL}}/v1/send \
  -H "Authorization: Bearer $PLUNK_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to": "user@example.com", "subject": "Hello", "body": "<p>Your message here</p>"}'
```
</Tab>

<Tab value="Node.js">
```ts
async function sendEmail(to: string, subject: string, body: string) {
  const response = await fetch('{{API_URL}}/v1/send', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.PLUNK_SECRET_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({to, subject, body}),
  });

  const result = await response.json();
  if (!result.success) {
    throw new Error(`[${result.error.code}] ${result.error.message}`);
  }
  return result.data;
}
```
</Tab>

<Tab value="Python">
```python
import os
import requests

def send_email(to, subject, body):
    response = requests.post(
        "{{API_URL}}/v1/send",
        headers={"Authorization": f"Bearer {os.environ['PLUNK_SECRET_KEY']}"},
        json={"to": to, "subject": subject, "body": body},
    )
    data = response.json()
    if not data.get("success"):
        error = data["error"]
        raise Exception(f"[{error['code']}] {error['message']}")
    return data["data"]
```
</Tab>
</Tabs>

## Response format [#response-format]

The public endpoints (`/v1/send`, `/v1/track`, `/v1/verify`) wrap their result in an envelope:

```json
{
  "success": true,
  "data": {
    "contact": "cnt_abc123",
    "event": "evt_xyz789",
    "timestamp": "2025-11-30T10:30:00.000Z"
  }
}
```

Resource endpoints (contacts, templates, campaigns, segments, workflows) return the resource itself, with no `success` or `data` wrapper:

```json
{
  "id": "cnt_abc123",
  "email": "user@example.com",
  "createdAt": "2025-11-30T10:30:00.000Z"
}
```

Errors use one shape everywhere, with a machine-readable `code`, a `requestId` to quote to support and, for validation failures, the fields that failed. See [Errors](/api-reference/errors).

## Pagination [#pagination]

Most list endpoints page with a cursor:

```http
GET /contacts?limit=100&cursor=abc123
```

| Parameter | Description                                                  |
| --------- | ------------------------------------------------------------ |
| `limit`   | Items per page. Defaults to 20, at most 100.                 |
| `cursor`  | The `cursor` value from the previous response.               |

```json
{
  "data": [],
  "cursor": "def456",
  "hasMore": true,
  "total": 10000
}
```

Pass `cursor` back until `hasMore` is `false`. `total` is only counted on the first page, the one requested without a cursor; later pages return `total: 0` to keep listing fast.

A few endpoints, such as `GET /segments/:id/contacts`, page by number instead, with `page` and `pageSize`. Their responses carry `total`, `page` and `pageSize`.

## Rate limits [#rate-limits]

| Limit         | Value                                                     |
| ------------- | --------------------------------------------------------- |
| API requests  | 1,000 requests per minute per project                     |
| Email sending | Throttled per project to protect deliverability           |
| Bulk work     | Queued and processed in the background                    |

Requests over the limit get `429 Too Many Requests`.

## Where to go next [#where-to-go-next]

<Cards>
<Card title="Send transactional email" href="/api-reference/public-api/sendEmail">
The request and response of `POST /v1/send`, with a playground.
</Card>

<Card title="Track event" href="/api-reference/public-api/trackEvent">
Record an event on a contact and trigger workflows.
</Card>

<Card title="Errors" href="/api-reference/errors">
Status codes, error codes, and how to handle them.
</Card>

<Card title="All endpoints" href="/api-reference/endpoints">
Every route, grouped by resource.
</Card>
</Cards>