# The HTTP API

Every tool as an HTTP endpoint: POST /v1/actions/{tool} with the tool’s parameters as JSON.

The HTTP API runs the same actions as the MCP server, with the same parameters, results and permission check. Use it from your own scripts and integrations.

Endpoint:

```http
POST https://api.withopenbook.com/v1/actions/{tool}
```

## Authentication

Send the person’s OAuth access token as a bearer token, got the same way ChatGPT gets one: see [Signing in](https://withopenbook.com/docs/mcp#signing-in). There are no API keys: every call acts as one person, and sees and does only what they can.

## Requests and responses

- The body is a JSON object with the tool’s parameters. Send `{}` for a tool with none.
- A successful call returns `200` with the tool’s result as JSON.
- Only tools in the person’s own list work. Any other returns `403` with the code `not_allowed`.

curl:

```bash
curl https://api.withopenbook.com/v1/actions/search_contacts \
  -H "Authorization: Bearer $OPENBOOK_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "coach", "limit": 10}'
```

TypeScript:

```ts
const res = await fetch('https://api.withopenbook.com/v1/actions/search_contacts', {
  method: 'POST',
  headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },
  body: JSON.stringify({ query: 'coach', limit: 10 }),
});
const result = await res.json();
```

Python:

```python
import json, urllib.request

req = urllib.request.Request(
    'https://api.withopenbook.com/v1/actions/search_contacts',
    data=json.dumps({'query': 'coach', 'limit': 10}).encode(),
    headers={'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'},
)
result = json.load(urllib.request.urlopen(req))
```

## Errors

An error returns a status code and a JSON body with a stable `code` and a `message` written for people, which ChatGPT can show as it is.

Error body:

```json
{ "error": { "code": "not_allowed", "message": "You can't use manage_owners" } }
```

| Code | Status | When |
|---|---|---|
| `unauthorized` | 401 | No token, or one that expired or was revoked. The `WWW-Authenticate` header says where to sign in. |
| `invalid` | 400 | A parameter is missing or wrong. The message names it. |
| `plan_required` | 402 | The feature needs a plan for the organization, like keeping requests about its contacts inside it; an owner works one out at withopenbook.com/start. |
| `needs_payment` | 402 | The group is Pay to join, so someone new pays for it themselves as they join, on withopenbook.com: invite them rather than giving them access. |
| `not_allowed` | 403 | The person can’t do this, or the tool isn’t in their list. |
| `not_found` | 404 | No such contact, group, request or match, for this person. |
| `needs_group` | 409 | The change would leave a contact in no group. Name one. |
| `needs_number` | 403 | Someone who added a group with no mobile number can only see it and leave it. Add a number first. |
| `budget_exhausted` | 429 | The person’s 3 people searches for today are used up. |
| `limit_reached` | 429 | A daily limit was reached: the person’s requests outside their groups for today, or their changes to their account for today. Try again tomorrow. |
| `plan_limit` | 402 | The change would go past the room its plan has, like a sixth group or a 26th person on the free plan. Nothing is hidden or deleted, and more room comes with a plan at withopenbook.com/billing, for whoever pays for it. |
| `needs_approval` | 403 | Only from Openbook Internal, the connector for Openbook’s own team: the connection’s first call of the day waits for its person to approve it on their phone, picking the number the message gives. Call again once they have. |

## Limits

- `find_people`: 3 searches a day for everyone.
- Requests outside your groups, from a match or for a missing field, have a daily limit.
- `import_contacts` and `add_to_private_contacts` take up to 500 contacts a call.
- `search_contacts` returns up to 100 at a time, with a cursor for the next page.
