Skip to main content
Resend Docs

Search documentation

Type to search this documentation.

On this pageOverview

Contact Delete

This step removes the contact that triggered the Automation from its Audience. Once deleted, the contact will no longer receive emails from that audience and any remaining steps in the Automation run are skipped.

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.

Include the Delete contact step to your Automation.

Automation Contact Delete

No configuration required. It is ready as soon as you add it.

Add a contact_delete step to your Automation's steps array.

Node.js
import { Resend } from 'resend';const resend = new Resend('re_xxxxxxxxx');const { data, error } = await resend.automations.create({  name: 'Remove churned users',  steps: [    {      key: 'start',      type: 'trigger',      config: { eventName: 'user.deleted' },    },    {      key: 'remove',      type: 'contact_delete',      config: {},    },  ],  connections: [{ from: 'start', to: 'remove', type: 'default' }],});
PHP
$resend = Resend::client('re_xxxxxxxxx');$resend->automations->create([  'name' => 'Remove churned users',  'steps' => [    [      'key' => 'start',      'type' => 'trigger',      'config' => ['event_name' => 'user.deleted'],    ],    [      'key' => 'remove',      'type' => 'contact_delete',      'config' => [],    ],  ],  'connections' => [['from' => 'start', 'to' => 'remove', 'type' => 'default']],]);
Python
import resendresend.api_key = "re_xxxxxxxxx"params: resend.Automations.CreateParams = {  "name": "Remove churned users",  "steps": [    {      "key": "start",      "type": "trigger",      "config": {"event_name": "user.deleted"},    },    {      "key": "remove",      "type": "contact_delete",      "config": {},    },  ],  "connections": [{"from": "start", "to": "remove", "type": "default"}],}resend.Automations.create(params)
Ruby
require "resend"Resend.api_key = "re_xxxxxxxxx"params = {  name: "Remove churned users",  steps: [    {      key: "start",      type: "trigger",      config: { event_name: "user.deleted" },    },    {      key: "remove",      type: "contact_delete",      config: {},    },  ],  connections: [{ from: "start", to: "remove", type: "default" }],}Resend::Automations.create(params)
Go
package mainimport "github.com/resend/resend-go/v4"func main() {	client := resend.NewClient("re_xxxxxxxxx")	params := &resend.CreateAutomationRequest{		Name: "Remove churned users",		Steps: []resend.AutomationStep{			{				Key:  "start",				Type: resend.AutomationStepTypeTrigger,				Config: map[string]any{					"event_name": "user.deleted",				},			},			{				Key:    "remove",				Type:   resend.AutomationStepTypeContactDelete,				Config: map[string]any{},			},		},		Connections: []resend.AutomationConnection{			{From: "start", To: "remove", Type: resend.AutomationConnectionTypeDefault},		},	}	client.Automations.Create(params)}
Rust
use resend_rs::{  json,  types::{    AutomationStatus, Connection, ConnectionType, CreateAutomationOptions, Step, TriggerStepConfig,  },  Resend, Result,};#[tokio::main]async fn main() -> Result<()> {  let resend = Resend::new("re_xxxxxxxxx");  let opts = CreateAutomationOptions {    name: "Remove churned users".to_owned(),    steps: vec![      Step::Trigger {        key: "start".to_owned(),        config: TriggerStepConfig {          event_name: "user.deleted".to_owned(),        },      },      Step::ContactDelete {        key: "remove".to_owned(),        config: json!("{}"),      },    ],    connections: vec![Connection::new("start", "remove").with_type(ConnectionType::Default)],    status: AutomationStatus::Disabled,  };  let _automation = resend.automations.create(opts).await?;  Ok(())}
Java
import com.resend.*;import com.resend.core.exception.ResendException;import com.resend.services.automations.model.AutomationConnection;import com.resend.services.automations.model.AutomationStep;import com.resend.services.automations.model.ConnectionType;import com.resend.services.automations.model.CreateAutomationOptions;import com.resend.services.automations.model.CreateAutomationResponseSuccess;public class Main {    public static void main(String[] args) throws ResendException {        Resend resend = new Resend("re_xxxxxxxxx");        CreateAutomationOptions options = CreateAutomationOptions.builder()                .name("Remove churned users")                .steps(                    AutomationStep.trigger("start")                        .eventName("user.deleted")                        .build(),                    AutomationStep.contactDelete("remove")                        .build()                )                .connections(                    AutomationConnection.builder()                        .from("start")                        .to("remove")                        .type(ConnectionType.DEFAULT)                        .build()                )                .build();        CreateAutomationResponseSuccess data = resend.automations().create(options);    }}
.NET
using Resend;using System.Text.Json;IResend resend = ResendClient.Create( "re_xxxxxxxxx" );var startConfig = JsonSerializer.SerializeToElement( new { event_name = "user.deleted" } );var removeConfig = JsonSerializer.SerializeToElement( new { } );var resp = await resend.AutomationCreateAsync( new AutomationCreateData(){    Name = "Remove churned users",    Steps = new List<AutomationStepData>    {        new AutomationStepData { Ref = "start", Type = "trigger", Config = startConfig },        new AutomationStepData { Ref = "remove", Type = "contact_delete", Config = removeConfig },    },    Connections = new List<AutomationEdge>    {        new AutomationEdge { From = "start", To = "remove", EdgeType = "default" },    },} );
cURL
curl -X POST 'https://api.resend.com/automations' \     -H 'Authorization: Bearer re_xxxxxxxxx' \     -H 'Content-Type: application/json' \     -d '{  "name": "Remove churned users",  "steps": [{    "key": "start",    "type": "trigger",    "config": { "event_name": "user.deleted" }  }, {    "key": "remove",    "type": "contact_delete",    "config": {}  }],  "connections": [    { "from": "start", "to": "remove", "type": "default" }  ]}'
CLI
resend automations create --name "Remove churned users" --file ./automation.json

The config object is empty, so no additional fields are required.

Example
{
  "key": "remove_contact",
  "type": "contact_delete",
  "config": {}
}
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu