> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pocketsflow.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code + Pocketsflow

> Connect Claude Code to the Pocketsflow MCP server and docs so you can build integrations, automate your store, and query your account from the terminal.

[Claude Code](https://www.anthropic.com/claude-code) is Anthropic's official CLI
coding agent. Connect it to Pocketsflow's **MCP server** and it can act on your
account directly — create products, read orders, issue refunds, manage
webhooks, and send newsletters — while also using the docs as context to write
integration code for you.

<Info>
  **Prerequisites**

  * Claude Code installed (`npm install -g @anthropic-ai/claude-code`).
  * A Pocketsflow API key. Create one in the dashboard under
    **Developers → API keys**. Use a `pk_test_…` key while building.
</Info>

## Two ways to use it

<CardGroup cols={2}>
  <Card title="Act on your account (MCP)" icon="plug">
    Connect the Pocketsflow MCP server so Claude Code can call the API as your
    account — no client code required.
  </Card>

  <Card title="Write integration code" icon="code">
    Point Claude Code at these docs to generate and debug checkout-session and
    webhook code against the public API.
  </Card>
</CardGroup>

## 1. Connect the Pocketsflow MCP server

The [Pocketsflow MCP server](/api-reference/mcp-server) exposes the full public
API as [Model Context Protocol](https://modelcontextprotocol.io) tools. Add it
with the Claude Code CLI:

```bash theme={null}
claude mcp add --transport http pocketsflow https://api.pocketsflow.com/mcp \
  --header "Authorization: Bearer pk_test_xxxxxxxxxxxxxxxxxxxxxxxx"
```

Then start `claude` in your project and ask things like:

* *"List my last 10 orders and their totals."*
* *"Create a \$29 product called Starter Kit and give me the checkout link."*
* *"Which subscriptions went past due this week?"*
* *"Refund order `ord_123` and tell the customer."*

Every tool call runs **as your account**, scoped by the API key. See
[MCP server](/api-reference/mcp-server) for the full tool list and transport
details.

<Warning>
  Treat API keys like passwords. A `pk_live_…` key lets the agent create and
  delete **real** data. Develop with `pk_test_…`, and use a dedicated, revocable
  key per integration.
</Warning>

## 2. Give Claude Code project context

Create a `CLAUDE.md` at the root of your integration project so Claude Code
follows Pocketsflow conventions when writing code:

```markdown theme={null}
# Pocketsflow integration project

## What we're building
A server-side integration with the Pocketsflow API: create checkout sessions,
redirect buyers, and settle orders from signed webhooks.

## Facts the agent must respect
- Base URL: https://api.pocketsflow.com
- Auth: `Authorization: Bearer <API key>`. Keys are `pk_live_…` / `pk_test_…`.
- Never put API keys or webhook signing secrets in client-side code.
- Create checkout: `POST /checkout/sessions` → returns `{ id, url }`. Redirect
  the buyer to `url`.
- Pass our own order id in `metadata`; it is echoed back on the order and every
  related webhook so we can reconcile.
- Confirm payment from the `order.completed` webhook — verify the HMAC-SHA256
  signature over the RAW body before trusting it. Make handlers idempotent.

## Conventions
- Use `pk_test_…` in development; read keys/secrets from environment variables.
- Prefer the patterns in the Pocketsflow docs (Integrations → Custom platforms).

## Do not
- Log secrets or full card data.
- Re-serialize the webhook body before verifying the signature.
- Mark an order paid without a verified webhook.
```

## 3. Use the docs as a source

Claude Code works best when it can read the authoritative reference. Point it at:

* **This documentation** — especially
  [Integrations overview](/integrations/overview),
  [Custom platforms](/integrations/custom-platforms), and
  [Consuming webhooks](/api-webhooks/consuming-webhooks).
* The **interactive API reference** at `https://api.pocketsflow.com/docs`
  (OpenAPI JSON at `/docs.json`).

<Tip>
  Every page in these docs has a **Copy / view as Markdown** and **Open in
  Claude** option in the top-right menu — hand a page straight to the agent as
  context instead of pasting URLs.
</Tip>

## Example: scaffold a webhook handler

Ask Claude Code:

> Using the Pocketsflow docs, write an Express endpoint that verifies the
> `X-Pocketsflow-Signature` header against the raw body, handles
> `order.completed` idempotently, and reads `metadata.external_order_id`.

It can generate the handler, wire up the signature check, and — with the MCP
server connected — send a test event to exercise it end to end.

## Related topics

* [MCP setup guide](/ai-tools/mcp)
* [MCP server](/api-reference/mcp-server)
* [Integrations overview](/integrations/overview)
* [Custom platforms](/integrations/custom-platforms)
* [Consuming webhooks](/api-webhooks/consuming-webhooks)
* [Cursor + Pocketsflow](/ai-tools/cursor) · [Windsurf + Pocketsflow](/ai-tools/windsurf)
