# Add Automation Step

> POST /automations/:id/steps — append a step to a disabled automation.

`POST /automations/:id/steps`

Appends a step to an automation. The automation must be **disabled** — [stop](https://www.sendping.co/docs/api/automations-stop) or disable it first. Returns the created step.

Supported step types (see the [Steps](https://www.sendping.co/docs/automations/steps) page for full config shapes):

- **[send_email](https://www.sendping.co/docs/automations/send-email)** — send a published template; `config.template.id` is required, with optional `variables`, `from`, `subject`, and `reply_to`.
- **[delay](https://www.sendping.co/docs/automations/delay)** — pause for a natural-language `duration` (e.g. `"1 day"`). Maximum 30 days.
- **[wait_for_event](https://www.sendping.co/docs/automations/wait-for-event)** — pause until `event_name` is received, with an optional `timeout` and `filter_rule`.
- **[condition](https://www.sendping.co/docs/automations/condition)** — branch on a `rule` (or an `and`/`or` group of rules) evaluated against `event.*` / `contact.*` data.
- **[contact_update](https://www.sendping.co/docs/automations/contact-update)** — update the contact's `first_name`, `last_name`, `unsubscribed`, or `properties`.
- **[contact_delete](https://www.sendping.co/docs/automations/contact-delete)** — delete the contact; `config` is an empty object `{}`.
- **[add_to_segment](https://www.sendping.co/docs/automations/add-to-segment)** — add the contact to a segment; requires `config.segment_id`.

**Node.js**

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

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.automations.addStep('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd', { "type": "delay", "config": { "duration": "1 day" } });
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Automations.add_step("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", {
  "type": "delay",
  "config": {
    "duration": "1 day"
  }
})
```

**PHP**

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

use SendPing\SendPing;

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

$sendping->automations->addStep('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd', [
  'type' => "delay",
  'config' => [
    'duration' => "1 day"
  ]
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Automations.add_step("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", {
  "type": "delay",
  "config": {
    "duration": "1 day"
  }
})
```

**Go**

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

client := sendping.NewClient("mb_xxxxxxxxx")

step, err := client.Automations.AddStep("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", &sendping.AddAutomationStepRequest{
    Type:   "delay",
    Config: map[string]any{"duration": "1 day"},
})
```

**Rust**

```rust
use sendping::{AddAutomationStepOptions, SendPing};

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

let params = AddAutomationStepOptions::new("delay")
    .with_config(serde_json::json!({"duration":"1 day"}));
let _step = mb.automations.add_step("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", params).await?;
```

**Java**

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

SendPing sendping = new SendPing("mb_xxxxxxxxx");

SendPingResponse response = sendping.automations().addStep(
        "c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd",
        AutomationStep.builder().type("delay").config("duration", "1 day").build());
```

**.NET**

```csharp
using SendPing;

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

var resp = await sendping.AutomationAddStepAsync("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", new AutomationAddStepOptions
{
    Type = "delay",
    Config = new Dictionary<string, object?> { ["duration"] = "1 day" },
});
```

**cURL**

```bash
curl -X POST 'https://www.sendping.co/api/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/steps' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{ "type": "delay", "config": { "duration": "1 day" } }'
```

**CLI**

```bash
sendping automations add-step c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd \
  --type 'delay' \
  --config '{"duration":"1 day"}'
```

**Node.js**

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

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.automations.addStep('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd', {
  "type": "send_email",
  "key": "welcome",
  "config": { "template": { "id": "34a080c9-b17d-4187-ad80-5af20266e535" } }
});
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Automations.add_step("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", {
  "type": "send_email",
  "key": "welcome",
  "config": {
    "template": {
      "id": "34a080c9-b17d-4187-ad80-5af20266e535"
    }
  }
})
```

**PHP**

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

use SendPing\SendPing;

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

$sendping->automations->addStep('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd', [
  'type' => "send_email",
  'key' => "welcome",
  'config' => [
    'template' => [
      'id' => "34a080c9-b17d-4187-ad80-5af20266e535"
    ]
  ]
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Automations.add_step("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", {
  "type": "send_email",
  "key": "welcome",
  "config": {
    "template": {
      "id": "34a080c9-b17d-4187-ad80-5af20266e535"
    }
  }
})
```

**Go**

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

client := sendping.NewClient("mb_xxxxxxxxx")

step, err := client.Automations.AddStep("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", &sendping.AddAutomationStepRequest{
    Type: "send_email",
    Key:  "welcome",
    Config: map[string]any{
        "template": map[string]any{"id": "34a080c9-b17d-4187-ad80-5af20266e535"},
    },
})
```

**Rust**

```rust
use sendping::{AddAutomationStepOptions, SendPing};

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

let params = AddAutomationStepOptions::new("send_email")
    .with_key("welcome")
    .with_config(serde_json::json!({"template":{"id":"34a080c9-b17d-4187-ad80-5af20266e535"}}));
let _step = mb.automations.add_step("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", params).await?;
```

**Java**

```java
import co.sendping.SendPing;
import co.sendping.SendPingResponse;
import co.sendping.requests.AutomationStep;
import java.util.Map;

SendPing sendping = new SendPing("mb_xxxxxxxxx");

AutomationStep request = AutomationStep.builder()
        .type("send_email")
        .key("welcome")
        .config("template", Map.of("id", "34a080c9-b17d-4187-ad80-5af20266e535"))
        .build();

SendPingResponse response = sendping.automations().addStep(
        "c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd",
        request);
```

**.NET**

```csharp
using SendPing;

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

var resp = await sendping.AutomationAddStepAsync("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", new AutomationAddStepOptions
{
    Type = "send_email",
    Key = "welcome",
    Config = new Dictionary<string, object?>
    {
        ["template"] = new Dictionary<string, object?>
        {
            ["id"] = "34a080c9-b17d-4187-ad80-5af20266e535",
        },
    },
});
```

**cURL**

```bash
curl -X POST 'https://www.sendping.co/api/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/steps' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "type": "send_email",
  "key": "welcome",
  "config": { "template": { "id": "34a080c9-b17d-4187-ad80-5af20266e535" } }
}'
```

**CLI**

```bash
sendping automations add-step c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd \
  --type 'send_email' \
  --key 'welcome' \
  --config '{"template":{"id":"34a080c9-b17d-4187-ad80-5af20266e535"}}'
```

### Response

The step routes return the **stored** step row rather than the documented graph shape, so the response uses the internal step vocabulary: `send_email` is stored as `send` and `wait_for_event` as `wait`, and a `send_email` config is flattened to `{ from, subject, html, text, template_id, variables?, reply_to? }` (so `template.id` comes back as `template_id`). The documented `send_email` / `template` shape is what the automation-level [create](https://www.sendping.co/docs/api/automations-create), [retrieve](https://www.sendping.co/docs/api/automations-get) and [update](https://www.sendping.co/docs/api/automations-update) responses return.

```json
{
  "id": "9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d",
  "key": "welcome",
  "type": "send",
  "position": 0,
  "config": { "template_id": "34a080c9-b17d-4187-ad80-5af20266e535" }
}
```
