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

# SDK

> TypeScript interfaces for authoring Plays and calling Deepline from applications.

The **Deepline SDK** connects TypeScript code to Deepline. It supports two
related jobs: defining work that runs inside a Play, and calling Deepline from
an application or script. The SDK uses the same org and remote execution
model as the CLI and web app.

A custom Play can combine tools, datasets and other Plays. An application can
start that Play, retain its run ID and retrieve the result later. These two
sides use different objects because one describes the workflow and the other
controls its execution.

## Inside a Play: describe the work

A Play file imports `deepline` and default-exports an async function of its
input. The function's parameter and returned object define its input and result.
Optional `export const config` supplies its name, description, triggers, and
limits. Runtime methods create observable units of work:

| Capability | What it contributes |
| - | - |
| Tools | Supported provider reads, searches and external operations. |
| Steps | Named scalar work and checkpoints. |
| Datasets and CSV input | Row processing, computed columns and retained results. |
| Recorded HTTP requests | External requests with execution history. |
| Child Plays | Reusable scalar logic or independently launched work. |
| Sleeps and event waits | Continuation after a delay, event or supported human response. |
| Database queries | Access to permitted customer data and persistent business state. |
| Logs and declared secrets | Diagnostic context and controlled access to credentials. |

TypeScript describes the expected input and result. Deepline's authoring
checks validate supported structure, tool contracts and configuration before
execution. The admitted graph connects these operations to the
[Play's run history](https://deepline.com/docs/play-runs.md).

The execution model supports ordinary business logic while requiring supported
boundaries for durable work. Explicit freshness settings control reuse for new
operations. Recovery of completed work within an interrupted execution is a
separate concern.

Inline `deepline.runPlay` composition uses compatible scalar children within one
parent run. A child with datasets, CSV, event waits or an explicit timeout
cannot use that path. Supported sequential sleeps remain possible outside
dataset callbacks.

`deepline.runPlayAsync` launches a separately published scalar child and returns
its run ID without waiting for its result. That target can suspend for events
or human responses, but cannot own a dataset, CSV or runtime sheet. Its admitted
run continues independently after parent completion or cancellation.

## Outside a Play: own the request and its observation

An application connects with org authorization and starts a saved custom
or prebuilt Play by name. Starting returns a job handle with a public run ID.
The application can wait for the result or return immediately and observe the
same run later.

The handle supports result retrieval, progress observation and explicit stop
operations. A lower-level `DeeplineClient` supports reads by saved run ID.
The client also exposes supported tool, Database, Monitor, org and usage
operations. Exact methods and types belong in the [SDK client reference](https://deepline.com/docs/sdk-v2/client-reference.md).

The remote run can outlive an HTTP request, worker or script. Saving launch
intent and the returned run ID lets another worker reconcile the same request.
A local timeout ends the caller's wait, not the remote execution.

Applications also choose who validates and writes accepted results. They can
poll for completion, receive an authenticated callback from a custom Play, or
let the Play own a destination write. The
[application integration guide](https://deepline.com/docs/sdk-v2/production-integration.md) explains those choices.

## Named and prebuilt Plays share an invocation model

A custom published Play contains your versioned workflow. A prebuilt Play
provides maintained logic with a defined contract. Both receive the input their
contract supports and produce a [Play run](https://deepline.com/docs/play-runs.md).

File-based development submits a snapshot of local TypeScript source for remote
execution. `deepline plays run -e` also accepts a short function body for an
inline run from the current project folder. Named invocation resolves the
selected saved revision. Publishing a new version changes what future callers can select while existing runs retain
their admitted snapshot.

Tools are smaller building blocks. A direct tool request performs one supported
operation without requiring a custom Play. A Play becomes useful when you need
selection rules, several operations, row processing or a reusable result.
Direct tool requests have their own
[recovery contract](https://deepline.com/docs/sdk-v2/tool-execution-recovery.md).

## Triggers extend the caller boundary

A published Play can declare webhooks, cron schedules and supported SQL
listeners. Deepline then starts runs from events or time rather than an
application's direct invocation. [Play triggers](https://deepline.com/docs/play-triggers.md) explains their
inputs and lifecycle.

A [Monitor](https://deepline.com/docs/plays/monitors.md) supplies a provider event feed. Its retained rows
can start a listener-driven Play. SDK client authorization and Monitor feed
activation remain separate operations.

## Other ways to call Deepline

The CLI uses the SDK and exposes agent-callable commands for discovery,
execution and observation. The web app uses the same org-owned Plays
and runs. Work started through one interface can be inspected through another.

Python and other HTTP-capable systems can call the Runtime API. They invoke
saved Plays and retain run IDs, while custom Play source remains TypeScript.
Credentials belong in the trusted caller environment rather than browser code
or Play inputs.

## Choose the practical guide

| Your task | Guide |
| - | - |
| Install the CLI or connect an agent | [Installation](https://deepline.com/docs/use-with-an-agent.md) |
| Run one maintained workflow | [Quickstart](https://deepline.com/docs/sdk-v2/quickstart.md) |
| Define custom business logic | [Build a Play](https://deepline.com/docs/sdk-v2/plays.md) |
| Choose a maintained contract | [Choose a prebuilt Play](https://deepline.com/docs/sdk-v2/prebuilt-plays.md) |
| Prepare file input | [Use a CSV as input](https://deepline.com/docs/sdk-v2/batch-csv.md) |
| Call from an application | [Integrate a Play into your app](https://deepline.com/docs/sdk-v2/production-integration.md) |
| Call from another language | [Call Plays from Python or HTTP](https://deepline.com/docs/sdk-v2/http-and-python.md) |

Use the [SDK reference](https://deepline.com/docs/sdk-v2/sdk-reference.md) for runtime methods and
[API reference](https://deepline.com/docs/api-reference.md) for HTTP contracts.


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