# JamesPeralta.com API

Pull your conversations and code submissions from JamesPeralta.com into your own code or AI
agent.

- **Base URL:** `https://jamesperalta.com/api/v1`
- **OpenAPI 3.1 spec:** [`/api/v1/openapi.json`](https://jamesperalta.com/api/v1/openapi.json)
- **This guide as Markdown:** [`/api/docs.md`](https://jamesperalta.com/api/docs.md)

## Authentication

Create a key at [jamesperalta.com/api](https://jamesperalta.com/api). It starts with `jpk_` and
is shown once. Send it on every request:

```bash
export JP_API_KEY=jpk_...
curl https://jamesperalta.com/api/v1/me -H "Authorization: Bearer $JP_API_KEY"
# {"email":"you@example.com","role":"USER","permissions":["conversations:read",…],"fullAccess":true}
```

A key acts as you and sees only your data. Revoke it on the same page. You can have 10 active
keys, and each key can make 120 requests a minute.

## Use it from Claude Code or Codex

Give your agent the key and the guide, then ask for what you want:

```text
My JamesPeralta.com API key is in the JP_API_KEY environment variable. Read
https://jamesperalta.com/api/docs.md, then call GET https://jamesperalta.com/api/v1 with
"Authorization: Bearer $JP_API_KEY" to see what the key can do. Then: <your task>.
```

`GET /api/v1` returns links to this guide and the OpenAPI spec, what the key may do, and every
endpoint with the permission it needs and whether this key has it. Errors say what went wrong
and how to fix it, so an agent can recover on its own. Agents that speak MCP can use the
[MCP server](#more) instead.

## Permissions

Pick a key's permissions when you create it: **All**, **Read only**, or **Restricted** to the
ones you choose. Give an agent the least it needs. A read-only key can pull your data but never
change it.

| Permission           | Lets the key                                                                |
| -------------------- | --------------------------------------------------------------------------- |
| `conversations:read` | Read your AI conversations                                                  |
| `submissions:read`   | Read your code submissions                                                  |
| `resume:read`        | Read your resumes and Resume Coach sessions                                 |
| `resume:write`       | Talk to Resume Coach and accept or reject its edits                         |
| `interviews:read`    | Read your interviews and transcripts                                        |
| `interviews:write`   | Start interviews, talk to the interviewer, submit code, generate scorecards |
| `practice:read`      | Browse Peralta 75 questions and your progress                               |
| `practice:write`     | Submit Peralta 75 solutions                                                 |

What a key can do also depends on your account's role. `GET /api/v1/me` lists the key's
permissions, and each operation in the OpenAPI spec names the one it needs as `x-permission`.
A call without it returns `403 forbidden`, naming the missing permission.

## Conversations

Every AI conversation you've had on the website: Resume Coach, Mentor, Protege, tutor, chat,
the application tracker, mock interviews, interview pad AI Assist, and question authoring.

```bash
API=https://jamesperalta.com/api/v1
AUTH="Authorization: Bearer $JP_API_KEY"

# List them, newest first
curl "$API/conversations?limit=25" -H "$AUTH"
# {"items":[{"type":"resume-coach","id":"583c3299-…","title":"Tighten my bullets","startedAt":"2026-11-02T10:00:00.123456+00:00"}],"nextCursor":"eyJ…"}

# Read one, with every message
curl "$API/conversations/resume-coach/583c3299-…" -H "$AUTH"
# {"type":"resume-coach","id":"583c3299-…","title":"…","startedAt":"…",
#  "messages":[{"role":"user","content":"…","createdAt":"…"},{"role":"assistant","content":"…","createdAt":"…"}]}
```

Filter the list with `type`: `application-tracker`, `behavioral-interview`, `chat`,
`coding-interview`, `interview-pad`, `mentor`, `protege`, `question-authoring`, `resume-coach`,
`system-design-interview`, or `tutor`. A conversation returns up to 1,000 messages, and only
what you saw: your messages and the AI's replies.

## Submissions

Every time you pressed Submit, in a coding interview or in the practice editor.

```bash
curl "$API/submissions?limit=25" -H "$AUTH"
# {"items":[{"source":"practice","id":"…","questionTitle":"1. Two Sum","practiceQuestionId":"leetcode-1",
#   "interviewId":null,"language":"python","passed":true,"passedCount":4,"totalCount":4,
#   "code":"class Solution: …","submittedAt":"2026-11-02T10:00:00.123456+00:00"}],"nextCursor":null}
```

Filter with `source=interview` or `source=practice`. Interview submissions keep the test
results but not the code, so their `code` is `null`.

## Paging

Lists return up to `limit` items (1–100, default 25). When `nextCursor` isn't `null`, pass it
back as `cursor` for the next page:

```bash
curl "$API/conversations?cursor=eyJ…" -H "$AUTH"
```

## Errors

Errors have one shape. Every response has an `X-Request-Id` header; include it when you report
a problem.

```json
{ "error": { "code": "not_found", "message": "Conversation not found.", "requestId": "req_…" } }
```

| `code`             | HTTP | What to do                                              |
| ------------------ | ---- | ------------------------------------------------------- |
| `invalid_request`  | 400  | Fix the request; `message` says what's wrong            |
| `unauthorized`     | 401  | Check the key; it may be revoked                        |
| `forbidden`        | 403  | The key lacks the permission; `message` names it        |
| `payment_required` | 402  | Free interview allowance used up; upgrade at `/pricing` |
| `not_found`        | 404  | Check the id; other people's data is also a `404`       |
| `conflict`         | 409  | Can't do that now (turn running, interview ended, …)    |
| `rate_limited`     | 429  | Wait `Retry-After` seconds                              |
| `upstream_error`   | 502  | The model or code runner failed. Retry                  |
| `internal_error`   | 500  | Retry; report the `requestId` if it keeps happening     |

## More

The same key also drives Resume Coach, AI coding interviews, and Peralta 75 practice
(`/resume-coach`, `/coding-interviews`, `/practice`). Coach and interviewer replies can take a
few minutes, so use a generous client timeout. Every route, field, and error is in the
[OpenAPI spec](https://jamesperalta.com/api/v1/openapi.json).

AI agents can use those products through the MCP server at `https://jamesperalta.com/api/mcp`
with the same key:

```bash
claude mcp add --transport http jamesperalta https://jamesperalta.com/api/mcp \
  --header "Authorization: Bearer $JP_API_KEY"
```

### Connect Claude, ChatGPT, or Meta AI

Apps that support remote MCP connectors sign in with OAuth, so no key is needed. Add a custom
connector with the URL `https://jamesperalta.com/api/mcp`, sign in to JamesPeralta.com when
the app asks, and choose what it may do. The connection appears on
[jamesperalta.com/api](https://jamesperalta.com/api) as a connected app; revoke it there at any
time. Reconnecting the same app replaces its earlier connection.
