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
The domain name to add (e.g., “example.com”)
The region where emails will be sent from. Options: us-east-1, eu-west-1, sa-east-1
Custom return path for the domain
Response
CreateDomainResponse
The unique identifier for the domain
Timestamp when the domain was created
The verification status of the domain
DNS records required for domain verification. See Record structure below.
The region where emails will be sent from
The DNS provider for the domain
Record
The DNS record type (e.g., “TXT”, “MX”, “CNAME”)
Time to live for the DNS record
Verification status of this specific record
The value to set for the DNS record
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)