Skip to main content

Methods

Remove

func (s *ContactsSvcImpl) Remove(options *RemoveContactOptions) (RemoveContactResponse, error)
Removes a contact.

RemoveWithContext

func (s *ContactsSvcImpl) RemoveWithContext(ctx context.Context, options *RemoveContactOptions) (RemoveContactResponse, error)
Removes a contact with context support.

Parameters

RemoveContactOptions

audience_id
string
Optional - Omit for global contacts. Include to remove an audience-specific contact.
id
string
required
The contact ID or email address to remove

Response

RemoveContactResponse

id
string
The ID of the deleted contact
object
string
Object type (“contact”)
deleted
bool
Whether the contact was successfully deleted

Examples

Remove Global Contact by ID

package main

import (
    "fmt"
    "github.com/resend/resend-go/v2"
)

func main() {
    client := resend.NewClient("re_123456789")

    options := &resend.RemoveContactOptions{
        Id: "c1a2b3c4-d5e6-7f8g-9h0i-1j2k3l4m5n6o",
    }

    response, err := client.Contacts.Remove(options)
    if err != nil {
        panic(err)
    }

    if response.Deleted {
        fmt.Println("Contact deleted:", response.Id)
    }
}

Remove Global Contact by Email

options := &resend.RemoveContactOptions{
    Id: "[email protected]",
}

response, err := client.Contacts.Remove(options)
if err != nil {
    panic(err)
}

fmt.Println("Deleted:", response.Deleted)

Remove Audience Contact

options := &resend.RemoveContactOptions{
    AudienceId: "aud_123456",
    Id:         "[email protected]",
}

response, err := client.Contacts.Remove(options)
if err != nil {
    panic(err)
}

With Context

ctx := context.Background()

options := &resend.RemoveContactOptions{
    Id: "c1a2b3c4-d5e6-7f8g-9h0i-1j2k3l4m5n6o",
}

response, err := client.Contacts.RemoveWithContext(ctx, options)
if err != nil {
    panic(err)
}

if response.Deleted {
    fmt.Println("Successfully removed contact")
}

Notes

  • The Id field accepts either a contact ID or email address
  • Omit AudienceId to remove global contacts
  • Include AudienceId to remove audience-specific contacts
  • This action cannot be undone

Build docs developers (and LLMs) love