resend

package module
v2.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 11 Imported by: 45

README

Resend Go SDK

Build Release

Installation

To install the Go SDK, simply execute the following command on a terminal:

go get github.com/resend/resend-go/v2

Setup

First, you need to get an API key, which is available in the Resend Dashboard.

Example

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

func main() {
    apiKey := "re_123"

    client := resend.NewClient(apiKey)

    params := &resend.SendEmailRequest{
        To:      []string{"to@example", "you@example.com"},
        From:    "me@exemple.io",
        Text:    "hello world",
        Subject: "Hello from Golang",
        Cc:      []string{"cc@example.com"},
        Bcc:     []string{"cc@example.com"},
        ReplyTo: "replyto@example.com",
    }

    sent, err := client.Emails.Send(params)
    if err != nil {
        panic(err)
    }
    fmt.Println(sent.Id)
}

You can view all the examples in the examples folder

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToCreateBroadcastSendRequest   = errors.New("[ERROR]: Failed to create Broadcasts.Send request")
	ErrFailedToCreateBroadcastCreateRequest = errors.New("[ERROR]: Failed to create Broadcasts.Create request")
)

BroadcastsSvc errors

View Source
var (
	ErrFailedToCreateApiKeysCreateRequest = errors.New("[ERROR]: Failed to create ApiKeys.Create request")
	ErrFailedToCreateApiKeysListRequest   = errors.New("[ERROR]: Failed to create ApiKeys.List request")
	ErrFailedToCreateApiKeysRemoveRequest = errors.New("[ERROR]: Failed to create ApiKeys.Remove request")
)

ApiKeySvc errors

View Source
var (
	ErrFailedToCreateUpdateEmailRequest = errors.New("[ERROR]: Failed to create UpdateEmail request")
	ErrFailedToCreateEmailsSendRequest  = errors.New("[ERROR]: Failed to create SendEmail request")
	ErrFailedToCreateEmailsGetRequest   = errors.New("[ERROR]: Failed to create GetEmail request")
)

EmailsSvc errors

Functions

func BytesToIntArray

func BytesToIntArray(a []byte) []int

BytesToIntArray converts a byte array to rune array ie: []byte(`hello`) becomes []int{104,101,108,108,111} which will then be properly marshalled into JSON in the way Resend supports

Types

type ApiKey

type ApiKey struct {
	Id        string `json:"id"`
	Name      string `json:"name"`
	CreatedAt string `json:"created_at"`
}

type ApiKeysSvc

type ApiKeysSvc interface {
	CreateWithContext(ctx context.Context, params *CreateApiKeyRequest) (CreateApiKeyResponse, error)
	Create(params *CreateApiKeyRequest) (CreateApiKeyResponse, error)
	ListWithContext(ctx context.Context) (ListApiKeysResponse, error)
	List() (ListApiKeysResponse, error)
	RemoveWithContext(ctx context.Context, apiKeyId string) (bool, error)
	Remove(apiKeyId string) (bool, error)
}

type ApiKeysSvcImpl

type ApiKeysSvcImpl struct {
	// contains filtered or unexported fields
}

func (*ApiKeysSvcImpl) Create

Create creates a new API Key based on the given params

func (*ApiKeysSvcImpl) CreateWithContext

func (s *ApiKeysSvcImpl) CreateWithContext(ctx context.Context, params *CreateApiKeyRequest) (CreateApiKeyResponse, error)

CreateWithContext creates a new API Key based on the given params https://resend.com/docs/api-reference/api-keys/create-api-key

func (*ApiKeysSvcImpl) List

List all API Keys in the project

func (*ApiKeysSvcImpl) ListWithContext

func (s *ApiKeysSvcImpl) ListWithContext(ctx context.Context) (ListApiKeysResponse, error)

ListWithContext list all API Keys in the project https://resend.com/docs/api-reference/api-keys/list-api-keys

func (*ApiKeysSvcImpl) Remove

func (s *ApiKeysSvcImpl) Remove(apiKeyId string) (bool, error)

Remove deletes a given api key by id

func (*ApiKeysSvcImpl) RemoveWithContext

