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

# Developers

> Automate your workspace with the Enterprise API, webhooks, the Node.js SDK, the MCP server for AI agents and the scoped payments partner API.

Everything in the Enterprise Admin is also available over HTTP, so you can
build your own back office, reconcile in your systems or approve withdrawals
from your own risk checks.

> [card] [Enterprise API reference](https://docs.pocketsflow.com/api-reference/enterprise.md)
>
> Workspace, sub-accounts, transactions, customers, withdrawals, earnings,
> settings, webhooks, audit log and the payments partner API.

> [card] [Interactive reference](https://api.pocketsflow.com/enterprise/docs)
>
> The Enterprise API on its own page: every endpoint, schema and a
> try-it console. OpenAPI JSON at `/enterprise/docs.json`.

> [card] [Webhooks](https://docs.pocketsflow.com/enterprise/webhooks.md)
>
> Signed events for sign-ups, sales, refunds and withdrawals.

> [card] [AI agents (MCP)](https://docs.pocketsflow.com/enterprise/mcp.md)
>
> Every endpoint as a tool for Claude, ChatGPT, Cursor or your agent.

> [card] [Node.js SDK](https://docs.pocketsflow.com/api-reference/sdk.md)
>
> The `pocketsflow` package, `enterprise` namespace (3.13.0 for
> everything on this page).

## Authenticate

Create a key in **Settings > API keys** (owners) and send it as a bearer token.
Base URL `https://api.pocketsflow.com`, every path under `/v1/enterprise`.

```bash theme={"system"}
curl https://api.pocketsflow.com/v1/enterprise/subaccounts \
  -H "Authorization: Bearer ek_live_..."
```

Seller keys (`pk_live_...`) don't work here: `/v1/enterprise` takes enterprise
keys (`ek_live_...`) only.

## The SDK

```bash theme={"system"}
npm install pocketsflow
```

```ts theme={"system"}
import { Pocketsflow } from "pocketsflow";

const pf = new Pocketsflow({ apiKey: process.env.POCKETSFLOW_ENTERPRISE_KEY! });

// Sellers
const { items } = await pf.enterprise.subaccounts.list({ filter: "selling" });
await pf.enterprise.subaccounts.holdPayouts(items[0].userId, { reason: "Review" });

// Withdrawals
await pf.enterprise.settings.setPayouts({ approvalRequired: true });
await pf.enterprise.subaccounts.setWithdrawalApproval(items[0].userId, "auto");
const pending = await pf.enterprise.withdrawals.list({ status: "pending" });

// Layout and your own fees on top of ours: 2% a sale, 0.5% + $1 a withdrawal
await pf.enterprise.settings.setDesign({ layout: "bank_first" });
await pf.enterprise.settings.setFees({ tenantMarkupRate: 0.02, tenantWithdrawalRate: 0.005, tenantWithdrawalFixedUsd: 1 });

// Buyers, a sale in full, the overview
const buyers = await pf.enterprise.customers.list({ search: "@gmail.com" });
const buyer = await pf.enterprise.customers.get(buyers.items[0].id); // stats + purchases
const sale = await pf.enterprise.transactions.get(buyer.purchases[0].id);
const { kpis } = await pf.enterprise.workspace.overview({ range: "30d" });

// Webhooks
await pf.enterprise.webhooks.create({ url: "https://hooks.example.com/pf", events: ["withdrawal.requested"] });

// Payments partner API, scoped to your sellers
const payments = await pf.enterprise.partner.get("payments", {
  company_id: items[0].partnerAccountId!,
  first: 20,
}); // { mode: "sandbox" } as a third argument for the sandbox

// Writes: request(method, path, { body, query, mode })
await pf.enterprise.partner.request("POST", "payments/pay_xxx/refund");
```

## Payments partner API

`/v1/enterprise/partner/{live|sandbox}/{path}` forwards to the payments
partner's own REST API with our credentials, limited to your sellers' accounts.
You never hold a partner key.

* Use a seller's `partnerAccountId` (or `partnerSandboxAccountId`) from the
  sub-account row as `company_id` on lists (`account_id` for payouts).
* Routes: the account and its ledger, account links, payments (read, refund,
  void, retry), refunds, disputes (read, evidence), products and promo codes,
  checkout configurations, invoices, memberships (read, update, cancel, pause,
  resume, extend), members, and read-only payouts and payout methods.
* Anything outside your sellers, or outside the allowed routes, answers `404`.
  Withdrawals never go through it: they use your approval flow.
* 120 calls a minute per key. Writes are in your audit log.

Full list: [Payments partner API](https://docs.pocketsflow.com/api-reference/enterprise.md#payments-partner-api).

## Limits and errors

| | |
| - | - |
| Rate limit | 200 requests a minute per IP; the partner API 120 a minute per key |
| Paging | `page`, `pageSize` (max 100); lists answer `{ items, page, pageSize, total }` |
| Errors | `{ "code", "message" }` with the HTTP status. Another workspace's data is `404`. A suspended workspace is `403 tenant_suspended`. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.