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

# Deepline SDK

> Write GTM workflows that turn raw accounts, people, and signals into enriched customer lists and updates in the systems your team uses.

<Note>
  Beta: the SDK docs are published and usable, but the surface is still
  evolving.
</Note>

Write GTM workflows that just work: start from a search, CSV, webhook, or schedule; enrich the right records; route each customer through the right path; push the result to Salesforce, a sequencer, a warehouse, or a CSV; then visualize what changed.

## 1. Pick the job

Keep the use case short. The workflow can hold the detail.

| Job                   | Example                                                                |
| --------------------- | ---------------------------------------------------------------------- |
| Weekly account search | Find new companies, enrich them, send qualified accounts to Salesforce |
| Custom waterfall      | Try providers in your order, stop at the first verified email          |
| Segment routing       | Run one path for directors, another for VPs                            |
| Inbound routing       | Enrich demo requests and send the right context to the owner           |
| Data review           | Export a CSV and chart segments, signals, and gaps                     |

## 2. Pilot one record

Start with a prebuilt workflow before writing your own.

```bash theme={null}
deepline plays describe prebuilt/person-linkedin-to-email --json

deepline plays run prebuilt/person-linkedin-to-email \
  --input '{"linkedin_url":"https://www.linkedin.com/in/real-person/"}' \
  --watch
```

Use a real lead you are allowed to enrich. A fake LinkedIn URL can return nothing.

## 3. Pilot a small list

```bash theme={null}
head -n 4 leads.csv > /tmp/leads-pilot.csv

deepline plays run lead-email-waterfall.play.ts \
  --csv /tmp/leads-pilot.csv \
  --watch

deepline runs export <run-id> --out /tmp/leads-pilot-enriched.csv
```

Inspect the output. If the rows look right, run the full file.

## 4. Add your business logic

This is where the SDK matters.

```ts theme={null}
import { definePlay } from 'deepline';

type Lead = {
  lead_id: string;
  seniority: 'VP' | 'Director';
  company_domain: string;
};

export default definePlay(
  'route-leads-by-seniority',
  async (ctx, input: { leads: Lead[] }) => {
    const rows = await ctx
      .dataset('routed_leads', input.leads)
      .withColumn('research', async (lead, rowCtx) => {
        if (lead.seniority === 'VP') {
          return await rowCtx.tools.execute({
            id: 'vp_research',
            tool: 'test_rate_limit',
            input: { key: lead.company_domain },
            description: 'Research this enterprise lead.',
          });
        }

        return await rowCtx.tools.execute({
          id: 'director_research',
          tool: 'test_rate_limit',
          input: { key: lead.company_domain },
          description: 'Research this midmarket lead.',
        });
      })
      .run({
        key: 'lead_id',
        description: 'Route each lead to the right research workflow.',
      });

    return { rows };
  },
);
```

Use this for custom waterfalls, segment-specific paths, weekly searches, and background jobs.

## 5. Ship the output

```bash theme={null}
deepline plays run weekly-new-accounts.play.ts \
  --input '{"query":"B2B SaaS companies hiring RevOps"}' \
  --watch

deepline runs export <run-id> --out output/new-accounts.csv
```

Then push to Salesforce, send to a sequencer, write to your warehouse, or chart the result.

## Examples

<CardGroup cols={2}>
  <Card title="Weekly company search to Salesforce" icon="building" href="/docs/sdk-v2/examples#weekly-company-search">
    Search once a week, enrich new accounts, and create Salesforce tasks.
  </Card>

  <Card title="Custom email waterfall" icon="water" href="/docs/sdk-v2/examples#lead-email-waterfall">
    Try your preferred providers and stop at the first verified email.
  </Card>

  <Card title="Director vs VP routing" icon="route" href="/docs/sdk-v2/examples#segment-specific-routing">
    Run different research paths based on buyer type.
  </Card>

  <Card title="Inbound webhook enrichment" icon="webhook" href="/docs/sdk-v2/examples#inbound-lead-webhook">
    Enrich form fills and route them to the right owner.
  </Card>

  <Card title="Nightly account refresh" icon="clock" href="/docs/sdk-v2/examples#nightly-account-refresh">
    Refresh account signals on a schedule with a run cap.
  </Card>

  <Card title="Python caller" icon="code" href="/docs/sdk-v2/examples#python-caller">
    Trigger a saved workflow from Airflow, notebooks, or backend jobs.
  </Card>
</CardGroup>

## Reference

<CardGroup cols={2}>
  <Card title="SDK Reference" icon="book" href="/docs/sdk-v2/sdk-reference">
    CLI commands, workflow authoring, config, triggers, and org safety.
  </Card>

  <Card title="API Reference" icon="brackets-curly" href="/docs/sdk-v2/api-reference">
    HTTP request shapes for starting and checking workflow runs.
  </Card>
</CardGroup>
