Update a segment
curl --request PATCH \
--url https://api.instantly.ai/api/v2/email-marketing/segments/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expected_revision": 1,
"name": "Active trial users",
"description": "Signed up recently"
}
'import requests
url = "https://api.instantly.ai/api/v2/email-marketing/segments/{id}"
payload = {
"expected_revision": 1,
"name": "Active trial users",
"description": "Signed up recently"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expected_revision: 1,
name: 'Active trial users',
description: 'Signed up recently'
})
};
fetch('https://api.instantly.ai/api/v2/email-marketing/segments/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.patch("https://api.instantly.ai/api/v2/email-marketing/segments/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expected_revision\": 1,\n \"name\": \"Active trial users\",\n \"description\": \"Signed up recently\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.instantly.ai/api/v2/email-marketing/segments/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'expected_revision' => 1,
'name' => 'Active trial users',
'description' => 'Signed up recently'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.instantly.ai/api/v2/email-marketing/segments/{id}"
payload := strings.NewReader("{\n \"expected_revision\": 1,\n \"name\": \"Active trial users\",\n \"description\": \"Signed up recently\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "0198a123-4567-7890-abcd-ef0123456789",
"workspace_id": "0198a123-4567-7890-abcd-ef0123456788",
"name": "Active trial users",
"description": "Signed up in the last 30 days",
"definition": {
"groups": [
{
"clauses": [
{
"operand": {
"field": "email"
},
"operator": "equals",
"value": "growth"
}
]
}
],
"timezone": "Europe/Bucharest"
},
"segment_type": "dynamic",
"schema_version": 1,
"revision": 1,
"timestamp_created": "2026-11-24T11:57:07.732Z",
"timestamp_updated": "2026-11-24T11:57:07.732Z",
"created_by": "0198a123-4567-7890-abcd-ef0123456787",
"updated_by": "0198a123-4567-7890-abcd-ef0123456787"
}{
"statusCode": 400,
"error": "Bad Request",
"message": "limit: must be at most 50",
"code": "VALIDATION_ERROR"
}{
"statusCode": 401,
"error": "Unauthorized",
"message": "Missing Authorization header"
}{
"statusCode": 402,
"error": "Payment Required",
"message": "Workspace does not have an active paid plan"
}{
"statusCode": 403,
"error": "Forbidden",
"message": "Workspace suspended due to a high bounce or spam complaint rate. Please contact support.",
"code": "WORKSPACE_SUSPENDED"
}{
"statusCode": 404,
"error": "Not Found",
"message": "Not found",
"code": "NOT_FOUND"
}{
"statusCode": 408,
"error": "Request Timeout",
"message": "An internal error occurred"
}{
"statusCode": 409,
"error": "Conflict",
"message": "The resource has changed. Reload it and try again.",
"code": "CONFLICT"
}{
"statusCode": 429,
"error": "Too Many Requests",
"message": "Rate limit exceeded"
}{
"statusCode": 500,
"error": "Internal Server Error",
"message": "An internal error occurred"
}Inbound & Lifecycle: Segment
Update a segment
Changes the name, description or definition of a segment. Send the revision you last read as expected_revision: if the segment changed since, the update gives 409 and you should read it again.
Requires one of the following scopes: email_marketing_subscribers:update, email_marketing_subscribers:all, all:update, all:all
PATCH
/
api
/
v2
/
email-marketing
/
segments
/
{id}
Update a segment
curl --request PATCH \
--url https://api.instantly.ai/api/v2/email-marketing/segments/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expected_revision": 1,
"name": "Active trial users",
"description": "Signed up recently"
}
'import requests
url = "https://api.instantly.ai/api/v2/email-marketing/segments/{id}"
payload = {
"expected_revision": 1,
"name": "Active trial users",
"description": "Signed up recently"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expected_revision: 1,
name: 'Active trial users',
description: 'Signed up recently'
})
};
fetch('https://api.instantly.ai/api/v2/email-marketing/segments/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.patch("https://api.instantly.ai/api/v2/email-marketing/segments/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expected_revision\": 1,\n \"name\": \"Active trial users\",\n \"description\": \"Signed up recently\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.instantly.ai/api/v2/email-marketing/segments/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'expected_revision' => 1,
'name' => 'Active trial users',
'description' => 'Signed up recently'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.instantly.ai/api/v2/email-marketing/segments/{id}"
payload := strings.NewReader("{\n \"expected_revision\": 1,\n \"name\": \"Active trial users\",\n \"description\": \"Signed up recently\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "0198a123-4567-7890-abcd-ef0123456789",
"workspace_id": "0198a123-4567-7890-abcd-ef0123456788",
"name": "Active trial users",
"description": "Signed up in the last 30 days",
"definition": {
"groups": [
{
"clauses": [
{
"operand": {
"field": "email"
},
"operator": "equals",
"value": "growth"
}
]
}
],
"timezone": "Europe/Bucharest"
},
"segment_type": "dynamic",
"schema_version": 1,
"revision": 1,
"timestamp_created": "2026-11-24T11:57:07.732Z",
"timestamp_updated": "2026-11-24T11:57:07.732Z",
"created_by": "0198a123-4567-7890-abcd-ef0123456787",
"updated_by": "0198a123-4567-7890-abcd-ef0123456787"
}{
"statusCode": 400,
"error": "Bad Request",
"message": "limit: must be at most 50",
"code": "VALIDATION_ERROR"
}{
"statusCode": 401,
"error": "Unauthorized",
"message": "Missing Authorization header"
}{
"statusCode": 402,
"error": "Payment Required",
"message": "Workspace does not have an active paid plan"
}{
"statusCode": 403,
"error": "Forbidden",
"message": "Workspace suspended due to a high bounce or spam complaint rate. Please contact support.",
"code": "WORKSPACE_SUSPENDED"
}{
"statusCode": 404,
"error": "Not Found",
"message": "Not found",
"code": "NOT_FOUND"
}{
"statusCode": 408,
"error": "Request Timeout",
"message": "An internal error occurred"
}{
"statusCode": 409,
"error": "Conflict",
"message": "The resource has changed. Reload it and try again.",
"code": "CONFLICT"
}{
"statusCode": 429,
"error": "Too Many Requests",
"message": "Rate limit exceeded"
}{
"statusCode": 500,
"error": "Internal Server Error",
"message": "An internal error occurred"
}Authorizations
Path Parameters
Body
application/json
- Option 1
- Option 2
- Option 3
Response
The updated segment
A saved set of rules that selects contacts. Membership is worked out each time the segment is used. Optional fields with no value are left out of responses. Lists page with cursor: pass the previous page's next_cursor until there is none.