Skip to main content

Methods

Create

func (s *DomainsSvcImpl) Create(params *CreateDomainRequest) (CreateDomainResponse, error)
Creates a new domain entry.

CreateWithContext

func (s *DomainsSvcImpl) CreateWithContext(ctx context.Context, params *CreateDomainRequest) (CreateDomainResponse, error)
Creates a new domain entry with context support.

Request Parameters

CreateDomainRequest

name
string
required
The domain name to add (e.g., “example.com”)
region
string
The region where emails will be sent from. Options: us-east-1, eu-west-1, sa-east-1
custom_return_path
string
Custom return path for the domain

Response

CreateDomainResponse

id
string
The unique identifier for the domain
name
string
The domain name
created_at
string
Timestamp when the domain was created
status
string
The verification status of the domain
records
[]Record
DNS records required for domain verification. See Record structure below.
region
string
The region where emails will be sent from
dns_provider
string
The DNS provider for the domain

Record

record
string
The record identifier
name
string
The DNS record name
type
string
The DNS record type (e.g., “TXT”, “MX”, “CNAME”)
ttl
string
Time to live for the DNS record
status
string
Verification status of this specific record
value
string
The value to set for the DNS record
priority
json.Number
Priority value for MX records (optional)

Example

package main

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

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

    params := &resend.CreateDomainRequest{
        Name:   "example.com",
        Region: "us-east-1",
    }

    domain, err := client.Domains.Create(params)
    if err != nil {
        panic(err)
    }

    fmt.Println("Domain ID:", domain.Id)
    fmt.Println("Status:", domain.Status)
    
    for _, record := range domain.Records {
        fmt.Printf("Add %s record: %s = %s\n", record.Type, record.Name, record.Value)
    }
}

Example with Context

ctx := context.Background()

params := &resend.CreateDomainRequest{
    Name:             "example.com",
    Region:           "us-east-1",
    CustomReturnPath: "bounces.example.com",
}

domain, err := client.Domains.CreateWithContext(ctx, params)

Build docs developers (and LLMs) love