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

# Schedule or trigger a Play | Agent guide

> Start Plays from authenticated inbound events or cron schedules, with explicit delivery and activation semantics.

[Human guide: task steps and agent prompt →](https://deepline.com/docs/human/sdk-v2/webhooks-and-schedules.md)

Use a **webhook** when another system starts the work. Use a **schedule** when
time starts it. Declare either binding in the Play source. Publishing activates
it; checking or manually running the local file does not.

## Before you start

Have a [custom Play](https://deepline.com/docs/sdk-v2/plays.md) with reviewed input and acceptance rules.
Choose the intended org, maximum work per invocation, and failure owner.
Confirm credentials and any downstream write permissions before activation.

For a webhook, identify the sender's signature format and stable delivery ID.
For a schedule, choose its timezone, intended times, and input. SQL listeners
for retained provider feeds are covered by [Set up a Monitor](https://deepline.com/docs/plays/set-up-a-monitor.md).

## Inbound webhook contract

The JSON request body becomes the Play input. Keep the input small and explicit:

```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
{
  "email": "jane@example.com",
  "company_domain": "example.com",
  "source": "hubspot"
}
```

Save this as `inbound-lead.play.ts`. It verifies a Standard Webhooks v1
signature before the Play function runs:

```ts theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
import deepline from 'deepline';

export const config = {
  webhook: {
    auth: {
      type: 'standard-webhooks',
      headerFamily: 'standard',
      signingSecrets: ['INBOUND_RELAY_WEBHOOK_SECRET'],
      toleranceSeconds: 300,
    },
  },
};

export default async function (lead: {
  email: string;
  company_domain?: string;
  source?: string;
}) {
  return {
    email: lead.email,
    company_domain: lead.company_domain ?? null,
    source: lead.source ?? 'webhook',
  };
}
```

Set the signing secret through the hidden CLI prompt. Keep its value out of
commands, source files, and agent prompts:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline secrets set INBOUND_RELAY_WEBHOOK_SECRET
```

HubSpot v3 signatures are not Standard Webhooks signatures. Put an authenticated
relay in front of a HubSpot-bound Play: verify the HubSpot signature there, then
sign the forwarded body with `webhook-id`, `webhook-timestamp`, and
`webhook-signature` under Standard Webhooks v1.

Use `headerFamily: 'svix'` for senders with `svix-*` headers. This example uses
`webhook-*` headers. Configure the matching secret on the sender or relay.

Use `webhook: {}` only in an isolated test environment. Require signature
verification before production whenever the sender supports it.

## Webhook delivery identity

Deepline deduplicates a retry only when the sender supplies a stable delivery
identity. Header precedence is:

1. `x-deepline-dedupe-key`
2. `idempotency-key`
3. `x-github-delivery`
4. `x-shopify-webhook-id`
5. `webhook-id`
6. `svix-id`

Reuse the same nonblank value only for a retry of the same delivery. Give each
new delivery a different value.

Without one, every POST begins a new run. Deepline does not infer identity from
identical JSON or a generic top-level `id`.

## Cron schedule

Save this as `daily-account-review.play.ts`. Use a five-field cron expression
and an IANA timezone. This minimal handler requires no input:

```ts theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
import deepline from 'deepline';

export const config = {
  cron: { schedule: '0 9 * * *', timezone: 'America/New_York' },
};

export default async function () {
  return { scheduled_at: new Date().toISOString() };
}
```

This example returns a timestamp; add your account selection and review logic
to the function. Use a [dataset](https://deepline.com/docs/sdk-v2/plays.md) when that logic processes rows.

A schedule receives `{}` unless `cron.input` supplies a static JSON object.
Set that object when the handler requires input. A previous manual run's input
does not become the schedule's input.

## Activate and test deliberately

First check and manually run the local file. These commands use the schedule
example, which requires no input:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline plays check ./daily-account-review.play.ts
deepline plays run ./daily-account-review.play.ts --input '{}'
```

For the webhook example, use `inbound-lead.play.ts` and the sample JSON body
shown above. Inspect the result and any downstream effects before publication.
A file run tests the handler; it does not test sender authentication or delivery.
Provider-backed handlers can spend Deepline credits.

After the sample passes review, publish the selected file. Inspect its live
binding:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline plays publish ./daily-account-review.play.ts
deepline plays trigger get --play daily-account-review
```

For the webhook example, publish `inbound-lead.play.ts` and inspect `inbound-lead`.
Copy the issued webhook URL from that trigger response into the sender or relay.

Verify the active binding:

* For a schedule, confirm the timezone, input, and next intended occurrence.
  Observe an actual scheduled run.
* For a webhook, send one authenticated test from the configured sender.
  Confirm the handler receives the expected input.
* Retry that delivery with its original ID. Confirm it reuses the same run.
  Use a different ID for a new event.
* Check failure visibility with `deepline notifications list` and
  `deepline notifications events`. Configure and test the owner's chosen
  destination before relying on unattended work. `deepline notifications --help`
  describes those steps.

Use `deepline plays trigger --help` to change or remove a published binding.
For Git-deployed Plays, change the source repository. Removing a webhook
retires its URL; re-enabling it issues a new URL.

## Verify this task

Inspect the live binding and an observed event or scheduled occurrence.
Handler tests, signature checks, and repeated-delivery checks establish different facts.


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