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
Optional - Omit for global contacts. Include to retrieve an audience-specific contact.
The contact ID or email address to retrieve
Response
The unique identifier for the contact
The contact’s email address
Timestamp when the contact was created
Whether the contact has unsubscribed from emails
Custom properties for global contacts. Currently, the API only returns string values.
Examples
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)
}
options := &resend.GetContactOptions{
Id: "user@example.com",
}
contact, err := client.Contacts.Get(options)
if err != nil {
panic(err)
}
fmt.Println("Contact ID:", contact.Id)
fmt.Println("Created:", contact.CreatedAt)
options := &resend.GetContactOptions{
AudienceId: "aud_123456",
Id: "user@example.com",
}
contact, err := client.Contacts.Get(options)
With Context and Properties
ctx := context.Background()
options := &resend.GetContactOptions{
Id: "user@example.com",
}
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