# Delay

> Pause an automation for a fixed duration before continuing to the next step.

A **delay** step pauses the automation for a specified duration before continuing to the next step. See [Using automations](https://www.sendping.co/docs/automations/overview) for how steps chain together.

Common use cases:

- **Email sequences** — space out emails in an onboarding series.
- **Cooldowns** — prevent sending too many emails in a short period.
- **Follow-ups** — give users time to take action before sending a reminder.

## How it works

In the dashboard you configure a delay duration in natural language. Over the API, the delay step accepts a single `duration` field with a human-readable time value.

**Node.js**

```js
import { SendPing } from 'sendping';

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.automations.create({
  "name": "Welcome series",
  "domain": "yourdomain.com",
  "steps": [
    {
      "key": "start",
      "type": "trigger",
      "config": { "event_name": "user.created" }
    },
    {
      "key": "wait_1_day",
      "type": "delay",
      "config": { "duration": "1 day" }
    }
  ],
  "connections": [
    { "from": "start", "to": "wait_1_day", "type": "default" }
  ]
});
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Automations.create({
  "name": "Welcome series",
  "domain": "yourdomain.com",
  "steps": [
    {
      "key": "start",
      "type": "trigger",
      "config": {
        "event_name": "user.created"
      }
    },
    {
      "key": "wait_1_day",
      "type": "delay",
      "config": {
        "duration": "1 day"
      }
    }
  ],
  "connections": [
    {
      "from": "start",
      "to": "wait_1_day",
      "type": "default"
    }
  ]
})
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

use SendPing\SendPing;

$sendping = SendPing::client('mb_xxxxxxxxx');

$sendping->automations->create([
  'name' => "Welcome series",
  'domain' => "yourdomain.com",
  'steps' => [
    [
      'key' => "start",
      'type' => "trigger",
      'config' => [
        'event_name' => "user.created"
      ]
    ],
    [
      'key' => "wait_1_day",
      'type' => "delay",
      'config' => [
        'duration' => "1 day"
      ]
    ]
  ],
  'connections' => [
    [
      'from' => "start",
      'to' => "wait_1_day",
      'type' => "default"
    ]
  ]
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Automations.create({
  "name": "Welcome series",
  "domain": "yourdomain.com",
  "steps": [
    {
      "key": "start",
      "type": "trigger",
      "config": {
        "event_name": "user.created"
      }
    },
    {
      "key": "wait_1_day",
      "type": "delay",
      "config": {
        "duration": "1 day"
      }
    }
  ],
  "connections": [
    {
      "from": "start",
      "to": "wait_1_day",
      "type": "default"
    }
  ]
})
```

**Go**

```go
import "github.com/shekhu10/sendping-sdks/sendping-go"

client := sendping.NewClient("mb_xxxxxxxxx")

automation, err := client.Automations.Create(&sendping.CreateAutomationRequest{
    Name:   "Welcome series",
    Domain: "yourdomain.com",
    Steps: []sendping.AutomationStepInput{
        {
            Key:    "start",
            Type:   "trigger",
            Config: map[string]any{"event_name": "user.created"},
        },
        {
            Key:    "wait_1_day",
            Type:   "delay",
            Config: map[string]any{"duration": "1 day"},
        },
    },
    Connections: []sendping.AutomationConnectionInput{
        {From: "start", To: "wait_1_day", Type: "default"},
    },
})
```

**Rust**

```rust
use sendping::{AutomationStepInput, ConnectionInput, CreateAutomationOptions, SendPing};

let mb = SendPing::new("mb_xxxxxxxxx");

let params = CreateAutomationOptions::new("Welcome series", "yourdomain.com")
    .with_step(AutomationStepInput::new("trigger")
        .with_key("start")
        .with_config(serde_json::json!({"event_name":"user.created"})))
    .with_step(AutomationStepInput::new("delay")
        .with_key("wait_1_day")
        .with_config(serde_json::json!({"duration":"1 day"})))
    .with_connection(ConnectionInput::new("start", "wait_1_day").with_type("default"));
let _automation = mb.automations.create(params).await?;
```

**Java**

```java
import co.sendping.SendPing;
import co.sendping.SendPingResponse;
import co.sendping.requests.AutomationConnection;
import co.sendping.requests.AutomationStep;
import co.sendping.requests.CreateAutomationRequest;

SendPing sendping = new SendPing("mb_xxxxxxxxx");

CreateAutomationRequest request = CreateAutomationRequest.builder()
        .name("Welcome series")
        .domain("yourdomain.com")
        .step(AutomationStep.builder()
                .key("start")
                .type("trigger")
                .config("event_name", "user.created")
                .build())
        .step(AutomationStep.builder()
                .key("wait_1_day")
                .type("delay")
                .config("duration", "1 day")
                .build())
        .connection(AutomationConnection.of("start", "wait_1_day", "default"))
        .build();

SendPingResponse response = sendping.automations().create(request);
```

**.NET**

```csharp
using SendPing;

ISendPing sendping = SendPingClient.Create("mb_xxxxxxxxx");

var resp = await sendping.AutomationCreateAsync(new AutomationCreateOptions
{
    Name = "Welcome series",
    Domain = "yourdomain.com",
    Steps = new List<AutomationStepInput>
    {
        new()
        {
            Key = "start",
            Type = "trigger",
            Config = new Dictionary<string, object?>
            {
                ["event_name"] = "user.created",
            },
        },
        new()
        {
            Key = "wait_1_day",
            Type = "delay",
            Config = new Dictionary<string, object?> { ["duration"] = "1 day" },
        },
    },
    Connections = new List<AutomationConnection>
    {
        new()
        {
            From = "start",
            To = "wait_1_day",
            Type = "default",
        },
    },
});
```

**cURL**

```bash
curl -X POST 'https://www.sendping.co/api/automations' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Welcome series",
  "domain": "yourdomain.com",
  "steps": [
    {
      "key": "start",
      "type": "trigger",
      "config": { "event_name": "user.created" }
    },
    {
      "key": "wait_1_day",
      "type": "delay",
      "config": { "duration": "1 day" }
    }
  ],
  "connections": [
    { "from": "start", "to": "wait_1_day", "type": "default" }
  ]
}'
```

Example durations: `"30 minutes"`, `"1 hour"`, `"12 hours"`, `"1 day"`, `"3 days"`, `"1 week"`.

> **Warning:** The maximum delay is **30 days**.

## Configuration

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `config.duration` | string | Yes | The delay duration in natural language (e.g. `"1 hour"`, `"3 days"`). Maximum: 30 days. |

```json
{
  "key": "wait_1_hour",
  "type": "delay",
  "config": {
    "duration": "1 hour"
  }
}
```
