Skip to main content

Update

Updates a scheduled email with the given parameters.
func (s *EmailsSvcImpl) Update(params *UpdateEmailRequest) (*UpdateEmailResponse, error)

Parameters

params
*UpdateEmailRequest
required
The update parameters.

Returns

response
*UpdateEmailResponse

Example

package main

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

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

	updateParams := &resend.UpdateEmailRequest{
		Id:          "4ef9a417-02e9-4d39-ad75-9611e0fcc33c",
		ScheduledAt: "2024-11-05T11:52:01.858Z",
	}

	updated, err := client.Emails.Update(updateParams)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Updated email: %s\n", updated.Id)
}

UpdateWithContext

Updates a scheduled email with the given parameters and context.
func (s *EmailsSvcImpl) UpdateWithContext(ctx context.Context, params *UpdateEmailRequest) (*UpdateEmailResponse, error)

Parameters

ctx
context.Context
required
Context for the request.
params
*UpdateEmailRequest
required
The update parameters. See Update for field details.

Returns

response
*UpdateEmailResponse
See Update for response field details.

Example

package main

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

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

	// First, schedule an email
	sendParams := &resend.SendEmailRequest{
		From:        "[email protected]",
		To:          []string{"[email protected]"},
		Subject:     "Scheduled Email",
		Text:        "This email will be sent later",
		ScheduledAt: "2024-09-05T11:52:01.858Z",
	}

	sent, err := client.Emails.SendWithContext(ctx, sendParams)
	if err != nil {
		panic(err)
	}

	// Update the scheduled time
	updateParams := &resend.UpdateEmailRequest{
		Id:          sent.Id,
		ScheduledAt: "2024-11-05T11:52:01.858Z",
	}

	updated, err := client.Emails.UpdateWithContext(ctx, updateParams)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Updated email: %s\n", updated.Id)
}

Build docs developers (and LLMs) love