Clienvy API documentation

Marketing segments

BETA. Part of the E-mailmarketing module, which only works for organizations that were given access to the beta and switched the module on. Do not use these endpoints on your own initiative; only when the user explicitly asks for mailings or segments. A segment holds conditions on relations, never a list: who falls in it is worked out again on every request and when a mailing is sent.


List segments

GET
https://api.clienvy.io/employee/v1
/marketing-segments

Returns all segments with who they reach right now.

List segments › query Parameters

search
​string

Only return segments whose name contains this text.

page
​integer

Page number of the paginated result set.

per_page
​integer

Number of items per page. Defaults to the endpoint's own page size; capped at 500.

List segments › Headers

X-Organization-Id
​string · uuid · required

UUID of the organization (tenant) the request operates on.

List segments › Responses

Array of MarketingSegmentListResource

​object

Create a segment

POST
https://api.clienvy.io/employee/v1
/marketing-segments

Create a segment › Headers

X-Organization-Id
​string · uuid · required

UUID of the organization (tenant) the request operates on.

Create a segment › Request Body

name
​string · maxLength: 128 · required
​object[] · required

The conditions, see GET marketing-segments/fields. Every condition must hold.

Create a segment › Responses

MarketingSegmentResource

id
​string · uuid
name
​string
condition_count
​integer
recipient_count
​integer

Who the segment reaches right now.

marketing_mailing_count
​integer

The number of mailings that use this segment.

created_at
​string · date-time
​object[]

Every condition must hold. See GET marketing-segments/fields for the fields, their operators and values. records names the records a condition on records picks; null for other conditions.

updated_at
​string · date-time

The condition fields

GET
https://api.clienvy.io/employee/v1
/marketing-segments/fields

Lists what a segment condition can look at, with the operators each field allows, the kind of value it takes, and the options or the endpoint to pick records from.

The condition fields › Headers

X-Organization-Id
​string · uuid · required

UUID of the organization (tenant) the request operates on.

The condition fields › Responses

Array of MarketingSegmentFieldResource

field
​string
label
​string
applies_to_contact
​boolean

Whether the condition looks at the contact rather than at its company.

​object[]
value_type
​MarketingSegmentConditionValueType · enum

What a condition compares against, so the front-end knows which field to show and the back-end which value to accept.

options
One or more values from a fixed list of options.
records
One or more records, fetched from the endpoint the field names.
number
none
The operator says it all, such as "has a customer portal account".
Enum values:
options
records
number
none
​object[]

The values to choose from, for a field with options.

records_endpoint
​string | null

Where to pick the records from, for a field on records. Null for other fields.


Preview a segment

POST
https://api.clienvy.io/employee/v1
/marketing-segments/preview

Who unsaved conditions would reach, to show while a segment is being built, or with marketing_segment_ids who saved segments reach together, as a mailing to them does: an address in several gets it once. Paginated, so meta.total is how many there are. Send page in the query string.

Preview a segment › Headers

X-Organization-Id
​string · uuid · required

UUID of the organization (tenant) the request operates on.

Preview a segment › Request Body

​object[]

The conditions, see GET marketing-segments/fields. Every condition must hold. Required without marketing_segment_ids.

​array

UUIDs of saved segments to preview together, instead of conditions.

marketing_mail_type_id
​string · uuid

Work it out for a mail of this type: who unsubscribed from it is left out.

Preview a segment › Responses

Array of MarketingSegmentRecipientResource

recipient_key
​string

Who the mail is filled in for, to pick a preview or test mail with.

name
​string
company_name
​string
function
​string
email
​string

Get a segment

GET
https://api.clienvy.io/employee/v1
/marketing-segments/{marketingSegment}

Returns a segment with its conditions, who it reaches right now, who it leaves out and which mailings use it.

Get a segment › path Parameters

marketingSegment
​string · uuid · required

The marketing segment UUID

Get a segment › Headers

X-Organization-Id
​string · uuid · required

UUID of the organization (tenant) the request operates on.

Get a segment › Responses

MarketingSegmentResource

id
​string · uuid
name
​string
condition_count
​integer
recipient_count
​integer

Who the segment reaches right now.

marketing_mailing_count
​integer

The number of mailings that use this segment.

created_at
​string · date-time
​object[]

Every condition must hold. See GET marketing-segments/fields for the fields, their operators and values. records names the records a condition on records picks; null for other conditions.

updated_at
​string · date-time

Update a segment

PUT
https://api.clienvy.io/employee/v1
/marketing-segments/{marketingSegment}

Only the fields present in the request change. conditions replaces all conditions.

Update a segment › path Parameters

marketingSegment
​string · uuid · required

The marketing segment UUID

Update a segment › Headers

X-Organization-Id
​string · uuid · required

UUID of the organization (tenant) the request operates on.

Update a segment › Request Body

name
​string · maxLength: 128
​object[]

Replaces all conditions, see GET marketing-segments/fields.

Update a segment › Responses

MarketingSegmentResource

id
​string · uuid
name
​string
condition_count
​integer
recipient_count
​integer

Who the segment reaches right now.

marketing_mailing_count
​integer

The number of mailings that use this segment.

created_at
​string · date-time
​object[]

Every condition must hold. See GET marketing-segments/fields for the fields, their operators and values. records names the records a condition on records picks; null for other conditions.

updated_at
​string · date-time

Delete a segment

DELETE
https://api.clienvy.io/employee/v1
/marketing-segments/{marketingSegment}

Refused once a mailing uses it, also one that went out: the mailing keeps showing which segments it was sent to.

Delete a segment › path Parameters

marketingSegment
​string · uuid · required

The marketing segment UUID

Delete a segment › Headers

X-Organization-Id
​string · uuid · required

UUID of the organization (tenant) the request operates on.

Delete a segment › Responses

MarketingSegmentReferenceResource

id
​string · uuid
name
​string

List the recipients of a segment

GET
https://api.clienvy.io/employee/v1
/marketing-segments/{marketingSegment}/recipients

Returns who the segment reaches right now. With a mail type, who unsubscribed from that type is left out too, as a mailing of that type does.

List the recipients of a segment › path Parameters

marketingSegment
​string · uuid · required

The marketing segment UUID

List the recipients of a segment › query Parameters

marketing_mail_type_id
​string · uuid

Work it out for a mail of this type, see GET /marketing-mail-types.

search
​string

Only return contacts whose name, company or e-mail address contains this text.

page
​integer

Page number of the paginated result set.

per_page
​integer

Number of items per page. Defaults to the endpoint's own page size; capped at 500.

List the recipients of a segment › Headers

X-Organization-Id
​string · uuid · required

UUID of the organization (tenant) the request operates on.

List the recipients of a segment › Responses

Array of MarketingSegmentRecipientResource