Skip to main content

Methods

Get

func (s *ContactsSvcImpl) Get(options *GetContactOptions) (Contact, error)
Retrieves a contact by ID or email address.

GetWithContext

func (s *ContactsSvcImpl) GetWithContext(ctx context.Context, options *GetContactOptions) (Contact, error)
Retrieves a contact by ID or email address with context support.

Parameters

GetContactOptions

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

Response

Contact

id
string
The unique identifier for the contact
email
string
The contact’s email address
object
string
Object type (“contact”)
first_name
string
The contact’s first name
last_name
string
The contact’s last name
created_at
string
Timestamp when the contact was created
unsubscribed
bool
Whether the contact has unsubscribed from emails
properties
map[string]any
Custom properties for global contacts. Currently, the API only returns string values.

Examples

Get Global Contact by ID

package main

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

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

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

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

    fmt.Println("Email:", contact.Email)
    fmt.Println("Name:", contact.FirstName, contact.LastName)
    fmt.Println("Unsubscribed:", contact.Unsubscribed)
}

Get Global Contact by Email

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

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

fmt.Println("Contact ID:", contact.Id)
fmt.Println("Created:", contact.CreatedAt)

Get Audience Contact

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

contact, err := client.Contacts.Get(options)

With Context and Properties

ctx := context.Background()

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

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

if contact.Properties != nil {
    fmt.Println("Properties:", contact.Properties)
}

Notes

  • The Id field accepts either a contact ID or email address
  • Omit AudienceId to retrieve global contacts
  • Include AudienceId to retrieve audience-specific contacts

Build docs developers (and LLMs) love