---
name: cdnpulse-setup
description: Set up CDN performance monitoring with CDNPulse. Use when you need to create a CDNPulse account, register a web application for CDN monitoring, or add the monitoring script to a website.
---

# CDNPulse Setup

CDNPulse monitors real-user CDN performance by collecting timing data from browsers via a lightweight script tag.

## Authentication

CDNPulse uses a **passwordless email flow**. A human must complete this step once to obtain a token.

1. **Request a code** — `POST https://api.cdnpulse.io/auth/signin` with `{"email": "user@example.com"}`
2. Check your inbox for the 6-digit verification code.
3. **Verify the code** — `POST https://api.cdnpulse.io/auth/verify` with `{"email": "user@example.com", "code": "123456"}`
4. The response contains `{"access_token": "...", "token_type": "bearer"}` — save this token.
5. Pass it on all REST API requests as `Authorization: Bearer <token>`.

> **Note for agents using the MCP server:** The email flow requires human inbox access and cannot be automated. Obtain a token once via the REST API above, then configure your MCP client to send it:
>
> ```json
> {
>   "mcpServers": {
>     "cdnpulse": {
>       "command": "npx",
>       "args": [
>         "mcp-remote",
>         "https://api.cdnpulse.io/mcp",
>         "--header",
>         "Authorization:Bearer ${CDNPULSE_TOKEN}"
>       ],
>       "env": {
>         "CDNPULSE_TOKEN": "<your-access-token>"
>       }
>     }
>   }
> }
> ```
>
> The MCP server will forward the token automatically to every tool call.

## Create an Application

```http
POST https://api.cdnpulse.io/api/apps
Authorization: Bearer <token>
Content-Type: application/json

{
  "name": "my-app",
  "website": "https://example.com",
  "description": "My web application",
  "public": false
}
```

- `name` — unique slug (lowercase alphanumeric + hyphens). **Cannot be changed after creation.**
- `website` — origin used for CORS validation when the script sends data.
- `public` — set `true` to allow unauthenticated analytics access.

A successful response returns the app object including the `name` used in all subsequent API calls.

## Add the Monitoring Script

Add this single `<script>` tag to every page you want to monitor, replacing `{name}` with your app name:

```html
<script
  src="https://api.cdnpulse.io/api/apps/{name}/cdnpulse.js"
  timing-allow-origin="*"
  crossorigin="anonymous"
  async
></script>
```

> **Important:** The page must also set the `Timing-Allow-Origin: *` response header so the script can read cross-origin resource timing data. Without it, CDN performance measurements will be empty.

## Manage Applications

| Action | Request |
|---|---|
| List all apps | `GET /api/apps` |
| Get one app | `GET /api/apps/{name}` |
| Update app | `PUT /api/apps/{name}` with partial JSON body |
| Delete app | `DELETE /api/apps/{name}` |

Full API reference: https://cdnpulse.io/openapi.yaml