func (s *ApiKeysSvcImpl) RemoveWithContext(ctx context.Context, apiKeyId string) (bool, error)

RemoveWithContext deletes a given api key by id https://resend.com/docs/api-reference/api-keys/delete-api-key

type Attachment

type Attachment struct {
	// Content is the binary content of the attachment to use when a Path
	// is not available.
	Content []byte

	// Filename that will appear in the email.
	// Make sure you pick the correct extension otherwise preview
	// may not work as expected
	Filename string

	// Path where the attachment file is hosted instead of providing the
	// content directly.
	Path string

	// Content type for the attachment, if not set will be derived from
	// the filename property
	ContentType string
}

Attachment is the public struct used for adding attachments to emails

func (*Attachment) MarshalJSON

func (a *Attachment) MarshalJSON() ([]byte, error)

MarshalJSON overrides the regular JSON Marshaller to ensure that the attachment content is provided in the way Resend expects.

type Audience added in v2.4.0

type Audience struct {
	Id        string `json:"id"`
	Name      string `json:"name"`
	Object    string `json:"object"`
	CreatedAt string `json:"created_at"`
}

type AudiencesSvc added in v2.4.0

type AudiencesSvc interface {
	CreateWithContext(ctx context.Context, params *CreateAudienceRequest) (CreateAudienceResponse, error)
	Create(params *CreateAudienceRequest) (CreateAudienceResponse, error)
	ListWithContext(ctx context.Context) (ListAudiencesResponse, error)
	List() (ListAudiencesResponse, error)
	GetWithContext(ctx context.Context, audienceId string) (Audience, error)
	Get(audienceId string) (Audience, error)
	RemoveWithContext(ctx context.Context, audienceId string) (RemoveAudienceResponse, error)
	Remove(audienceId string) (RemoveAudienceResponse, error)
}

type AudiencesSvcImpl added in v2.4.0

type AudiencesSvcImpl struct {
	// contains filtered or unexported fields
}

func (*AudiencesSvcImpl) Create added in v2.4.0

Create creates a new Audience entry based on the given params https://resend.com/docs/api-reference/audiences/create-audience

func (*AudiencesSvcImpl) CreateWithContext added in v2.4.0

func (s *AudiencesSvcImpl) CreateWithContext(ctx context.Context, params *CreateAudienceRequest) (CreateAudienceResponse, error)

CreateWithContext creates a new Audience entry based on the given params https://resend.com/docs/api-reference/audiences/create-audience

func (*AudiencesSvcImpl) Get added in v2.4.0

func (s *AudiencesSvcImpl) Get(audienceId string) (Audience, error)

Get Retrieve a single audience. https://resend.com/docs/api-reference/audiences/get-audience

func (*AudiencesSvcImpl) GetWithContext added in v2.4.0

func (s *AudiencesSvcImpl) GetWithContext(ctx context.Context, audienceId string) (Audience, error)

GetWithContext Retrieve a single audience. https://resend.com/docs/api-reference/audiences/get-audience

func (*AudiencesSvcImpl) List added in v2.4.0

List returns the list of all audiences https://resend.com/docs/api-reference/audiences/list-audiences

func (*AudiencesSvcImpl) ListWithContext added in v2.4.0

func (s *AudiencesSvcImpl) ListWithContext(ctx context.Context) (ListAudiencesResponse, error)

ListWithContext returns the list of all audiences https://resend.com/docs/api-reference/audiences/list-audiences

func (*AudiencesSvcImpl) Remove added in v2.4.0

func (s *AudiencesSvcImpl) Remove(audienceId string) (RemoveAudienceResponse, error)

Remove removes a given audience entry by id https://resend.com/docs/api-reference/audiences/delete-audience

func (*AudiencesSvcImpl) RemoveWithContext added in v2.4.0

func (s *AudiencesSvcImpl) RemoveWithContext(ctx context.Context, audienceId string) (RemoveAudienceResponse, error)

RemoveWithContext removes a given audience by id https://resend.com/docs/api-reference/audiences/delete-audience

type BatchEmailResponse

type BatchEmailResponse struct {
	Data []SendEmailResponse `json:"data"`
}

