> ## 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.

# Cursor + Pocketsflow

> Connect Cursor to the Pocketsflow MCP server and docs so it can build and debug integrations against the Pocketsflow API.

[Cursor](https://cursor.com) is an AI-native code editor. Connect it to the
Pocketsflow **MCP server** and it can call the API as your account while you
build; add a project rule so it writes integration code the right way.

<Info>
  **Prerequisites**

  * Cursor installed.
  * A Pocketsflow API key from **Developers → API keys** (use `pk_test_…` while
    building).
</Info>

## Connect the Pocketsflow MCP server

Add the [Pocketsflow MCP server](/api-reference/mcp-server) to Cursor's MCP
config at `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (per project):

```json theme={null}
{
  "mcpServers": {
    "pocketsflow": {
      "url": "https://api.pocketsflow.com/mcp",
      "headers": {
        "Authorization": "Bearer pk_test_xxxxxxxxxxxxxxxxxxxxxxxx"
      }
    }
  }
}
```

Reload Cursor. In Composer/Chat (Agent mode), Cursor lists the Pocketsflow tools
and can run them — *"list my products"*, *"create a checkout link for product X"*,
*"show orders from the last 7 days"*. Each call runs as your account, scoped by
the key.

<Warning>
  Keep `~/.cursor/mcp.json` out of version control — it contains your API key.
  Prefer a `pk_test_…` key, and never commit `pk_live_…` keys.
</Warning>

## Add a project rule

Create a Cursor project rule so the editor follows Pocketsflow conventions when
generating code. In your integration repo:

```bash theme={null}
mkdir -p .cursor/rules
```

Create `.cursor/rules/pocketsflow.mdc`:

```markdown theme={null}
---
description: Building against the Pocketsflow API
alwaysApply: true
---

# Pocketsflow integration rules

- Base URL: https://api.pocketsflow.com
- Auth header: `Authorization: Bearer <API key>` (`pk_live_…` / `pk_test_…`).
- Secrets (API keys, webhook signing secrets) live in env vars — never in
  client-side code or the repo.

## Checkout
- Create a session with `POST /checkout/sessions` → `{ id, url }`.
- Redirect the buyer to `url`.
- Put our own order id in `metadata`; it is echoed back on the order and every
  related webhook — use it to reconcile.

## Webhooks
- Confirm payment from `order.completed`. Verify the `X-Pocketsflow-Signature`
  HMAC-SHA256 over the RAW request body before trusting the payload.
- Make handlers idempotent (an event may be re-sent).
- Return 2xx quickly; do heavy work asynchronously.

## References
- Docs: Integrations → Custom platforms, and API & Webhooks → Consuming webhooks.
- Interactive API reference: https://api.pocketsflow.com/docs
```

<Tip>
  Add `https://api.pocketsflow.com/docs.json` (the OpenAPI spec) to Cursor's
  **Docs** so it can search endpoint definitions while it codes. You can also
  use the **Open in Cursor** / **Copy as Markdown** action in the top-right of
  any docs page to hand a page in as context.
</Tip>

## Typical workflow

<Steps>
  <Step title="Describe the integration">
    In Agent mode, ask Cursor to build the checkout + webhook flow, referencing
    the rule and docs.
  </Step>

  <Step title="Let it call the API via MCP">
    Have it create a test product and a checkout session with your `pk_test_…`
    key to validate the request shape.
  </Step>

  <Step title="Test the webhook">
    Ask it to send a test event and confirm your handler verifies the signature
    and settles the order.
  </Step>
</Steps>

## 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)
* [Claude Code + Pocketsflow](/ai-tools/claude-code) · [Windsurf + Pocketsflow](/ai-tools/windsurf)
