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
Optional - Omit for global contacts. Include to remove an audience-specific contact.
The contact ID or email address to remove
Response
The ID of the deleted contact
Whether the contact was successfully deleted
Examples
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)
}
}
options := &resend.RemoveContactOptions{
Id: "[email protected]",
}
response, err := client.Contacts.Remove(options)
if err != nil {
panic(err)
}
fmt.Println("Deleted:", response.Deleted)
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