BatchEmailResponse is the response from the BatchSendEmail call. see https://resend.com/docs/api-reference/emails/send-batch-emails

type BatchSvc

type BatchSvc interface {
	Send([]*SendEmailRequest) (*BatchEmailResponse, error)
	SendWithContext(ctx context.Context, params []*SendEmailRequest) (*BatchEmailResponse, error)
}

type BatchSvcImpl

type BatchSvcImpl struct {
	// contains filtered or unexported fields
}

func (*BatchSvcImpl) Send

func (s *BatchSvcImpl) Send(params []*SendEmailRequest) (*BatchEmailResponse, error)

Send send a batch of emails https://resend.com/docs/api-reference/emails/send-batch-emails

func (*BatchSvcImpl) SendWithContext

func (s *BatchSvcImpl) SendWithContext(ctx context.Context, params []*SendEmailRequest) (*BatchEmailResponse, error)

SendWithContext is the same as Send but accepts a ctx as argument

type Broadcast added in v2.14.0

type Broadcast struct {
	Object      string   `json:"object"`
	Id          string   `json:"id"`
	Name        string   `json:"name"`
	AudienceId  string   `json:"audience_id"`
	From        string   `json:"from"`
	Subject     string   `json:"subject"`
	ReplyTo     []string `json:"reply_to"`
	PreviewText string   `json:"preview_text"`
	Status      string   `json:"status"`
	CreatedAt   string   `json:"created_at"`
	ScheduledAt string   `json:"scheduled_at"`
	SentAt      string   `json:"sent_at"`
}

type BroadcastsSvc added in v2.14.0

type BroadcastsSvc interface {
	CreateWithContext(ctx context.Context, params *CreateBroadcastRequest) (CreateBroadcastResponse, error)
	Create(params *CreateBroadcastRequest) (CreateBroadcastResponse, error)

	ListWithContext(ctx context.Context) (ListBroadcastsResponse, error)
	List() (ListBroadcastsResponse, error)

	GetWithContext(ctx context.Context, broadcastId string) (Broadcast, error)
	Get(broadcastId string) (Broadcast, error)

	SendWithContext(ctx context.Context, params *SendBroadcastRequest) (SendBroadcastResponse, error)
	Send(params *SendBroadcastRequest) (SendBroadcastResponse, error)

	RemoveWithContext(ctx context.Context, broadcastId string) (RemoveBroadcastResponse, error)
	Remove(broadcastId string) (RemoveBroadcastResponse, error)
}

type BroadcastsSvcImpl added in v2.14.0

type BroadcastsSvcImpl struct {
	// contains filtered or unexported fields
}

func (*BroadcastsSvcImpl) Create added in v2.14.0

Create creates a new Broadcast based on the given params

func (*BroadcastsSvcImpl) CreateWithContext added in v2.14.0

CreateWithContext creates a new Broadcast based on the given params https://resend.com/docs/api-reference/broadcasts/create-broadcast

func (*BroadcastsSvcImpl) Get added in v2.14.0

func (s *BroadcastsSvcImpl) Get(broadcastId string) (Broadcast, error)

Get retrieves a single broadcast.

func (*BroadcastsSvcImpl) GetWithContext added in v2.14.0

func (s *BroadcastsSvcImpl) GetWithContext(ctx context.Context, broadcastId string) (Broadcast, error)

GetWithContext Retrieve a single broadcast. https://resend.com/docs/api-reference/broadcasts/get-broadcast

func (*BroadcastsSvcImpl) List added in v2.14.0

List returns the list of all broadcasts

func (*BroadcastsSvcImpl) ListWithContext added in v2.14.0

func (s *BroadcastsSvcImpl) ListWithContext(ctx context.Context) (ListBroadcastsResponse, error)

ListWithContext returns the list of all broadcasts https://resend.com/docs/api-reference/broadcasts/list-broadcasts

func (*BroadcastsSvcImpl) Remove added in v2.14.0

func (s *BroadcastsSvcImpl) Remove(broadcastId string) (RemoveBroadcastResponse, error)

Remove removes a given broadcast entry by id

func (*BroadcastsSvcImpl) RemoveWithContext added in v2.14.0

