Clienvy API documentation

Marketing mailings

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 a mailing. A mailing is an HTML mail of one mail type, sent once to one or more segments of relations, right away or at a set moment; an address in several segments gets it once. The usual way: create it, set the HTML (it must contain {{mailing.unsubscribe_url}} unless the mail type is the system type), look at the preview, send a test mail, then send or schedule it.


List mailings

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

Returns a paginated list of mailings, newest first.

List mailings › query Parameters

search
​string

Only return mailings whose name contains this text.

statuses
​string

Only return mailings in these statuses. Accepts a comma-separated list of concept, scheduled, sending, sent.

marketing_segment_ids
​string

Only return mailings sent to these segments. Accepts a comma-separated list of UUIDs.

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 mailings › Headers

X-Organization-Id
​string · uuid · required

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

List mailings › Responses

Array of MarketingMailingListResource

​object

Create a mailing

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

Creates a concept. Without html the mail starts empty.

Create a mailing › Headers

X-Organization-Id
​string · uuid · required

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

Create a mailing › Request Body

name
​string · maxLength: 128 · required

Internal name, the recipients never see it.

marketing_mail_type_id
​string · uuid · required

UUID of the mail type, see GET /marketing-mail-types. Recipients who unsubscribed from this type do not get it; the system type is for mail about running the business only, which nobody can unsubscribe from.

​array

UUIDs of the segments it goes to. Can be set later, it needs at least one to be sent.

mail_identity_id
​string · uuid

UUID of the mail identity it comes from. Defaults to the default mail identity of the organization.

subject
​string · maxLength: 255

Subject line. Variables such as {{contact.first_name}} are filled in per recipient.

html
​string

The complete HTML document. Variables: {{contact.*}}, {{company.*}}, {{organization.*}}, {{image.<file-id>}} for an image in file_ids, {{mailing.unsubscribe_url}}, which is required unless the mail type is the system type, and {{mailing.view_online_url}}, the mail as the recipient got it in a browser.

html_file_id
​string · uuid

Instead of html: an uploaded HTML file (html or htm, up to 500 KB, see POST /files) whose content becomes the HTML, so a long document does not have to be sent along as text.

​array

UUIDs of uploaded images (jpg, png or gif, see POST /files) the HTML places as {{image.<file-id>}}, so they need no hosting elsewhere. The HTML may only place images in this list.

track_opens
​boolean

Measure who opens it. Defaults to true.

track_clicks
​boolean

Measure who clicks which link. Defaults to true.

utm_source
​string · maxLength: 255

Added as utm_source behind every link, also when clicks are not measured. Empty takes utm_defaults when it goes out.

utm_medium
​string · maxLength: 255

Added as utm_medium behind every link. Empty takes utm_defaults when it goes out.

utm_campaign
​string · maxLength: 255

Added as utm_campaign behind every link. Empty takes utm_defaults (the name of the mailing in snake case) when it goes out.

Create a mailing › Responses

MarketingMailingResource

id
​string · uuid
name
​string
status
​MarketingMailingStatus · enum
concept
Being written, can still change.
scheduled
Waiting for its moment; can go back to concept until then.
sending
Recipients are recorded and the mails are going out.
sent
Every recipient had its turn. Only the name can change now.
Enum values:
concept
scheduled
sending
sent
​MarketingSegmentReferenceResource[]

Who it goes to. A segment cannot be deleted while a mailing uses it.

​MarketingMailTypeReferenceResource
scheduled_at
​string | null · date-time
sent_at
​string | null · date-time
recipient_count
​integer

Who it goes to: until it goes out, who its segments reach right now for its mail type; afterwards the recipients recorded when it was sent.

open_rate
​number | null

The share of the recipients that opened it, from 0 to 1. Null before it was sent.

created_at
​string · date-time
​MailIdentityReferenceResource | null

Who the mail comes from. Null once the mail identity was deleted.

subject
​string
html
​string

The complete HTML document. Must contain {{mailing.unsubscribe_url}} before it can be sent, unless the mail type is the system type.

​FileResource[]

The images the HTML may place as {{image.<file-id>}}.

track_opens
​boolean
track_clicks
​boolean
utm_source
​string | null

Behind every link, also when clicks are not measured. Null takes utm_defaults when it goes out; once it went out, what it went out with.

utm_medium
​string | null
utm_campaign
​string | null
​object

What an empty utm parameter becomes when it goes out.

​object | null

