# REST API

Source: https://pinprompt.veren-technology.com/docs/reference/api

pinprompt's web app, the Chrome extension and CI all use one HTTP API at `<your pinprompt>/api/v1`. This page covers the calls that are useful outside pinprompt: reading projects and items, the spec and its versions, commenting, the generated Playwright test, and reporting CI results.

**Status: Beta.** These calls are what the product uses today and may still change between releases; the [changelog](https://pinprompt.veren-technology.com/docs/reference/changelog.md) says when one does. Coding agents should use the [MCP server](https://pinprompt.veren-technology.com/docs/reference/mcp.md) instead: it carries the whole agent loop (claim, ask, attach a pull request) and its tools only ever gain optional inputs.

## Authentication

Send a token in the `Authorization` header:

```bash
curl -H "Authorization: Bearer pp_…" https://<your pinprompt>/api/v1/projects
```

| Token | Where it comes from | What it can call |
|---|---|---|
| **Agent token** | *Settings → Agents → New agent* (shown once) | Its own project only, with the agent role: read the project and its items, the spec and evidence, comment as a team note, report CI checks, get the Playwright test. It can't triage, approve, change status or close anything. A "CI" agent is the usual choice for pipelines. |
| **Personal token** (the extension's) | Created when someone connects the Chrome extension | Only the extension's own calls. Anything else answers `403` with "A personal token only makes the extension's calls". Don't use it for scripts. |
| **Browser session** | Signing in to pinprompt | Everything the person's role allows, from the pinprompt app itself. Calls that change something also need a same-origin request. |

Every call checks the token's role in the project, on the server. A missing or unknown token gets `401`.

## Errors and limits

Errors are JSON with a stable `code`:

```json
{ "error": { "code": "forbidden", "message": "You don't have permission to do that" } }
```

| Status | `code` | Means |
|---|---|---|
| 400 | `bad_request` | The query or body didn't validate; the message names the field |
| 401 | `unauthorized` | No token, or one pinprompt doesn't know |
| 403 | `forbidden` | The token's role can't do this |
| 403 | `csrf` | A browser-session call that changes something came from another site |
| 403 | `plan_limit` | The workspace's plan doesn't allow this; the message says which limit |
| 404 | `not_found` | No such project or item, or not one this token can see |
| 409 | `conflict` | The item moved on (for example someone else claimed it) |
| 422 | `invalid` | The request is well-formed but not allowed in the item's state (the message says why) |
| 413 | `too_large` | The body is over its cap (1 MB for most calls, 2 MB for a check report) |
| 415 | `unsupported_media_type` | A browser-session call whose body isn't `Content-Type: application/json` (with a token, a body that isn't JSON gets `400`) |
| 429 | `rate_limited` | Too many requests. Some answers carry `Retry-After`; when one doesn't, wait a minute and back off (check reports, for example, are capped per hour) |
| 500 | `internal` | Something went wrong on the server; the message never carries details |

Items are named by their key (`FB-1188`) or their id (`itm_…`) wherever a path says `:item`. Projects are named by their id or slug.

## Projects

### `GET /api/v1/projects`

The projects the token can see: `{ projects: [{ id, key, slug, name, … }] }`. With `?url=<page URL>`, only the projects whose sites match that page.

### `GET /api/v1/projects/:project/items`

The project's items, newest activity first: `{ items, counts, next_cursor }`.

| Query | Values |
|---|---|
| `view` | `inbox` (default), `triage`, `to_approve`, `mine`, `agent_ready`, `with_agent`, `to_check`, `done` |
| `status`, `kind`, `priority`, `label`, `env` | Comma-separated lists, for example `kind=bug,copy&priority=P0,P1` |
| `assignee` | Comma-separated: `me`, `none`, `agent`, or people's or agents' ids |
| `reporter` | Comma-separated people's ids |
| `page` | A page path on the site, for example `/collections` |
| `q` | Text search: an item key (`FB-12`) finds that item; other words search titles, page paths, the spec and the thread |
| `has_pr` | `1` or `0` |
| `created_after`, `created_before`, `updated_after`, `updated_before` | `YYYY-MM-DD` or unix milliseconds |
| `sort` | `updated` (default), `created`, `priority` |
| `limit`, `cursor` | Page size from 1 to 2000 (default 500), and the previous response's `next_cursor`; it's `null` on the last page |

Each item has `id`, `key`, `title`, `kind`, `status`, `priority`, `pagePath`, `breakpoint`, `reporter`, `assignee`, `waitingOn`, `labels`, and comment and vote counts.

## Items

### `GET /api/v1/items/:item`

One item in full: everything in the list, plus the current `spec` ([The feedback spec](https://pinprompt.veren-technology.com/docs/feedback-spec.md)) and `specVersion`, the spec's `versions`, the page URL and anchor, the thread's `messages`, `evidence`, `references`, agent `runs`, links to issues and pull requests, and the latest `checks`. A client's token never gets team-only notes, selectors or code paths.

### `GET /api/v1/items/:item/specs/:version`

One earlier version of the spec, with who changed it and when.

### `GET /api/v1/items?pr=<pull request URL>`

The items linked to a pull request (by an agent's `attach_run`, or a code host integration): `{ items: [{ key, title, status, specVersion, projectId }] }`. The CI action uses it to find which items a pull request fixes.

### `POST /api/v1/items/:item`

Acts on an item. The body names the action; the response is the item afterwards. With an agent token, only `comment` is allowed, and it's always a team note:

```json
{ "action": "comment", "body": "Fixed in #215; the preview is building." }
```

People signed in to pinprompt use the same call for every other action (status, route, assign, priority, labels, verify), each checked against their role. Only people mark an item done.

## Checks in CI

### `GET /api/v1/items/:item/playwright`

The item's acceptance checks as a ready-to-run Playwright test (`FB-1188.spec.ts`), as a file. `?format=json` returns `{ key, filename, specVersion, asserted, fixme, code }` instead. Measurable checks are real assertions; the rest are `test.fixme` with the check's text.

### `POST /api/v1/items/:item/checks`

Records one CI run of that test on the item: send the Playwright JSON report, or `results` per check, and where it ran.

```json
{
  "results": [{ "id": "AC-1", "status": "passed" }, { "id": "AC-2", "status": "failed", "message": "expected 16px, got 24px" }],
  "previewUrl": "https://pr-215.example.app",
  "ciUrl": "https://github.com/acme/web/actions/runs/123",
  "prUrl": "https://github.com/acme/web/pull/215",
  "commitSha": "a1b2c3d",
  "specVersion": 2
}
```

`201` with the stored run. A run never closes an item: a person still signs it off. `GET` on the same path lists earlier runs, newest first. The whole set-up, with the GitHub Action: [Playwright checks](https://pinprompt.veren-technology.com/docs/reference/playwright-checks.md).

## Webhooks instead of polling

To hear about changes as they happen, connect a [webhook](https://pinprompt.veren-technology.com/docs/reference/webhooks.md): pinprompt sends signed JSON for every item event.
