Skip to main content
Removes a segment entry by its unique identifier.

Methods

Remove

Remove(segmentId string) (RemoveSegmentResponse, error)
Deletes a segment using the default background context.

RemoveWithContext

RemoveWithContext(ctx context.Context, segmentId string) (RemoveSegmentResponse, error)
Deletes a segment with a custom context for cancellation and timeout control.

Parameters

segmentId
string
required
The unique identifier of the segment to delete.

Response

id
string
The unique identifier of the deleted segment.
object
string
The object type, always segment.
deleted
boolean
Indicates whether the segment was successfully deleted.

Example

package main

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

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

    response, err := client.Segments.Remove("seg_123456")
    if err != nil {
        panic(err)
    }

    if response.Deleted {
        fmt.Println("Segment deleted successfully")
    }
}
Deleting a segment is permanent and cannot be undone. Make sure you want to delete the segment before proceeding.

Build docs developers (and LLMs) love