# Contact Delete

> Remove the contact that triggered the automation from its audience.

The **contact delete** step removes the contact that triggered the automation from its [audience](https://www.sendping.co/docs/audiences/overview). Once deleted, the contact no longer receives emails from that audience and any remaining steps in the run are skipped. See [Using automations](https://www.sendping.co/docs/automations/overview) for the surrounding workflow.

Common use cases:

- **Compliance** — delete contacts as part of a data-removal workflow.
- **Churn** — remove a contact when a user stops using your service.
- **Unsubscribe flows** — automatically remove contacts who opt out.

## How it works

In the dashboard, add the **Delete contact** step — no configuration is required; it is ready as soon as you add it. Over the API, add a `contact_delete` step with an empty `config` object.

**Node.js**

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

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.automations.create({
  "name": "Remove churned users",
  "domain": "yourdomain.com",
  "steps": [
    {
      "key": "start",
      "type": "trigger",
      "config": { "event_name": "user.deleted" }
    },
    {
      "key": "remove",
      "type": "contact_delete",
      "config": {}
    }
  ],
  "connections": [
    { "from": "start", "to": "remove", "type": "default" }
  ]
});
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Automations.create({
  "name": "Remove churned users",
  "domain": "yourdomain.com",
  "steps": [
    {
      "key": "start",
      "type": "trigger",
      "config": {
        "event_name": "user.deleted"
      }
    },
    {
      "key": "remove",
      "type": "contact_delete",
      "config": {}
    }
  ],
  "connections": [
    {
      "from": "start",
      "to": "remove",
      "type": "default"
    }
  ]
})
```

**PHP**

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

use SendPing\SendPing;

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

$sendping->automations->create([
  'name' => "Remove churned users",
  'domain' => "yourdomain.com",
  'steps' => [
    [
      'key' => "start",
      'type' => "trigger",
      'config' => [
        'event_name' => "user.deleted"
      ]
    ],
    [
      'key' => "remove",
      'type' => "contact_delete",
      'config' => []
    ]
  ],
  'connections' => [
    [
      'from' => "start",
      'to' => "remove",
      'type' => "default"
    ]
  ]
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Automations.create({
  "name": "Remove churned users",
  "domain": "yourdomain.com",
  "steps": [
    {
      "key": "start",
      "type": "trigger",
      "config": {
        "event_name": "user.deleted"
      }
    },
    {
      "key": "remove",
      "type": "contact_delete",
      "config": {}
    }
  ],
  "connections": [
    {
      "from": "start",
      "to": "remove",
      "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:   "Remove churned users",
    Domain: "yourdomain.com",
    Steps: []sendping.AutomationStepInput{
        {
            Key:    "start",
            Type:   "trigger",
            Config: map[string]any{"event_name": "user.deleted"},
        },
        {Key: "remove", Type: "contact_delete", Config: map[string]any{}},
    },
    Connections: []sendping.AutomationConnectionInput{
        {From: "start", To: "remove", Type: "default"},
    },
})
```

**Rust**

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

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

let params = CreateAutomationOptions::new("Remove churned users", "yourdomain.com")
    .with_step(AutomationStepInput::new("trigger")
        .with_key("start")
        .with_config(serde_json::json!({"event_name":"user.deleted"})))
    .with_step(AutomationStepInput::new("contact_delete")
        .with_key("remove")
        .with_config(serde_json::json!({})))
    .with_connection(ConnectionInput::new("start", "remove").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;
import java.util.Map;

SendPing sendping = new SendPing("mb_xxxxxxxxx");

CreateAutomationRequest request = CreateAutomationRequest.builder()
        .name("Remove churned users")
        .domain("yourdomain.com")
        .step(AutomationStep.builder()
                .key("start")
                .type("trigger")
                .config("event_name", "user.deleted")
                .build())
        .step(AutomationStep.builder()
                .key("remove")
                .type("contact_delete")
                .config(Map.of())
                .build())
        .connection(AutomationConnection.of("start", "remove", "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 = "Remove churned users",
    Domain = "yourdomain.com",
    Steps = new List<AutomationStepInput>
    {
        new()
        {
            Key = "start",
            Type = "trigger",
            Config = new Dictionary<string, object?>
            {
                ["event_name"] = "user.deleted",
            },
        },
        new()
        {
            Key = "remove",
            Type = "contact_delete",
            Config = new Dictionary<string, object?>(),
        },
    },
    Connections = new List<AutomationConnection>
    {
        new()
        {
            From = "start",
            To = "remove",
            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": "Remove churned users",
  "domain": "yourdomain.com",
  "steps": [
    {
      "key": "start",
      "type": "trigger",
      "config": { "event_name": "user.deleted" }
    },
    {
      "key": "remove",
      "type": "contact_delete",
      "config": {}
    }
  ],
  "connections": [
    { "from": "start", "to": "remove", "type": "default" }
  ]
}'
```

> **Warning:** Deleting a contact is **permanent**. The contact and all of its properties are removed from the audience. If the contact needs to be re-added later, it must be created again.

## Configuration

The `config` object is empty — no additional fields are required.

```json
{
  "key": "remove_contact",
  "type": "contact_delete",
  "config": {}
}
```
