Skip to main content
Resend Docs

Search documentation

Type to search this documentation.

On this pageOverview

Update Segment

PATCH

/

segments

/

:segment_id

Node.js
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.segments.update(
  '78261eea-8f8b-4381-83c6-79fa7120f1cf',
  {
    name: 'Active Users',
  },
);
PHP
$resend = Resend::client('re_xxxxxxxxx');

$resend->segments->update('78261eea-8f8b-4381-83c6-79fa7120f1cf', [
  'name' => 'Active Users',
]);
Python
import resend

resend.api_key = 're_xxxxxxxxx'

params: resend.Segments.UpdateParams = {
    "name": "Active Users",
}

segment = resend.Segments.update('78261eea-8f8b-4381-83c6-79fa7120f1cf', params)
Ruby
require "resend"

Resend.api_key = "re_xxxxxxxxx"

params = {
  segment_id: "78261eea-8f8b-4381-83c6-79fa7120f1cf",
  name: "Active Users"
}
Resend::Segments.update(params)
Go
package main

import (
	"context"
	"fmt"

	"github.com/resend/resend-go/v4"
)

func main() {
	ctx := context.TODO()
	client := resend.NewClient("re_xxxxxxxxx")

	params := &resend.UpdateSegmentRequest{
		Name: "Active Users",
	}

	segment, err := client.Segments.UpdateWithContext(ctx, "78261eea-8f8b-4381-83c6-79fa7120f1cf", params)
	if err != nil {
		panic(err)
	}
	fmt.Println(segment)
}
Rust
use resend_rs::{Resend, Result};

#[tokio::main]
async fn main() -> Result<()> {
  let resend = Resend::new("re_xxxxxxxxx");

  let _segment = resend
    .segments
    .update("78261eea-8f8b-4381-83c6-79fa7120f1cf", "Active Users")
    .await?;

  Ok(())
}
Java
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.segments.model.UpdateSegmentOptions;
import com.resend.services.segments.model.UpdateSegmentResponseSuccess;

public class Main {
    public static void main(String[] args) throws ResendException {
        Resend resend = new Resend("re_xxxxxxxxx");

        UpdateSegmentOptions options = UpdateSegmentOptions.builder()
            .name("Active Users")
            .build();

        UpdateSegmentResponseSuccess response = resend.segments().update("78261eea-8f8b-4381-83c6-79fa7120f1cf", options);
    }
}
.NET
using Resend;

IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI

var resp = await resend.SegmentUpdateAsync( new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), new SegmentData() {
  Name = "Active Users",
} );
Console.WriteLine( "Segment Id={0}", resp.Content.Id );
cURL
curl -X PATCH 'https://api.resend.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf' \
     -H 'Authorization: Bearer re_xxxxxxxxx' \
     -H 'Content-Type: application/json' \
     -d $'{
  "name": "Active Users"
}'
CLI
resend segments update 78261eea-8f8b-4381-83c6-79fa7120f1cf --name "Active Users"
Response
{
  "object": "segment",
  "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf"
}

string

required

The name of the segment.

Node.js
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.segments.update(
  '78261eea-8f8b-4381-83c6-79fa7120f1cf',
  {
    name: 'Active Users',
  },
);
PHP
$resend = Resend::client('re_xxxxxxxxx');

$resend->segments->update('78261eea-8f8b-4381-83c6-79fa7120f1cf', [
  'name' => 'Active Users',
]);
Python
import resend

resend.api_key = 're_xxxxxxxxx'

params: resend.Segments.UpdateParams = {
    "name": "Active Users",
}

segment = resend.Segments.update('78261eea-8f8b-4381-83c6-79fa7120f1cf', params)
Ruby
require "resend"

Resend.api_key = "re_xxxxxxxxx"

params = {
  segment_id: "78261eea-8f8b-4381-83c6-79fa7120f1cf",
  name: "Active Users"
}
Resend::Segments.update(params)
Go
package main

import (
	"context"
	"fmt"

	"github.com/resend/resend-go/v4"
)

func main() {
	ctx := context.TODO()
	client := resend.NewClient("re_xxxxxxxxx")

	params := &resend.UpdateSegmentRequest{
		Name: "Active Users",
	}

	segment, err := client.Segments.UpdateWithContext(ctx, "78261eea-8f8b-4381-83c6-79fa7120f1cf", params)
	if err != nil {
		panic(err)
	}
	fmt.Println(segment)
}
Rust
use resend_rs::{Resend, Result};

#[tokio::main]
async fn main() -> Result<()> {
  let resend = Resend::new("re_xxxxxxxxx");

  let _segment = resend
    .segments
    .update("78261eea-8f8b-4381-83c6-79fa7120f1cf", "Active Users")
    .await?;

  Ok(())
}
Java
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.segments.model.UpdateSegmentOptions;
import com.resend.services.segments.model.UpdateSegmentResponseSuccess;

public class Main {
    public static void main(String[] args) throws ResendException {
        Resend resend = new Resend("re_xxxxxxxxx");

        UpdateSegmentOptions options = UpdateSegmentOptions.builder()
            .name("Active Users")
            .build();

        UpdateSegmentResponseSuccess response = resend.segments().update("78261eea-8f8b-4381-83c6-79fa7120f1cf", options);
    }
}
.NET
using Resend;

IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI

var resp = await resend.SegmentUpdateAsync( new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), new SegmentData() {
  Name = "Active Users",
} );
Console.WriteLine( "Segment Id={0}", resp.Content.Id );
cURL
curl -X PATCH 'https://api.resend.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf' \
     -H 'Authorization: Bearer re_xxxxxxxxx' \
     -H 'Content-Type: application/json' \
     -d $'{
  "name": "Active Users"
}'
CLI
resend segments update 78261eea-8f8b-4381-83c6-79fa7120f1cf --name "Active Users"
JSON
{
  "object": "segment",
  "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf"
}

Was this page helpful?

⌘I

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu