# Onboarding profile

> What a signed-in person told the app about their role, product and territory. Session only, free, and used to frame Ask answers.

Source: https://openpipe.health/docs/api/profile/

The web app asks a new person a few questions: what their company sells, their role, who they sell to, what their product is for, and which states they cover. The answers are their profile. [Ask](https://openpipe.health/docs/api/ask.md#answers-framed-for-the-asker) uses it to frame answers.

A profile belongs to a person, not to a workspace and not to an API key. It follows the person into every workspace they open.

- **Session only.** Every endpoint on this page needs a [session token](https://openpipe.health/docs/authentication.md#two-kinds-of-token). An API key gets `403` with `A profile belongs to a signed-in person. An API key does not have one.`
- **Free.** Nothing here spends credits.
- **No user id in any request.** The profile read or written is always the one of the person the session belongs to.
- **Request bodies are at most 8 KB.** A larger one gets `413` with code `TOO_LARGE`.

These endpoints exist for the app's onboarding screens. They are documented so the behaviour is clear.

## Limits

Counted per person, per minute, in every workspace together. Switching workspace does not reset them. They apply on top of the [general rate limits](https://openpipe.health/docs/api/errors.md#rate-limits), and on these four endpoints the `RateLimit-*` headers describe the limit below.

| Endpoint | Limit |
|---|---|
| `PUT /api/profile` | 120 per minute |
| `GET /api/profile/resolve` | 90 per minute |
| `POST /api/profile/market` | 12 per minute |
| `POST /api/profile/suggestions` | 6 per minute |

`GET /api/profile` has no limit of its own.

## Get your profile

```http
GET /api/profile
```

```sh
curl "$OPH_API/api/profile" -H "Authorization: Bearer $OPH_SESSION"
```

`$OPH_SESSION` stands for a session token. See [Authentication](https://openpipe.health/docs/authentication.md#browser-sign-in) for how the app gets one.

```json
{
  "profile": {
    "sells": "devices",
    "role": "rep",
    "buyers": ["hospitals", "clinicians"],
    "focus": {
      "text": "knee replacement",
      "items": [{ "kind": "procedure", "code": "27447", "label": "…" }]
    },
    "territory": ["FL", "GA"],
    "suggestions": null,
    "step": 4,
    "completedAt": null,
    "skippedAt": null,
    "updatedAt": "2026-12-05T04:10:02.000Z"
  },
  "exists": true
}
```

| Field | Values |
|---|---|
| `sells` | `devices`, `pharma`, `diagnostics`, `healthit`, `services`, `other`, or `null` |
| `role` | `rep`, `leader`, `marketing`, `analyst`, `bizdev`, `founder`, or `null` |
| `buyers` | Any of `hospitals`, `groups`, `clinicians`, `asc`, `labs` |
| `focus.text` | What the person typed, up to 80 characters |
| `focus.items` | Up to 5 things in the data that the text was matched to. See [focus items](#focus-items). |
| `territory` | Two-letter codes of the 50 states and DC, sorted |
| `suggestions` | The last result of [Build suggestions](#build-suggestions), or `null` |
| `step` | The onboarding step the person is on, 0 to 5 |
| `completedAt`, `skippedAt` | When the person finished or skipped onboarding |

A person with no profile yet gets an empty one and `"exists": false`.

## Update your profile

```http
PUT /api/profile
```

Send only the fields to change. Each one replaces the stored value.

```json
{ "role": "rep", "territory": ["FL", "GA"], "step": 4 }
```

| Field | Rule |
|---|---|
| `sells`, `role` | One of the values above, or `null` |
| `buyers` | An array of the values above |
| `focus` | `{ "text": "…", "items": [ … ] }`. `text` can be 200 characters; it is stripped of markup and control characters and cut to 80. At most 5 items. |
| `territory` | An array of state codes. Anything other than the 50 states and DC is rejected. |
| `step` | An integer from 0 to 5 |
| `status` | `completed` sets `completedAt` and clears `skippedAt`. `skipped` sets `skippedAt`, unless the profile is already completed. |

An unknown field is rejected, at the top level and inside `focus` and its items. Returns `{ "profile": { … } }` with the stored profile.

| Status | Message |
|---|---|
| `400` | `Invalid profile: <field>: <what is wrong>` |
| `413` | `Request body is too large (8 KB limit).` |
| `429` | `Too many profile updates. Try again in 12s.` |

### Focus items

An item names one thing in the data, in one of three shapes:

```json
{ "kind": "procedure", "code": "27447" }
{ "kind": "drug", "name": "Apixaban", "by": "generic" }
{ "kind": "specialty", "name": "Cardiology" }
```

- `code` is a five-character HCPCS code. `by` is `generic` or `brand`.
- Every item is checked against the data. A code or name that is not there is dropped without an error, and duplicates are removed.
- `label` is written by the server from its own index. A `label` sent in the request is ignored.

Use [Match text to the data](#match-text-to-the-data) to get items that will pass the check.

## Match text to the data

```http
GET /api/profile/resolve
```

Turns what someone typed into procedures, drugs and specialties that exist in the data. It is fast enough to call as a person types.

| Parameter | Meaning |
|---|---|
| `q` | The text. Fewer than 2 characters, not counting spaces, returns no matches. Only the first 80 characters are used, and more than 200 is rejected. |
| `sells` | Optional. One of the `sells` values, used to rank the kinds of match. |

```json
{ "q": "knee", "matches": [ … ], "drugsPending": false, "guess": null }
```

- `matches` are candidates to offer as [focus items](#focus-items).
- `drugsPending` is `true` while the drug names are still loading; drug matches can be missing until then.
- `guess` is `procedure`, `drug`, `specialty`, `unclear` or `null`. It is set only when the text matched more than one kind of thing and a classifier answered in time.
- The response has a `Server-Timing` header with the time spent matching.

## Size your market

```http
POST /api/profile/market
```

Takes no body. Computes a few headline numbers for the profile's buyers, focus and territory.

```json
{
  "headline": "…",
  "scope": "…",
  "metrics": [
    { "id": "…", "label": "…", "format": "number", "sql": "SELECT …", "sources": ["medicare_service"], "value": 1234, "detail": null, "engine": "postgres", "ms": 40 }
  ],
  "ms": 412
}
```

- Every metric carries the SQL that produced it and the datasets it read, like any other [receipt](https://openpipe.health/docs/receipts.md). Each statement runs through the read-only checks with a time limit of 8 seconds.
- A metric that fails has `"value": null` and an `error`. The others are still returned.
- A result with no failed metric is kept for 10 minutes and returned with `"cached": true` to anyone whose buyers, focus and territory are the same.
- When the numbers cannot be computed yet, the response is still `200`, with an `unavailable` message and `retry`: `true` if it is worth asking again shortly.
- `409` with `Your saved focus no longer matches the data. Pick it again.` if a focus item is no longer in the data.

## Build suggestions

```http
POST /api/profile/suggestions
```

Takes no body. Builds starter questions and dashboard ideas for the profile, stores them on it, and returns them.

```json
{
  "suggestions": {
    "questions": [{ "text": "…", "family": "…" }],
    "dashboards": [{ "title": "…", "question": "…", "family": "…" }],
    "source": "templates",
    "builtAt": "2026-12-05T04:12:44.000Z"
  },
  "timing": { "ms": 380, "decisionMs": 120, "decision": "used" }
}
```

- Questions come from templates filled in with the profile. `source` is `templates+model` when a model added up to two more; those have `"family": "model"`.
- `timing.decision` is `used` when a model ranked the templates for this person, and `fallback` when it was unavailable and the default order was used.
- The suggestions are text to send to [Ask](https://openpipe.health/docs/api/ask.md). Building them runs no query against the data and costs nothing; asking one costs the usual 25 credits.