func (s *BroadcastsSvcImpl) RemoveWithContext(ctx context.Context, broadcastId string) (RemoveBroadcastResponse, error)

RemoveWithContext removes a given broadcast by id https://resend.com/docs/api-reference/broadcasts/delete-broadcast

func (*BroadcastsSvcImpl) Send added in v2.14.0

Send sends broadcasts to your audience.

func (*BroadcastsSvcImpl) SendWithContext added in v2.14.0

SendWithContext Sends broadcasts to your audience. https://resend.com/docs/api-reference/broadcasts/send-broadcast

type CancelScheduledEmailResponse added in v2.11.0

type CancelScheduledEmailResponse struct {
	Id     string `json:"id"`
	Object string `json:"object"`
}

CancelScheduledEmailResponse is the response from the Cancel call.

type Client

type Client struct {

	// Api Key
	ApiKey string

	// Base URL
	BaseURL *url.URL

	// User agent for client
	UserAgent string

	// Services
	Emails     EmailsSvc
	Batch      BatchSvc
	ApiKeys    ApiKeysSvc
	Domains    DomainsSvc
	Audiences  AudiencesSvc
	Contacts   ContactsSvc
	Broadcasts BroadcastsSvc
	// contains filtered or unexported fields
}

Client handles communication with Resend API.

func NewClient

func NewClient(apiKey string) *Client

NewClient is the default client constructor

func NewCustomClient

func NewCustomClient(httpClient *http.Client, apiKey string) *Client

NewCustomClient builds a new Resend API client, using a provided Http client.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, path string, params interface{}) (*http.Request, error)

NewRequest builds and returns a new HTTP request object based on the given arguments

func (*Client) Perform

func (c *Client) Perform(req *http.Request, ret interface{}) (*http.Response, error)

Perform sends the request to the Resend API

type Contact added in v2.4.0

type Contact struct {
	Id           string `json:"id"`
	Email        string `json:"email"`
	Object       string `json:"object"`
	FirstName    string `json:"first_name"`
	LastName     string `json:"last_name"`
	CreatedAt    string `json:"created_at"`
	Unsubscribed bool   `json:"unsubscribed"`
}

type ContactsSvc added in v2.4.0

type ContactsSvc interface {
	CreateWithContext(ctx context.Context, params *CreateContactRequest) (CreateContactResponse, error)
	Create(params *CreateContactRequest) (CreateContactResponse, error)
	ListWithContext(ctx context.Context, audienceId string) (ListContactsResponse, error)
	List(audienceId string) (ListContactsResponse, error)
	GetWithContext(ctx context.Context, audienceId, contactId string) (Contact, error)
	Get(audienceId, contactId string) (Contact, error)
	RemoveWithContext(ctx context.Context, audienceId, contactId string) (RemoveContactResponse, error)
	Remove(audienceId, contactId string) (RemoveContactResponse, error)
	UpdateWithContext(ctx context.Context, params *UpdateContactRequest) (UpdateContactResponse, error)
	Update(params *UpdateContactRequest) (UpdateContactResponse, error)
}

type ContactsSvcImpl added in v2.4.0

type ContactsSvcImpl struct {
	// contains filtered or unexported fields
}

func (*ContactsSvcImpl) Create added in v2.4.0

Create creates a new Contact entry based on the given params https://resend.com/docs/api-reference/contacts/create-contact

func (*ContactsSvcImpl) CreateWithContext added in v2.4.0

func (s *ContactsSvcImpl) CreateWithContext(ctx context.Context, params *CreateContactRequest) (CreateContactResponse, error)

CreateWithContext creates a new Contact based on the given params https://resend.com/docs/api-reference/contacts/create-contact

func (*ContactsSvcImpl) Get added in v2.4.0

func (s *ContactsSvcImpl) Get(audienceId, contactId string) (Contact, error)

Get Retrieve a single contact. https://resend.com/docs/api-reference/contacts/get-contact

func (*ContactsSvcImpl) GetWithContext added in v2.4.0

func (s *ContactsSvcImpl) GetWithContext(ctx context.Context, audienceId, contactId string) (Contact, error)

