# Authentication

## Personal access tokens

Open **Settings → API & MCP** in the account menu. Give the token a descriptive name and select the scopes your integration needs. Copy it when shown: the token value is displayed once and cannot be retrieved again.

You can revoke a token from the same page. Tokens expire six months after creation; expired or revoked tokens return `401 Unauthorized`.

### Request headers

Send these headers on API requests, replacing `YOUR_TOKEN` with your token:

```http
Authorization: Bearer YOUR_TOKEN
Accept: application/json
```

For JSON request bodies, also send:

```http
Content-Type: application/json
```

## Email verification

The token's account must have a verified email address. An unverified account cannot use `/api/v1` routes; a JSON request is rejected with `403` until verification is complete.

## MCP access

Your AI app must support a remote MCP server over Streamable HTTP with a custom bearer authorization header.

### Connect your client

1. Open **Settings → API & MCP**. Copy the **Server URL** under **Connect with MCP**.
2. Create a token with `teams:read`, `sites:read`, `checks:read`, and `issues:read` for read-only monitoring. Add `reports:read` for client reports.
3. Copy the token when it is shown.
4. Add the remote server in your AI app, choose **Streamable HTTP**, and set the `Authorization` header to `Bearer YOUR_TOKEN`.
5. Ask the client to list your Sitepulse teams using `sitepulse_list_teams`.

The hosted server URL is:

```text
https://app.sitepulse.dev/mcp
```

Use `/mcp`, without the REST API's `/api/v1` prefix. The transport uses:

```http
Authorization: Bearer YOUR_TOKEN
Accept: application/json, text/event-stream
```

Your client normally sets `Accept` itself. Clients that only offer interactive sign-in and cannot send a custom bearer header cannot use this connection method.

### Tools and permissions

MCP tools cover account and team discovery, monitoring settings, sites, checks, issues, per-site reports, and saved client reports. They use the same membership, roles, plan access, validation, and quotas as the API.

Use the opaque `uuid` strings returned by Sitepulse, including for tool arguments named `team_id`. Deletion tools also require `confirm: true`. Site updates must include the site's existing URL.

Tool failures return `isError: true` with the operation's status and message. A successful transport response does not establish that the tool's operation succeeded. [Report downloads](/docs/guide/reports/#api-and-mcp-access) return embedded file resources containing the MIME type and base64 bytes.

<span id="oauth-scopes"></span>

## Token scopes

A token's scope does not grant permissions that its account lacks. Both the token scope and the team's role rules must allow the operation. Missing scope returns `403 Forbidden`.

| Scope | Allows |
|-------|--------|
| `teams:read` | Read account teams, limits, and monitoring defaults. |
| `teams:write` | Update team monitoring defaults. |
| `sites:read` | Read sites, monitoring data, and per-site uptime/performance reports. |
| `sites:write` | Create and update sites, including assigning existing team tags. |
| `sites:delete` | Delete sites. |
| `checks:read` | Read checks and results. |
| `checks:run` | Run on-demand checks. |
| `checks:delete` | Delete on-demand checks where the account's role allows it. |
| `issues:read` | Read monitoring issues and workflow state. |
| `reports:read` | Read client-report schedules, recipients, history, saved results, and downloads. |

### Suggested scope sets

| Integration | Scopes |
|-------------|--------|
| Monitoring dashboard | `teams:read`, `sites:read`, `checks:read`, `issues:read` |
| Site provisioning | `teams:read`, `sites:read`, `sites:write` |
| Check runner | `teams:read`, `sites:read`, `checks:read`, `checks:run` |
| Team monitoring configuration | `teams:read`, `teams:write` |
| Client-report reader | `teams:read`, `reports:read` |

Client reports also require an owner or admin role and active Growth or Agency access, including the Growth trial. `sites:read` alone covers per-site uptime and performance reports, not saved client reports.

## Team access and billing

The account must belong to the team in the route, or the team owning the referenced site, check, issue, or report. Foreign team resources return `404`.

Protected routes require active trial or subscription access. Without it, requests return `402`, usually with:

```json
{
  "message": "An active team subscription is required."
}
```

An expired trial can return `Your trial has ended. Subscribe to resume monitoring.` The owner must restore access through **Billing**. Creating a different token does not restore monitoring access.

`GET /me` and `GET /teams` remain available for account and team discovery after access expires. Their authentication and scope requirements still apply.

`GET /issues` lists only teams with eligible access. With an explicit inactive `team` filter it returns `402`; if no eligible team can be listed it can return `403`. It is not a way to retrieve inactive teams' issue history.

## Protect your tokens

Store tokens in a secret manager or server-side environment variables. Do not put them in source control or browser-delivered JavaScript. Use a separate token for each integration, grant only necessary scopes, and revoke it when the integration is retired.

## Related references

- [API overview and examples](/docs/api/overview/)
- [Requests and responses](/docs/api/requests-responses/)
- [Endpoints](/docs/api/endpoints/)
