# Publisher API quickstart

> Create a scoped Shaw API key, inspect your workspace and monthly credits, search templates across languages, and compare Workspace vs. Docs MCP.

Shaw's HTTP API (`https://shaw.ai/api/*`) lets scripts, CI pipelines, and
backend services verify organization identity, check monthly credits,
discover templates, and publish remixes or hosted pages.

## Step-by-step setup [#step-by-step-setup]

<Steps>
  <Step title="Create a scoped API key">
    Sign in at [shaw.ai/login](https://shaw.ai/login), open **API keys**
    ([shaw.ai/app/developers](https://shaw.ai/app/developers)), choose **New
    key**, and grant only the scopes your workflow requires—typically `org:read`,
    `pages:read`, and `pages:write`. The secret starts with `sk_` and is shown
    once; store it in your environment or CI secret manager.
  </Step>
  <Step title="Target an organization">
    Every call runs inside one workspace. Pass
    `X-Shaw-Tenant: <organization-id>` when your account belongs to multiple
    organizations, or pin the API key to a single organization when creating it.
  </Step>
  <Step title="Inspect identity, credits, and catalog">
    Run `GET /api/me`, `GET /api/credits`, and `GET /api/templates/search` (all
    `0` credits) before inspecting `codeMetrics` or unlocking source with
    `POST /api/templates/use`.
  </Step>
</Steps>

## Verify identity, credits & search [#verify-identity-credits--search]

Run the three foundational read calls using `curl`, TypeScript (`fetch`), or
Python (`httpx` / `requests`):

<Tabs items={["curl", "TypeScript", "Python"]}>
  <Tab value="curl">

```sh
export SHAW_API_KEY="sk_..."

# 1. Verify publisher identity & accessible organizations (org:read)
curl -sS https://shaw.ai/api/me \
  -H "Authorization: Bearer $SHAW_API_KEY"

# 2. Check monthly credit allowance & remaining balance (org:read)
curl -sS https://shaw.ai/api/credits \
  -H "Authorization: Bearer $SHAW_API_KEY" \
  -H "X-Shaw-Tenant: org_01j9x2m4p7q8w2ab"

# 3. Search templates and preview credit cost at 0 credits (pages:read)
curl -sS "https://shaw.ai/api/templates/search?q=skincare&channel=websites&limit=5" \
  -H "Authorization: Bearer $SHAW_API_KEY" \
  -H "X-Shaw-Tenant: org_01j9x2m4p7q8w2ab"
```

  </Tab>
  <Tab value="TypeScript">

```ts
const base = "https://shaw.ai"
const headers = {
  Authorization: `Bearer ${process.env.SHAW_API_KEY}`,
  "X-Shaw-Tenant": process.env.SHAW_TENANT_ID ?? "",
}

const [meRes, creditsRes, searchRes] = await Promise.all([
  fetch(`${base}/api/me`, { headers }),
  fetch(`${base}/api/credits`, { headers }),
  fetch(`${base}/api/templates/search?q=skincare&channel=websites&limit=5`, {
    headers,
  }),
])

const me = await meRes.json()
const credits = await creditsRes.json()
const search = await searchRes.json()

console.log({
  activeTenant: me.activeTenant,
  remainingCredits: credits.data.remainingCredits,
  topTemplate: search.items[0],
})
```

  </Tab>
  <Tab value="Python">

```python
import os
import requests

base = "https://shaw.ai"
headers = {
    "Authorization": f"Bearer {os.environ['SHAW_API_KEY']}",
    "X-Shaw-Tenant": os.environ["SHAW_TENANT_ID"],
}

me = requests.get(f"{base}/api/me", headers=headers, timeout=15).json()
credits = requests.get(f"{base}/api/credits", headers=headers, timeout=15).json()
search = requests.get(
    f"{base}/api/templates/search",
    params={"q": "skincare", "channel": "websites", "limit": 5},
    headers=headers,
    timeout=15,
).json()

print(me["activeTenant"], credits["data"]["remainingCredits"], search["items"][0]["id"])
```

  </Tab>
</Tabs>

<EndpointCard
  method="GET"
  path="/api/templates/search"
  scope="pages:read"
  href="/api-reference/templates"
>
  Search and paginate Shaw's template catalog across brands, categories, and
  channels with pre-flight credit estimates.
</EndpointCard>

## Public catalog feeds [#public-catalog-feeds]

Unauthenticated catalog metadata across [Websites](https://shaw.ai/websites),
[Apps](https://shaw.ai/apps), [Emails](https://shaw.ai/emails), and
[19 categories](https://shaw.ai/categories) is also published at
`/api/templates/library.json` and `/api/templates/meta/<slug>`. Raw template
source archive routes under `/api/templates/zip/*` always return HTTP `403`.

## Workspace MCP vs. Docs MCP [#workspace-mcp-vs-docs-mcp]

Shaw operates two distinct MCP servers for different jobs:

|                    | Workspace MCP (`https://shaw.ai/mcp`)                                                                              | Docs MCP (`https://shaw.ai/docs/mcp`)                     |
| ------------------ | ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------- |
| **Purpose**        | Act inside your Shaw organization (Template Code Library, credits, Brand Kits, direct Klaviyo email import)        | Search and read public Shaw documentation                 |
| **Authentication** | Required (OAuth 2.1 + PKCE on `/app/connect`, or `Bearer sk_...` API key)                                          | None (public, read-only)                                  |
| **Key tools**      | `get_me`, `get_credits_balance`, `search_templates`, `get_template`, `use_template`, `publish_template_to_klaviyo` | `search_shaw`, `list_pages`, `get_page`                   |
| **Setup guide**    | [Claude, ChatGPT & MCP Plugin](/developers/mcp)                                                                    | Add `https://shaw.ai/docs/mcp` directly in any MCP client |

Every docs page is also served as clean Markdown by appending `.md` to its URL
(for example `https://shaw.ai/docs/guides/templates.md`), and the complete index
lives at [llms.txt](/llms.txt).

## Next steps [#next-steps]

- Connect Claude, ChatGPT, Codex, or Cursor in
  [Claude, ChatGPT & MCP Plugin](/developers/mcp).
- Understand per-page credit pricing, lifetime updates, Auto Top-Up, and
  `402 INSUFFICIENT_CREDITS` handling in [Monthly credits](/developers/credits).
- Review scopes, OAuth 2.1 discovery, and status codes in
  [Authentication & API keys](/developers/authentication).
- Explore the live [Templates API Reference](/api-reference/templates) or
  [Publishing templates to R2](/guides/publishing).