GetWithContext Retrieve a single contact. https://resend.com/docs/api-reference/contacts/get-contact

func (*ContactsSvcImpl) List added in v2.4.0

func (s *ContactsSvcImpl) List(audienceId string) (ListContactsResponse, error)

List returns the list of all contacts in an audience https://resend.com/docs/api-reference/contacts/list-contacts

func (*ContactsSvcImpl) ListWithContext added in v2.4.0

func (s *ContactsSvcImpl) ListWithContext(ctx context.Context, audienceId string) (ListContactsResponse, error)

ListWithContext returns the list of all contacts in an audience https://resend.com/docs/api-reference/contacts/list-contacts

func (*ContactsSvcImpl) Remove added in v2.4.0

func (s *ContactsSvcImpl) Remove(audienceId, contactId string) (RemoveContactResponse, error)

Remove removes a given contact entry by id or email

@param [contactId] - the contact id or contact email

https://resend.com/docs/api-reference/contacts/delete-contact

func (*ContactsSvcImpl) RemoveWithContext added in v2.4.0

func (s *ContactsSvcImpl) RemoveWithContext(ctx context.Context, audienceId, contactId string) (RemoveContactResponse, error)

RemoveWithContext same as Remove but with context https://resend.com/docs/api-reference/contacts/delete-contact

func (*ContactsSvcImpl) Update added in v2.4.0

UpdateWithContext updates an existing Contact based on the given params https://resend.com/docs/api-reference/contacts/update-contact

func (*ContactsSvcImpl) UpdateWithContext added in v2.4.0

func (s *ContactsSvcImpl) UpdateWithContext(ctx context.Context, params *UpdateContactRequest) (UpdateContactResponse, error)

UpdateWithContext updates an existing Contact based on the given params https://resend.com/docs/api-reference/contacts/update-contact

type CreateApiKeyRequest

type CreateApiKeyRequest struct {
	Name       string `json:"name"`
	Permission string `json:"permission,omitempty"` // TODO: update permission to type
	DomainId   string `json:"domain_id,omitempty"`
}

type CreateApiKeyResponse

type CreateApiKeyResponse struct {
	Id    string `json:"id"`
	Token string `json:"token"`
}

type CreateAudienceRequest added in v2.4.0

type CreateAudienceRequest struct {
	Name string `json:"name"`
}

type CreateAudienceResponse added in v2.4.0

type CreateAudienceResponse struct {
	Id     string `json:"id"`
	Name   string `json:"name"`
	Object string `json:"object"`
}

type CreateBroadcastRequest added in v2.14.0

type CreateBroadcastRequest struct {
	AudienceId string   `json:"audience_id"`
	From       string   `json:"from"`
	Subject    string   `json:"subject"`
	ReplyTo    []string `json:"reply_to"`
	Html       string   `json:"html"`
	Text       string   `json:"text"`
	Name       string   `json:"name"`
}

type CreateBroadcastResponse added in v2.14.0

type CreateBroadcastResponse struct {
	Id string `json:"id"`
}

type CreateContactRequest added in v2.4.0

type CreateContactRequest struct {
	Email        string `json:"email"`
	AudienceId   string `json:"audience_id"`
	Unsubscribed bool   `json:"unsubscribed,omitempty"`
	FirstName    string `json:"first_name,omitempty"`
	LastName     string `json:"last_name,omitempty"`
}

type CreateContactResponse added in v2.4.0

type CreateContactResponse struct {
	Object string `json:"object"`
	Id     string `json:"id"`
}

type CreateDomainRequest

type CreateDomainRequest struct {
	Name   string `json:"name"`
	Region string `json:"region,omitempty"`
}

type CreateDomainResponse

type CreateDomainResponse struct {
	Id          string   `json:"id"`
	Name        string   `json:"name"`
	CreatedAt   string   `json:"createdAt"`
	Status      string   `json:"status"`
	Records     []Record `json:"records"`
	Region      string   `json:"region"`
	DnsProvider string   `json:"dnsProvider"`
}

type DefaultError

type DefaultError struct {
	Message string `json:"message"`
}

type Domain

