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

# Plays

> Versioned workflows that combine data, tools and business rules into repeatable work.

A **Play** is a versioned workflow that Deepline executes. It takes input,
performs work, and returns a result. A Play can research accounts, find contact
details, evaluate a lead, or update a connected system.

Plays combine tools with your rules for using their results. For example, a
lead-routing Play can enrich a company, check an account list, select an owner,
and prepare a CRM update. The Play defines which evidence is sufficient and
what should happen when a source fails or returns no match.

## Maintained and custom Plays

**Prebuilt Plays** supply maintained workflows with defined inputs and outputs.
They can combine several providers, apply acceptance rules, and return a common
result. A waterfall that tries another source after a miss is one example.
The Play's contract identifies its supported inputs, output fields and usage
model.

**Custom Plays** express your own workflow as a default-exported TypeScript
function. The function receives the input and uses the imported `deepline`
runtime. An optional exported `config` declares triggers and other settings.
The filename supplies the Play name unless `config.name` overrides it.
They can use prebuilt Plays, individual tools, customer data and external HTTP
requests. This lets you reuse maintained enrichment while controlling your
selection, review and destination rules.

A single-record Play and a batch Play can accept different inputs. A Play that
accepts a person profile does not automatically accept a CSV. The
[prebuilt Play guide](https://deepline.com/docs/sdk-v2/prebuilt-plays.md) explains how to inspect those contracts
and links each prebuilt Play’s public page.

## A definition, a version, and a run answer different questions

The definition contains the workflow's code and input contract. A published
version makes a specific revision available to named callers and automated
triggers. A [Play run](https://deepline.com/docs/play-runs.md) applies an immutable code snapshot to one input.

You can check and run a local file while developing a custom Play. That file
run executes the submitted snapshot. Publishing makes a selected revision
live and activates its declared triggers. Editing a draft does not change the
published version or a run already in progress.

Suppose a routing rule changes from country ownership to named-account
ownership. Runs from the two versions can assign different owners. Their
version identities explain which rule each run used. External data can also
change between runs, so version identity and source observation times answer
different questions.

## The execution graph makes work observable

Deepline presents a Play as a graph of its work. The graph connects input,
steps, decisions, datasets and results. During a run, those boundaries help
show what started, what finished and where an error occurred.

| Building block | Purpose |
| - | - |
| Tool call | Read provider data or perform a supported operation. |
| Step | Record a named scalar action or checkpoint. |
| Dataset | Process rows, add columns and retain row results. |
| Child Play | Reuse another Play's logic or launch separate work. |
| Recorded HTTP request | Call an external endpoint with a visible execution history. |
| Wait | Continue after a supported delay, event or human response. |

Datasets organize work such as one enrichment per lead. Stable row keys connect
inputs, computed columns and errors. A batch can therefore retain successful
rows while identifying rows that failed under its configured failure policy.
A compact run summary points to those rows rather than embedding the entire
file.

A Play can return a scalar object, dataset references, or a combination of both.
The run graph and retained datasets support inspection. A chart or report can
then present the accepted data in a form suited to the business question.

## Reuse a Play or launch an independent run

`deepline.runPlay` composes a compatible scalar child inside the parent's run.
The child's work appears within the parent graph and shares its run identity.
It does not create another independently managed run.

Inline children cannot own datasets, CSV processing, event waits or explicit
timeouts. Sequential scalar composition can include supported sleeps outside
dataset callbacks. The [SDK reference](https://deepline.com/docs/sdk-v2/sdk-reference.md) defines the placement rules.

`deepline.runPlayAsync` launches an independently published scalar child and returns
its run ID. That child can wait for an event or human response. It has its own
status, result and cancellation boundary. Its target cannot own a dataset,
CSV or runtime sheet. An admitted child continues independently if its parent
finishes or is cancelled.

This distinction supports two different designs: reuse a calculation inside
one run, or give a record its own execution lifecycle. An
[Engine](https://deepline.com/docs/plays/engines.md) adds persistent business states when the process spans
several runs.

## Durable execution and retries are different from exactly-once effects

Deepline records completed work so an interrupted execution can recover it.
For new work, explicit freshness settings determine whether eligible completed
results can be reused. A fresh lookup and recovery of an interrupted operation
serve different purposes.

Independent runs can still execute the same provider operation. A stable step
label alone does not prevent duplicate external effects or guarantee a free
rerun. Destination writes need a supported idempotency key or reconciliation
with the destination's actual state.

For example, a timed-out CRM update may already have succeeded. A useful Play
can retain the request identity, inspect the CRM record, and decide whether
another write is needed.

## A trigger supplies the occasion, not another implementation

Manual calls, webhooks, cron schedules and supported SQL listeners can start
a Play. [Play triggers](https://deepline.com/docs/play-triggers.md) determine when the workflow receives
input. The Play determines what to do with it.

A [Monitor](https://deepline.com/docs/plays/monitors.md) supplies an upstream event feed. A SQL listener can
react to its accepted Database rows. Several consumers can use the same feed
while applying different business rules.

## Execution success is only one layer of success

A completed run means the handler finished. Its result can still contain a
legitimate no-match outcome or rows that need review. The Play defines whether
an email, company match or proposed update meets your acceptance rule.

Keeping evidence, decisions and destination outcomes separate makes those
results useful. Accepted research can remain valid even when a later
notification fails. Run status, business state and external write status each
explain a different part of the work.

## Continue learning

* [Build a Play](https://deepline.com/docs/sdk-v2/plays.md): author, check and publish custom logic.
* [Run Plays and view results](https://deepline.com/docs/sdk-v2/calling-plays.md): execute and inspect a selected Play.
* [Play runs](https://deepline.com/docs/play-runs.md): understand results, logs, recovery and cancellation.
* [Play triggers](https://deepline.com/docs/play-triggers.md): understand automated entry points.
* [SDK](https://deepline.com/docs/sdk-v2/overview.md): use TypeScript inside and outside a Play.


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