# SDK Reference: Cron Trigger
Source: https://docs.chain.link/cre/reference/sdk/triggers/cron-trigger-ts
Last Updated: 2026-01-20

> For the complete documentation index, see [llms.txt](/llms.txt).

The Cron Trigger fires at a specified schedule using standard cron expressions. It is ideal for workflows that need to run at regular intervals.

## Creating the trigger

```typescript
import { CronCapability } from "@chainlink/cre-sdk"

const cron = new CronCapability()
const trigger = cron.trigger({ schedule: "0 */10 * * * *" }) // Every 10 minutes
```

## Configuration

The `trigger()` method accepts a configuration object with the following field:

| Field      | Type   | Description                                                                                                                                   |
| ---------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `schedule` | string | A standard cron expression with 5 or 6 fields, where the optional 6th field represents seconds. **Note:** The minimum interval is 30 seconds. |

**Examples:**

```typescript
// Every 30 seconds (minimum interval)
cron.trigger({ schedule: "*/30 * * * * *" })

// Every 10 minutes
cron.trigger({ schedule: "0 */10 * * * *" })

// Every day at midnight
cron.trigger({ schedule: "0 0 * * *" })

// Every Monday at 9 AM
cron.trigger({ schedule: "0 9 * * 1" })
```

## Payload

The payload passed to your callback function contains the scheduled execution time.

| Field                    | Type        | Description                               |
| ------------------------ | ----------- | ----------------------------------------- |
| `scheduledExecutionTime` | `Timestamp` | The time the execution was scheduled for. |

The `Timestamp` has the following structure:

```typescript
{
  seconds: bigint // Seconds since Unix epoch
  nanos: number // Nanoseconds component
}
```

## Callback Function

Your callback function for cron triggers must conform to this signature:

```typescript
import { type Runtime, type CronPayload } from "@chainlink/cre-sdk"

const onCronTrigger = (runtime: Runtime<Config>, payload: CronPayload): YourReturnType => {
  // Your workflow logic here
  return result
}
```

**Parameters:**

- `runtime`: The runtime object used to invoke capabilities and access configuration
- `payload`: The cron payload containing the scheduled execution time

**Example:**

```typescript
import { type Runtime, type CronPayload } from "@chainlink/cre-sdk"

type Config = {
  schedule: string
  message: string
}

const onCronTrigger = (runtime: Runtime<Config>, payload: CronPayload): string => {
  if (!payload.scheduledExecutionTime) {
    throw new Error("Scheduled execution time is required")
  }

  const executionTime = new Date(Number(payload.scheduledExecutionTime.seconds) * 1000)
  runtime.log(`Workflow triggered at: ${executionTime.toISOString()}`)

  return runtime.config.message
}
```

## Complete Example

```typescript
import { CronCapability, handler, Runner, type Runtime, type CronPayload } from "@chainlink/cre-sdk"

type Config = {
  schedule: string
}

const onCronTrigger = (runtime: Runtime<Config>, payload: CronPayload): string => {
  runtime.log("Cron workflow triggered!")
  return "Success"
}

const initWorkflow = (config: Config) => {
  const cron = new CronCapability()

  return [handler(cron.trigger({ schedule: config.schedule }), onCronTrigger)]
}

export async function main() {
  const runner = await Runner.newRunner<Config>()
  await runner.run(initWorkflow)
}
```