type Domain struct {
	Id        string `json:"id,omitempty"`
	Object    string `json:"object,omitempty"`
	Name      string `json:"name,omitempty"`
	CreatedAt string `json:"created_at,omitempty"`
	Status    string `json:"status,omitempty"`
	Region    string `json:"region,omitempty"`
}

type DomainsSvc

type DomainsSvc interface {
	CreateWithContext(ctx context.Context, params *CreateDomainRequest) (CreateDomainResponse, error)
	Create(params *CreateDomainRequest) (CreateDomainResponse, error)
	VerifyWithContext(ctx context.Context, domainId string) (bool, error)
	Verify(domainId string) (bool, error)
	ListWithContext(ctx context.Context) (ListDomainsResponse, error)
	List() (ListDomainsResponse, error)
	GetWithContext(ctx context.Context, domainId string) (Domain, error)
	Get(domainId string) (Domain, error)
	RemoveWithContext(ctx context.Context, domainId string) (bool, error)
	Remove(domainId string) (bool, error)
	UpdateWithContext(ctx context.Context, domainId string, params *UpdateDomainRequest) (Domain, error)
	Update(domainId string, params *UpdateDomainRequest) (Domain, error)
}

type DomainsSvcImpl

type DomainsSvcImpl struct {
	// contains filtered or unexported fields
}

func (*DomainsSvcImpl) Create

Create creates a new Domain entry based on the given params https://resend.com/docs/api-reference/domains/create-domain

func (*DomainsSvcImpl) CreateWithContext

func (s *DomainsSvcImpl) CreateWithContext(ctx context.Context, params *CreateDomainRequest) (CreateDomainResponse, error)

CreateWithContext creates a new Domain entry based on the given params https://resend.com/docs/api-reference/domains/create-domain

func (*DomainsSvcImpl) Get

func (s *DomainsSvcImpl) Get(domainId string) (Domain, error)

Get retrieves a domain object https://resend.com/docs/api-reference/domains/get-domain

func (*DomainsSvcImpl) GetWithContext

func (s *DomainsSvcImpl) GetWithContext(ctx context.Context, domainId string) (Domain, error)

GetWithContext retrieves a domain object https://resend.com/docs/api-reference/domains/get-domain

func (*DomainsSvcImpl) List

List returns the list of all domains https://resend.com/docs/api-reference/domains/list-domains

func (*DomainsSvcImpl) ListWithContext

func (s *DomainsSvcImpl) ListWithContext(ctx context.Context) (ListDomainsResponse, error)

ListWithContext returns the list of all domains https://resend.com/docs/api-reference/domains/list-domains

func (*DomainsSvcImpl) Remove

func (s *DomainsSvcImpl) Remove(domainId string) (bool, error)

Remove removes a given domain entry by id https://resend.com/docs/api-reference/domains/delete-domain

func (*DomainsSvcImpl) RemoveWithContext

func (s *DomainsSvcImpl) RemoveWithContext(ctx context.Context, domainId string) (bool, error)

RemoveWithContext removes a given domain entry by id https://resend.com/docs/api-reference/domains/delete-domain

func (*DomainsSvcImpl) Update added in v2.6.0

func (s *DomainsSvcImpl) Update(domainId string, params *UpdateDomainRequest) (Domain, error)

Update is a wrapper around UpdateWithContext

func (*DomainsSvcImpl) UpdateWithContext added in v2.6.0

func (s *DomainsSvcImpl) UpdateWithContext(ctx context.Context, domainId string, params *UpdateDomainRequest) (Domain, error)

UpdateWithContext updates an existing Domain entry based on the given params https://resend.com/docs/api-reference/domains/update-domain

func (*DomainsSvcImpl) Verify

func (s *DomainsSvcImpl) Verify(domainId string) (bool, error)

Verify verifies a given domain Id https://resend.com/docs/api-reference/domains/verify-domain

func (*DomainsSvcImpl) VerifyWithContext

func (s *DomainsSvcImpl) VerifyWithContext(ctx context.Context, domainId string) (bool, error)

VerifyWithContext verifies a given domain Id https://resend.com/docs/api-reference/domains/verify-domain

type Email

