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

# AI playbook drafting

> Turn raw call notes and methodology docs into a publishable playbook in ~20 seconds.

Parlay's playbook drafting service synthesizes one or more **source materials** (call notes, transcripts, methodology docs, battle cards) into a structured markdown playbook using Gemini 2.5 Flash. The draft is reviewable; you promote it to "active" with a single call.

## The flow

1. **Upload source materials** — N free-form text blobs, each with a title
2. **Generate a draft** — async job synthesizes them into one markdown playbook
3. **Review** — read the draft, request more if you want
4. **Publish** — promote to the org's active playbook (auto-applied to every future analysis)

## When to use this

<CardGroup cols={2}>
  <Card title="Good fits" icon="check">
    * Onboarding a new partner — turn their existing collateral into a Parlay-formatted playbook
    * Refreshing an outdated playbook — feed in recent top-performer call notes
    * Generating role-specific playbooks (SDR vs AE vs CSM) from segmented inputs
  </Card>

  <Card title="When to skip" icon="x">
    * You already have a polished playbook in markdown — use `create_playbook` instead
    * You want to fine-tune the playbook prose word-by-word — generate, then `update_playbook` to edit
    * The org has zero source material — the model needs *something* to synthesize from
  </Card>
</CardGroup>

## Step 1 — Upload source materials

<CodeGroup>
  ```bash cURL theme={null}
  # First source
  curl -X POST \
    https://api.goparlay.io/v1/orgs/demo-acme/playbook-sources \
    -H "Authorization: Bearer pk_sandbox_YOUR_KEY" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: $(uuidgen)" \
    -d '{
      "title": "Top performer highlights",
      "content": "When customers push back on pricing, our top reps bridge to value by asking: what would solving this be worth in the next 12 months? They always confirm decision-making authority before scheduling a demo..."
    }'

  # Second source
  curl -X POST \
    https://api.goparlay.io/v1/orgs/demo-acme/playbook-sources \
    -H "Authorization: Bearer pk_sandbox_YOUR_KEY" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: $(uuidgen)" \
    -d '{
      "title": "Objection handling cheat sheet",
      "content": "Common objections and proven responses: 1) It costs too much → reframe to monthly cost ÷ ROI. 2) We already have a solution → dig into what is not working with the current setup..."
    }'
  ```

  ```javascript Node theme={null}
  const upload = (title, content) =>
    fetch(`${BASE_URL}/v1/orgs/demo-acme/playbook-sources`, {
      method: "POST",
      headers: {
        Authorization: `Bearer ${KEY}`,
        "Content-Type": "application/json",
        "Idempotency-Key": crypto.randomUUID(),
      },
      body: JSON.stringify({ title, content }),
    }).then((r) => r.json());

  const src1 = await upload("Top performer highlights", "When customers push back on pricing...");
  const src2 = await upload("Objection handling cheat sheet", "Common objections and proven responses...");
  ```
</CodeGroup>

Each source is up to 500,000 characters. You can upload 1 or 50 — the draft job accepts up to 50 source ids.

## Step 2 — Kick off the draft

```bash theme={null}
curl -X POST \
  https://api.goparlay.io/v1/orgs/demo-acme/playbook-drafts \
  -H "Authorization: Bearer pk_sandbox_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "source_material_ids": ["<src1_id>", "<src2_id>"]
  }'
```

Response:

```json theme={null}
{
  "draft_id": "b7ed4724-4204-4833-abe3-792d451371f1",
  "status": "queued",
  "created_at": "2026-04-24T18:53:17.867123+00:00"
}
```

## Step 3 — Poll until complete

```bash theme={null}
curl https://api.goparlay.io/v1/orgs/demo-acme/playbook-drafts/<draft_id> \
  -H "Authorization: Bearer pk_sandbox_YOUR_KEY"
```

Typical latency: **15–30 seconds**. When `status === "completed"`:

```json theme={null}
{
  "id": "b7ed4724-...",
  "status": "completed",
  "generated_content": "# Sales Playbook\n\n## Discovery Questions\n\n*   **Current Solution Gaps:** When a prospect indicates they already have a solution, dig into what specifically isn't working...\n\n## Budget Authority\n\nBefore scheduling a demo, confirm decision-making authority...\n\n## Objection Handling\n\n### Pricing pushback\nReframe price as ROI: \"What would solving this be worth in the next 12 months?\"\n...",
  "gemini_model": "gemini-2.5-flash",
  "gemini_input_tokens": 412,
  "gemini_output_tokens": 1853,
  "cost_usd_cents": 1
}
```

The `generated_content` is the full markdown playbook, ready to publish.

## Step 4 — Review and publish

If the draft looks good:

```bash theme={null}
curl -X POST \
  https://api.goparlay.io/v1/orgs/demo-acme/playbook-drafts/<draft_id>/publish \
  -H "Authorization: Bearer pk_sandbox_YOUR_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

This:

* Inserts the `generated_content` into the `playbooks` table as **version 1, is\_active=true**
* Marks the draft as `published`, sets `published_playbook_id`
* Fires a `playbook.published` webhook
* Returns `{ playbook_id, draft_id, published: true }`

From here on, every analysis under `demo-acme` automatically uses this playbook in the analysis prompt.

## Don't like the draft?

You have a few options:

* **Generate a new draft** with different sources or a different combination
* **Edit the draft externally**, then `create_playbook` directly with your edited content (skipping `publish_playbook_draft`)
* **Publish anyway, then `update_playbook`** to edit the content. This bumps the playbook version and snapshots history.

Drafts can't be republished once they've been published once.

## Doing this from MCP

```
For org "demo-acme", upload these two source materials [paste content], then generate a playbook draft from them. Show me the first 1,000 characters of the generated content. If it looks good, publish it.
```

The model calls `upload_playbook_source` (×2), `generate_playbook_draft` (auto-polls), shows you the preview, and (if you confirm) calls `publish_playbook_draft`.

## Cost + latency

| Operation                 | Cost          | Latency                                |
| ------------------------- | ------------- | -------------------------------------- |
| `upload_playbook_source`  | \$0           | under 1s                               |
| `generate_playbook_draft` | \~$0.01–$0.05 | 15–30s typical, up to 3 min worst case |
| `publish_playbook_draft`  | \$0           | under 1s                               |

Cost scales with input + output tokens. Two short sources (a few hundred chars each) → \~$0.01. Twenty long sources (50k chars each) → ~$0.05.

## What happens to the previous active playbook?

`publish_playbook_draft` does **not** automatically deactivate older playbooks. If you want only the new one active, follow up with:

```bash theme={null}
curl -X PATCH \
  https://api.goparlay.io/v1/orgs/demo-acme/playbooks/<old_playbook_id> \
  -H "Authorization: Bearer pk_sandbox_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "is_active": false }'
```

In a future release we'll add an option on `publish_playbook_draft` to deactivate other active playbooks atomically.
