Save a customer segment
POST
/api/v1/commerce/segments
const url = 'https://digize.com/api/v1/commerce/segments';const options = { method: 'POST', headers: { 'Idempotency-Key': '5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69', 'x-api-key': '<x-api-key>', 'Content-Type': 'application/json' }, body: '{"id":"example","name":"example","filter":{"search":"example","tags":["example"],"minOrders":1,"maxOrders":1,"minSpent":1,"maxSpent":1,"orderedWithinDays":1,"notOrderedWithinDays":1,"emailMarketing":["subscribed"],"hasStoreCredit":true,"minPoints":1,"location":"example"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://digize.com/api/v1/commerce/segments \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: 5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69' \ --header 'x-api-key: <x-api-key>' \ --data '{ "id": "example", "name": "example", "filter": { "search": "example", "tags": [ "example" ], "minOrders": 1, "maxOrders": 1, "minSpent": 1, "maxSpent": 1, "orderedWithinDays": 1, "notOrderedWithinDays": 1, "emailMarketing": [ "subscribed" ], "hasStoreCredit": true, "minPoints": 1, "location": "example" } }'Saves a customer filter as a named segment, or changes one with id: orders, spend, last order, tags, email consent, store credit, points, location.
Needs the commerce:write permission.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Idempotency-Key
string
Makes the request safe to send again: for 24 hours the same key and request answer the first response without repeating the change.
Example
5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
Responses
Section titled “Responses”Done
Media typeapplication/json
object
id
required
string
name
required
string
filter
required
object
search
string
tags
Array<string>
minOrders
integer
maxOrders
integer
minSpent
integer
maxSpent
integer
orderedWithinDays
integer
notOrderedWithinDays
integer
emailMarketing
Array<string>
hasStoreCredit
boolean
minPoints
integer
location
string
createdBy
required
string
createdAt
required
string format: date-time
updatedAt
required
string format: date-time
Example
{ "filter": { "emailMarketing": [ "subscribed" ] }}What was sent isn’t valid (invalid).
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any
Example
{ "error": { "code": "invalid" }}No key, or one that’s unknown, off or expired.
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any
Example
{ "error": { "code": "invalid" }}The key doesn’t have the permission this needs.
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any
Example
{ "error": { "code": "invalid" }}Nothing has that id (not_found).
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any
Example
{ "error": { "code": "invalid" }}A request with the same Idempotency-Key is still running (conflict).
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any
Example
{ "error": { "code": "invalid" }}The Idempotency-Key was used with a different request.
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any
Example
{ "error": { "code": "invalid" }}Over the rate limit; see retry-after.
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any
Example
{ "error": { "code": "invalid" }}