type Email struct {
	Id        string   `json:"id"`
	Object    string   `json:"object"`
	To        []string `json:"to"`
	From      string   `json:"from"`
	CreatedAt string   `json:"created_at"`
	Subject   string   `json:"subject"`
	Html      string   `json:"html"`
	Text      string   `json:"text"`
	Bcc       []string `json:"bcc"`
	Cc        []string `json:"cc"`
	ReplyTo   []string `json:"reply_to"`
	LastEvent string   `json:"last_event"`
}

Email provides the structure for the response from the Get call.

type EmailsSvc

type EmailsSvc interface {
	CancelWithContext(ctx context.Context, emailID string) (*CancelScheduledEmailResponse, error)
	Cancel(emailID string) (*CancelScheduledEmailResponse, error)
	UpdateWithContext(ctx context.Context, params *UpdateEmailRequest) (*UpdateEmailResponse, error)
	Update(params *UpdateEmailRequest) (*UpdateEmailResponse, error)
	SendWithContext(ctx context.Context, params *SendEmailRequest) (*SendEmailResponse, error)
	Send(params *SendEmailRequest) (*SendEmailResponse, error)
	GetWithContext(ctx context.Context, emailID string) (*Email, error)
	Get(emailID string) (*Email, error)
}

type EmailsSvcImpl

type EmailsSvcImpl struct {
	// contains filtered or unexported fields
}

func (*EmailsSvcImpl) Cancel added in v2.11.0

func (s *EmailsSvcImpl) Cancel(emailID string) (*CancelScheduledEmailResponse, error)

Cancel cancels an email by ID https://resend.com/docs/api-reference/emails/cancel-email

func (*EmailsSvcImpl) CancelWithContext added in v2.11.0

func (s *EmailsSvcImpl) CancelWithContext(ctx context.Context, emailID string) (*CancelScheduledEmailResponse, error)

CancelWithContext cancels an email by ID https://resend.com/docs/api-reference/emails/cancel-email

func (*EmailsSvcImpl) Get

func (s *EmailsSvcImpl) Get(emailID string) (*Email, error)

Get retrieves an email with the given emailID https://resend.com/docs/api-reference/emails/retrieve-email

func (*EmailsSvcImpl) GetWithContext

func (s *EmailsSvcImpl) GetWithContext(ctx context.Context, emailID string) (*Email, error)

GetWithContext retrieves an email with the given emailID https://resend.com/docs/api-reference/emails/retrieve-email

func (*EmailsSvcImpl) Send

Send sends an email with the given params https://resend.com/docs/api-reference/emails/send-email

func (*EmailsSvcImpl) SendWithContext

func (s *EmailsSvcImpl) SendWithContext(ctx context.Context, params *SendEmailRequest) (*SendEmailResponse, error)

SendWithContext sends an email with the given params https://resend.com/docs/api-reference/emails/send-email

func (*EmailsSvcImpl) Update added in v2.11.0

Update updates an email with the given params https://resend.com/docs/api-reference/emails/update-email

func (*EmailsSvcImpl) UpdateWithContext added in v2.11.0

func (s *EmailsSvcImpl) UpdateWithContext(ctx context.Context, params *UpdateEmailRequest) (*UpdateEmailResponse, error)

UpdateWithContext updates an email with the given params https://resend.com/docs/api-reference/emails/update-email

type InvalidRequestError

type InvalidRequestError struct {
	StatusCode int    `json:"statusCode"`
	Name       string `json:"name"`
	Message    string `json:"message"`
}

type ListApiKeysResponse

type ListApiKeysResponse struct {
	Data []ApiKey `json:"data"`
}

type ListAudiencesResponse added in v2.4.0

type ListAudiencesResponse struct {
	Object string     `json:"object"`
	Data   []Audience `json:"data"`
}

type ListBroadcastsResponse added in v2.14.0

type ListBroadcastsResponse struct {
	Object string      `json:"object"`
	Data   []Broadcast `json:"data"`
}

type ListContactsResponse added in v2.4.0

type ListContactsResponse struct {
	Object string    `json:"object"`
	Data   []Contact `json:"data"`
}

type ListDomainsResponse