What still stands in the way of sending, keyed by what it is about: subject, html (the unsubscribe link), mail_identity_id, marketing_segment_ids or status. Empty when it is ready to go; null once it goes out.

​MarketingMailingStatisticsResource | null

The numbers so far, once it is being sent; null before that.

updated_at
​string · date-time

Get a mailing

GET
https://api.clienvy.io/employee/v1
/marketing-mailings/{marketingMailing}

Returns a mailing with its sender, subject and HTML, and its numbers once it is being sent. The mail as one recipient gets it is GET marketing-mailings/{marketing_mailing}/preview.

Get a mailing › path Parameters

marketingMailing
​string · uuid · required

The marketing mailing UUID

Get a mailing › Headers

X-Organization-Id
​string · uuid · required

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

Get a mailing › Responses

MarketingMailingResource

id
​string · uuid
name
​string
status
​MarketingMailingStatus · enum
concept
Being written, can still change.
scheduled
Waiting for its moment; can go back to concept until then.
sending
Recipients are recorded and the mails are going out.
sent
Every recipient had its turn. Only the name can change now.
Enum values:
concept
scheduled
sending
sent
​MarketingSegmentReferenceResource[]

Who it goes to. A segment cannot be deleted while a mailing uses it.

​MarketingMailTypeReferenceResource
scheduled_at
​string | null · date-time
sent_at
​string | null · date-time
recipient_count
​integer

Who it goes to: until it goes out, who its segments reach right now for its mail type; afterwards the recipients recorded when it was sent.

open_rate
​number | null

The share of the recipients that opened it, from 0 to 1. Null before it was sent.

created_at
​string · date-time
​MailIdentityReferenceResource | null

Who the mail comes from. Null once the mail identity was deleted.

subject
​string
html
​string

The complete HTML document. Must contain {{mailing.unsubscribe_url}} before it can be sent, unless the mail type is the system type.

​FileResource[]

The images the HTML may place as {{image.<file-id>}}.

track_opens
​boolean
track_clicks
​boolean
utm_source
​string | null

Behind every link, also when clicks are not measured. Null takes utm_defaults when it goes out; once it went out, what it went out with.

utm_medium
​string | null
utm_campaign
​string | null
​object

What an empty utm parameter becomes when it goes out.

​object | null

What still stands in the way of sending, keyed by what it is about: subject, html (the unsubscribe link), mail_identity_id, marketing_segment_ids or status. Empty when it is ready to go; null once it goes out.

​MarketingMailingStatisticsResource | null

The numbers so far, once it is being sent; null before that.

updated_at
​string · date-time

Update a mailing

PUT
https://api.clienvy.io/employee/v1
/marketing-mailings/{marketingMailing}

Only the fields present in the request change. Once a mailing is scheduled or goes out, only the name can change; take a scheduled one back first with unschedule.

Update a mailing › path Parameters

marketingMailing
​string · uuid · required

The marketing mailing UUID

Update a mailing › Headers

X-Organization-Id
​string · uuid · required

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

Update a mailing › Request Body

name
​string · maxLength: 128
​array

Replaces the segments it goes to.

marketing_mail_type_id
​string · uuid
mail_identity_id
​string · uuid
subject
​string · maxLength: 255
html
​string

The complete HTML document, see create.

html_file_id
​string · uuid

Instead of html: an uploaded HTML file whose content replaces the HTML, see create.

​array

Replaces the images, see create. An image the HTML still places cannot be taken away.

track_opens
​boolean
track_clicks
​boolean
utm_source
​string · maxLength: 255

See create.

utm_medium
​string · maxLength: 255

See create.

utm_campaign
​string · maxLength: 255

See create.

Update a mailing › Responses

MarketingMailingResource

id
​string · uuid
name
​string
status
​MarketingMailingStatus · enum
concept
Being written, can still change.
scheduled
Waiting for its moment; can go back to concept until then.
sending
Recipients are recorded and the mails are going out.
sent
Every recipient had its turn. Only the name can change now.
Enum values:
concept
scheduled
sending
sent
​MarketingSegmentReferenceResource[]

Who it goes to. A segment cannot be deleted while a mailing uses it.

​MarketingMailTypeReferenceResource
scheduled_at
​string | null · date-time
sent_at
​string | null · date-time
recipient_count
​integer

Who it goes to: until it goes out, who its segments reach right now for its mail type; afterwards the recipients recorded when it was sent.

open_rate
​number | null

The share of the recipients that opened it, from 0 to 1. Null before it was sent.

created_at
​string · date-time
​MailIdentityReferenceResource | null

Who the mail comes from. Null once the mail identity was deleted.

subject
​string
html
​string

The complete HTML document. Must contain {{mailing.unsubscribe_url}} before it can be sent, unless the mail type is the system type.

​FileResource[]

The images the HTML may place as {{image.<file-id>}}.

track_opens
​boolean
track_clicks
​boolean
utm_source
​string | null

Behind every link, also when clicks are not measured. Null takes utm_defaults when it goes out; once it went out, what it went out with.

utm_medium
​string | null
utm_campaign
​string | null
​object

What an empty utm parameter becomes when it goes out.

​object | null

What still stands in the way of sending, keyed by what it is about: subject, html (the unsubscribe link), mail_identity_id, marketing_segment_ids or status. Empty when it is ready to go; null once it goes out.

​MarketingMailingStatisticsResource | null

The numbers so far, once it is being sent; null before that.

updated_at
​string · date-time

Delete a mailing

DELETE
https://api.clienvy.io/employee/v1
/marketing-mailings/{marketingMailing}

Only a concept or a scheduled mailing can be deleted.

Delete a mailing › path Parameters

marketingMailing
​string · uuid · required

The marketing mailing UUID

Delete a mailing › Headers

X-Organization-Id
​string · uuid · required

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

Delete a mailing › Responses

MarketingMailingReferenceResource

id
​string · uuid
name
​string
status
​MarketingMailingStatus · enum
concept
Being written, can still change.
scheduled
Waiting for its moment; can go back to concept until then.
sending
Recipients are recorded and the mails are going out.
sent
Every recipient had its turn. Only the name can change now.
Enum values:
concept
scheduled
sending
sent

Duplicate a mailing

POST
https://api.clienvy.io/employee/v1
/marketing-mailings/{marketingMailing}/duplicate

Creates a concept with the same mail and segments, to build the next mailing on.

Duplicate a mailing › path Parameters

marketingMailing
​string · uuid · required

The marketing mailing UUID

Duplicate a mailing › Headers

X-Organization-Id
​string · uuid · required

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

Duplicate a mailing › Responses

MarketingMailingResource

id
​string · uuid
name
​string
status
​MarketingMailingStatus · enum
concept
Being written, can still change.
scheduled
Waiting for its moment; can go back to concept until then.
sending
Recipients are recorded and the mails are going out.
sent
Every recipient had its turn. Only the name can change now.
Enum values:
concept
scheduled
sending
sent
​MarketingSegmentReferenceResource[]

Who it goes to. A segment cannot be deleted while a mailing uses it.

​MarketingMailTypeReferenceResource
scheduled_at
​string | null · date-time
sent_at
​string | null · date-time
recipient_count
​integer

Who it goes to: until it goes out, who its segments reach right now for its mail type; afterwards the recipients recorded when it was sent.

open_rate
​number | null

The share of the recipients that opened it, from 0 to 1. Null before it was sent.

created_at
​string · date-time
​MailIdentityReferenceResource | null

Who the mail comes from. Null once the mail identity was deleted.

subject
​string
html
​string

The complete HTML document. Must contain {{mailing.unsubscribe_url}} before it can be sent, unless the mail type is the system type.

​FileResource[]

The images the HTML may place as {{image.<file-id>}}.

track_opens
​boolean
track_clicks
​boolean
utm_source
​string | null

Behind every link, also when clicks are not measured. Null takes utm_defaults when it goes out; once it went out, what it went out with.

utm_medium
​string | null
utm_campaign
​string | null
​object

What an empty utm parameter becomes when it goes out.

​object | null

What still stands in the way of sending, keyed by what it is about: subject, html (the unsubscribe link), mail_identity_id, marketing_segment_ids or status. Empty when it is ready to go; null once it goes out.

​MarketingMailingStatisticsResource | null

The numbers so far, once it is being sent; null before that.

updated_at
​string · date-time

Preview a mailing

GET
https://api.clienvy.io/employee/v1
/marketing-mailings/{marketingMailing}/preview

Returns the subject and HTML as one recipient gets them, with their variables filled in, and who that is: the recipient asked for, or else the first recipient. Pick one with preview-recipients (before sending) or recipients (after). The recipient is null when there is nobody to fill it in for.

Preview a mailing › path Parameters

marketingMailing
​string · uuid · required

The marketing mailing UUID

Preview a mailing › query Parameters

recipient_key
​string

The recipient_key of the recipient to fill the preview in for, from preview-recipients or recipients.

Preview a mailing › Headers

X-Organization-Id
​string · uuid · required

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

Preview a mailing › Responses

MarketingMailingPreviewResource

subject
​string
html
​string
recipient
​object | null

Who it is filled in for. Null when there is nobody to fill it in for.


List who a preview can be shown for

GET
https://api.clienvy.io/employee/v1
/marketing-mailings/{marketingMailing}/preview-recipients

Returns the recipients of its segments for its mail type, to pick the contact a preview or test is filled in for.

List who a preview can be shown for › path Parameters

marketingMailing
​string · uuid · required

The marketing mailing UUID

List who a preview can be shown for › query Parameters

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 who a preview can be shown for › Headers

X-Organization-Id
​string · uuid · required

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

List who a preview can be shown for › Responses

Array of MarketingSegmentRecipientResource

​object

Send a test

POST
https://api.clienvy.io/employee/v1
/marketing-mailings/{marketingMailing}/send-test

Sends the saved mailing to one address, filled in as one recipient, without measuring anything. The unsubscribe link in a test goes nowhere.

Send a test › path Parameters

marketingMailing
​string · uuid · required

The marketing mailing UUID

Send a test › Headers

X-Organization-Id
​string · uuid · required

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

Send a test › Request Body

email
​string · email

Where the test goes. Defaults to the e-mail address of the employee.

recipient_key
​string

The recipient_key of the recipient to fill the variables in for, from preview-recipients or recipients. Defaults to the first recipient.

Send a test › Responses

​array
No data returned

Send or schedule a mailing

POST
https://api.clienvy.io/employee/v1
/marketing-mailings/{marketingMailing}/send

Sends the mailing now, or at scheduled_at when that lies ahead. Refused with the reasons when it is not ready: no segments or nobody in them, no subject, no unsubscribe link in the HTML (unless the mail type is the system type), or a sender whose domain is not verified. When it goes out, the recipients are recorded; who joins a segment afterwards does not get it.

Send or schedule a mailing › path Parameters

marketingMailing
​string · uuid · required

The marketing mailing UUID

Send or schedule a mailing › Headers

X-Organization-Id
​string · uuid · required

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

Send or schedule a mailing › Request Body

scheduled_at
​string · date-time

When to send it (Y-m-d H:i, in the time zone of the organization), in the future. Leave it out to send it now.

Send or schedule a mailing › Responses

MarketingMailingResource

id
​string · uuid
name
​string
status
​MarketingMailingStatus · enum
concept
Being written, can still change.
scheduled
Waiting for its moment; can go back to concept until then.
sending
Recipients are recorded and the mails are going out.
sent
Every recipient had its turn. Only the name can change now.
Enum values:
concept
scheduled
sending
sent
​MarketingSegmentReferenceResource[]

Who it goes to. A segment cannot be deleted while a mailing uses it.

​MarketingMailTypeReferenceResource
scheduled_at
​string | null · date-time
sent_at
​string | null · date-time
recipient_count
​integer

Who it goes to: until it goes out, who its segments reach right now for its mail type; afterwards the recipients recorded when it was sent.

open_rate
​number | null

The share of the recipients that opened it, from 0 to 1. Null before it was sent.

created_at
​string · date-time
​MailIdentityReferenceResource | null

Who the mail comes from. Null once the mail identity was deleted.

subject
​string
html
​string

The complete HTML document. Must contain {{mailing.unsubscribe_url}} before it can be sent, unless the mail type is the system type.

​FileResource[]

The images the HTML may place as {{image.<file-id>}}.

track_opens
​boolean
track_clicks
​boolean
utm_source
​string | null

Behind every link, also when clicks are not measured. Null takes utm_defaults when it goes out; once it went out, what it went out with.

utm_medium
​string | null
utm_campaign
​string | null
​object

What an empty utm parameter becomes when it goes out.

​object | null

What still stands in the way of sending, keyed by what it is about: subject, html (the unsubscribe link), mail_identity_id, marketing_segment_ids or status. Empty when it is ready to go; null once it goes out.

​MarketingMailingStatisticsResource | null

The numbers so far, once it is being sent; null before that.

updated_at
​string · date-time

Take a scheduled mailing back

POST
https://api.clienvy.io/employee/v1
/marketing-mailings/{marketingMailing}/unschedule

A scheduled mailing goes back to concept, so it can be changed again.

Take a scheduled mailing back › path Parameters

marketingMailing
​string · uuid · required

The marketing mailing UUID

Take a scheduled mailing back › Headers

X-Organization-Id
​string · uuid · required

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

Take a scheduled mailing back › Responses

MarketingMailingResource

id
​string · uuid
name
​string
status
​MarketingMailingStatus · enum
concept
Being written, can still change.
scheduled
Waiting for its moment; can go back to concept until then.
sending
Recipients are recorded and the mails are going out.
sent
Every recipient had its turn. Only the name can change now.
Enum values:
concept
scheduled
sending
sent
​MarketingSegmentReferenceResource[]

Who it goes to. A segment cannot be deleted while a mailing uses it.

​MarketingMailTypeReferenceResource
scheduled_at
​string | null · date-time
sent_at
​string | null · date-time
recipient_count
​integer

Who it goes to: until it goes out, who its segments reach right now for its mail type; afterwards the recipients recorded when it was sent.

open_rate
​number | null

The share of the recipients that opened it, from 0 to 1. Null before it was sent.

created_at
​string · date-time
​MailIdentityReferenceResource | null

Who the mail comes from. Null once the mail identity was deleted.

subject
​string
html
​string

The complete HTML document. Must contain {{mailing.unsubscribe_url}} before it can be sent, unless the mail type is the system type.

​FileResource[]

The images the HTML may place as {{image.<file-id>}}.

track_opens
​boolean
track_clicks
​boolean
utm_source
​string | null

Behind every link, also when clicks are not measured. Null takes utm_defaults when it goes out; once it went out, what it went out with.

utm_medium
​string | null
utm_campaign
​string | null
​object

What an empty utm parameter becomes when it goes out.

​object | null

What still stands in the way of sending, keyed by what it is about: subject, html (the unsubscribe link), mail_identity_id, marketing_segment_ids or status. Empty when it is ready to go; null once it goes out.

​MarketingMailingStatisticsResource | null

The numbers so far, once it is being sent; null before that.

updated_at
​string · date-time

List the recipients of a mailing

GET
https://api.clienvy.io/employee/v1
/marketing-mailings/{marketingMailing}/recipients

Returns who a mailing was sent to, with per recipient whether it arrived, when it was first opened and how often links were clicked. Only filled once the mailing goes out.

List the recipients of a mailing › path Parameters

marketingMailing
​string · uuid · required

The marketing mailing UUID

List the recipients of a mailing › query Parameters

search
​string

Only return recipients whose name or e-mail address contains this text.

statuses
​string

Only return recipients in these statuses. Accepts a comma-separated list of queued, sent, delivered, failed.

opened
​boolean

Only return recipients who opened it.

clicked
​boolean

Only return recipients who clicked a link.

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 mailing › Headers

X-Organization-Id
​string · uuid · required

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

List the recipients of a mailing › Responses

Array of MarketingMailingRecipientListResource

​object

Get one recipient of a mailing

GET
https://api.clienvy.io/employee/v1
/marketing-mailings/{marketingMailing}/recipients/{marketingMailRecipient}

Returns what happened to the mail for one recipient, with every click on a link and when.

Get one recipient of a mailing › path Parameters

marketingMailing
​string · uuid · required

The marketing mailing UUID

marketingMailRecipient
​string · uuid · required

The marketing mail recipient UUID

Get one recipient of a mailing › Headers

X-Organization-Id
​string · uuid · required

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

Get one recipient of a mailing › Responses

MarketingMailingRecipientResource

id
​string · uuid
recipient_key
​string

The recipient as it got the mail, to pick a preview or test mail with.

name
​string
email
​string
status
​MailDeliveryStatus · enum

Where the mail to one recipient stands, for marketing mail and every other mail alike. Opened and clicked are not a status: marketing mail keeps them as moments and counts next to it, because a delivered mail can be opened and clicked many times.

queued
Recorded, waiting for its turn.
sent
Handed to the mail provider.
delivered
The receiving server accepted it.
failed
Not delivered, see the failure reason.
Enum values:
queued
sent
delivered
failed
failure_reason
​string | null

Why it failed, in the words of the mail provider. Null when it did not fail.

sent_at
​string | null · date-time
delivered_at
​string | null · date-time
first_opened_at
​string | null · date-time
open_count
​integer
first_clicked_at
​string | null · date-time
click_count
​integer
unsubscribed_at
​string | null · date-time
​ContactReferenceResource | null

The contact with this address now, found by the address. Null when no contact has it.