Skip to content

Latest commit

 

History

History
274 lines (185 loc) · 7.08 KB

SegmentsApi.md

File metadata and controls

274 lines (185 loc) · 7.08 KB

ElasticEmail.SegmentsApi

All URIs are relative to https://api.elasticemail.com/v4

Method HTTP request Description
segmentsByNameDelete DELETE /segments/{name} Delete Segment
segmentsByNameGet GET /segments/{name} Load Segment
segmentsByNamePut PUT /segments/{name} Update Segment
segmentsGet GET /segments Load Segments
segmentsPost POST /segments Add Segment

segmentsByNameDelete

segmentsByNameDelete(name)

Delete Segment

Delete an existing segment. Required Access Level: ModifyContacts

Example

import ElasticEmail from '@elasticemail/elasticemail-client';
let defaultClient = ElasticEmail.ApiClient.instance;
// Configure API key authorization: apikey
let apikey = defaultClient.authentications['apikey'];
apikey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apikey.apiKeyPrefix = 'Token';

let apiInstance = new ElasticEmail.SegmentsApi();
let name = "My Segment 1"; // String | Name of your segment.
apiInstance.segmentsByNameDelete(name, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully.');
  }
});

Parameters

Name Type Description Notes
name String Name of your segment.

Return type

null (empty response body)

Authorization

apikey

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

segmentsByNameGet

Segment segmentsByNameGet(name)

Load Segment

Returns details for the specified segment. Required Access Level: ViewContacts

Example

import ElasticEmail from '@elasticemail/elasticemail-client';
let defaultClient = ElasticEmail.ApiClient.instance;
// Configure API key authorization: apikey
let apikey = defaultClient.authentications['apikey'];
apikey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apikey.apiKeyPrefix = 'Token';

let apiInstance = new ElasticEmail.SegmentsApi();
let name = "name_example"; // String | Name of the segment you want to load. Will load all contacts if the 'All Contacts' name has been provided
apiInstance.segmentsByNameGet(name, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
name String Name of the segment you want to load. Will load all contacts if the 'All Contacts' name has been provided

Return type

Segment

Authorization

apikey

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

segmentsByNamePut

Segment segmentsByNamePut(name, segmentPayload)

Update Segment

Rename or change RULE for your segment. Required Access Level: ModifyContacts

Example

import ElasticEmail from '@elasticemail/elasticemail-client';
let defaultClient = ElasticEmail.ApiClient.instance;
// Configure API key authorization: apikey
let apikey = defaultClient.authentications['apikey'];
apikey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apikey.apiKeyPrefix = 'Token';

let apiInstance = new ElasticEmail.SegmentsApi();
let name = "My Segment 1"; // String | Name of your segment.
let segmentPayload = new ElasticEmail.SegmentPayload(); // SegmentPayload | 
apiInstance.segmentsByNamePut(name, segmentPayload, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
name String Name of your segment.
segmentPayload SegmentPayload

Return type

Segment

Authorization

apikey

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

segmentsGet

[Segment] segmentsGet(opts)

Load Segments

Returns a list of all your available Segments. Required Access Level: ViewContacts

Example

import ElasticEmail from '@elasticemail/elasticemail-client';
let defaultClient = ElasticEmail.ApiClient.instance;
// Configure API key authorization: apikey
let apikey = defaultClient.authentications['apikey'];
apikey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apikey.apiKeyPrefix = 'Token';

let apiInstance = new ElasticEmail.SegmentsApi();
let opts = {
  'limit': 100, // Number | Maximum number of returned items.
  'offset': 20 // Number | How many items should be returned ahead.
};
apiInstance.segmentsGet(opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
limit Number Maximum number of returned items. [optional]
offset Number How many items should be returned ahead. [optional]

Return type

[Segment]

Authorization

apikey

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

segmentsPost

Segment segmentsPost(segmentPayload)

Add Segment

Add a new segment, based on specified RULE. Required Access Level: ModifyContacts

Example

import ElasticEmail from '@elasticemail/elasticemail-client';
let defaultClient = ElasticEmail.ApiClient.instance;
// Configure API key authorization: apikey
let apikey = defaultClient.authentications['apikey'];
apikey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apikey.apiKeyPrefix = 'Token';

let apiInstance = new ElasticEmail.SegmentsApi();
let segmentPayload = new ElasticEmail.SegmentPayload(); // SegmentPayload | 
apiInstance.segmentsPost(segmentPayload, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
segmentPayload SegmentPayload

Return type

Segment

Authorization

apikey

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json