type ListDomainsResponse struct {
	Data []Domain `json:"data"`
}

type MissingRequiredFieldsError added in v2.15.0

type MissingRequiredFieldsError struct {
	// contains filtered or unexported fields
}

MissingRequiredFieldsError is used when a required field is missing before making an API request

func (*MissingRequiredFieldsError) Error added in v2.15.0

type Record

type Record struct {
	Record   string      `json:"record"`
	Name     string      `json:"name"`
	Type     string      `json:"type"`
	Ttl      string      `json:"ttl"`
	Status   string      `json:"status"`
	Value    string      `json:"value"`
	Priority json.Number `json:"priority,omitempty"`
}

type RemoveAudienceResponse added in v2.4.0

type RemoveAudienceResponse struct {
	Id      string `json:"id"`
	Object  string `json:"object"`
	Deleted bool   `json:"deleted"`
}

type RemoveBroadcastResponse added in v2.14.0

type RemoveBroadcastResponse struct {
	Object  string `json:"object"`
	Id      string `json:"id"`
	Deleted bool   `json:"deleted"`
}

type RemoveContactResponse added in v2.4.0

type RemoveContactResponse struct {
	Id      string `json:"id"`
	Object  string `json:"object"`
	Deleted bool   `json:"deleted"`
}

type SendBroadcastRequest added in v2.14.0

type SendBroadcastRequest struct {
	BroadcastId string `json:"broadcast_id"`

	//Schedule email to be sent later. The date should be in language natural (e.g.: in 1 min)
	// or ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z).
	ScheduledAt string `json:"scheduled_at"`
}

type SendBroadcastResponse added in v2.14.0

type SendBroadcastResponse struct {
	Id string `json:"id"`
}

type SendEmailRequest

type SendEmailRequest struct {
	From        string            `json:"from"`
	To          []string          `json:"to"`
	Subject     string            `json:"subject"`
	Bcc         []string          `json:"bcc,omitempty"`
	Cc          []string          `json:"cc,omitempty"`
	ReplyTo     string            `json:"reply_to,omitempty"`
	Html        string            `json:"html,omitempty"`
	Text        string            `json:"text,omitempty"`
	Tags        []Tag             `json:"tags,omitempty"`
	Attachments []*Attachment     `json:"attachments,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
	ScheduledAt string            `json:"scheduled_at,omitempty"`
}

SendEmailRequest is the request object for the Send call.

See also https://resend.com/docs/api-reference/emails/send-email

type SendEmailResponse

type SendEmailResponse struct {
	Id string `json:"id"`
}

SendEmailResponse is the response from the Send call.

type Tag

type Tag struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Tags are used to define custom metadata for emails

type TlsOption added in v2.8.0

type TlsOption = string
const (
	Enforced      TlsOption = "enforced"
	Opportunistic TlsOption = "opportunistic"
)

type UpdateContactRequest added in v2.4.0

type UpdateContactRequest struct {
	Id           string `json:"id"`
	Email        string `json:"email,omitempty"`
	AudienceId   string `json:"audience_id"`
	FirstName    string `json:"first_name,omitempty"`
	LastName     string `json:"last_name,omitempty"`
	Unsubscribed bool   `json:"unsubscribed,omitempty"`
}

type UpdateContactResponse added in v2.4.0

type UpdateContactResponse struct {
	Data  Contact  `json:"data"`
	Error struct{} `json:"error"` // Fix this
}

type UpdateDomainRequest added in v2.6.0

type UpdateDomainRequest struct {
	OpenTracking  bool      `json:"open_tracking,omitempty"`
	ClickTracking bool      `json:"click_tracking,omitempty"`
	Tls           TlsOption `json:"tls,omitempty"`
}

type UpdateEmailRequest added in v2.11.0

type UpdateEmailRequest struct {
	Id          string `json:"id"`
	ScheduledAt string `json:"scheduled_at"`
}

UpdateEmailRequest is the request object for the Update call.

type UpdateEmailResponse added in v2.11.0

type UpdateEmailResponse struct {
	Id     string `json:"id"`
	Object string `json:"object"`
}

UpdateEmailResponse is the type that represents the response from the Update call.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL