Skip to content

Latest commit

Β 

History

History
322 lines (210 loc) Β· 11.6 KB

File metadata and controls

322 lines (210 loc) Β· 11.6 KB

sendx.ContactApi

All URIs are relative to https://api.sendx.io/api/v1/rest

Method HTTP request Description
createContact POST /contact Create a new contact
deleteContact DELETE /contact/{identifier} Delete contact
getAllContacts GET /contact Get all contacts
getContact GET /contact/{identifier} Get contact by ID
unsubscribeContact POST /contact/unsubscribe/{identifier} Unsubscribe contact
updateContact PUT /contact/{identifier} Update contact

createContact

RestRContact createContact(restEContact)

Create a new contact

Creates a new contact in your SendX team with the provided information. 🎯 Key Features: - Email validation and duplicate detection - Automatic relationship building with lists and tags - Smart custom field handling πŸ“‹ Business Rules: - Email is mandatory and must be unique within the team - Last tracked IP is stored for analytics

Example

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

let apiInstance = new sendx.ContactApi();
let restEContact = {"email":"john.doe@example.com"}; // RestEContact | 
apiInstance.createContact(restEContact).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
restEContact RestEContact

Return type

RestRContact

Authorization

TeamApiKey

HTTP request headers

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

deleteContact

DeleteResponse deleteContact(identifier)

Delete contact

Soft deletes a contact from your team. 🎯 Key Features: - Soft delete preserves data - Removes from all lists - Cancels pending campaigns - Maintains historical data

Example

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

let apiInstance = new sendx.ContactApi();
let identifier = "contact_BnKjkbBBS500CoBCP0oChQ"; // String | Resource identifier with prefix (e.g., `contact_BnKjkbBBS500CoBCP0oChQ`)  **Format:** `<prefix>_<22-character-id>` 
apiInstance.deleteContact(identifier).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
identifier String Resource identifier with prefix (e.g., `contact_BnKjkbBBS500CoBCP0oChQ`) Format: `<prefix>_<22-character-id>`

Return type

DeleteResponse

Authorization

TeamApiKey

HTTP request headers

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

getAllContacts

[RestRContact] getAllContacts(opts)

Get all contacts

Retrieves a paginated list of all contacts in your team with optional filtering capabilities. 🎯 Key Features: - Pagination support with offset/limit - Search contacts by name or email - All relationships included (lists, tags, custom fields) - Prefixed IDs for easy integration πŸ“Š Pagination: - Default limit: 10 contacts per page - Maximum limit: 100 contacts per page - Use offset for page navigation πŸ” Search: - Searches across firstName, lastName, and email fields - Case-insensitive partial matching - Combine with pagination for large datasets

Example

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

let apiInstance = new sendx.ContactApi();
let opts = {
  'offset': 0, // Number | Number of records to skip for pagination.  **Examples:** - `0` - First page (default) - `50` - Second page (with limit=50) - `100` - Third page (with limit=50) 
  'limit': 10, // Number | Maximum number of records to return.  **Constraints:** - Minimum: 1 - Maximum: 100 - Default: 10 
  'search': "john" // String | Search term to filter contacts by name or email.  **Search Behavior:** - Searches firstName, lastName, and email fields - Case-insensitive partial matching - Minimum 2 characters for search  **Examples:** - `john` - Finds \"John Doe\", \"johnson@example.com\" - `@company.com` - Finds all emails from company.com - `smith` - Finds \"John Smith\", \"smith@email.com\" 
};
apiInstance.getAllContacts(opts).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
offset Number Number of records to skip for pagination. Examples: - `0` - First page (default) - `50` - Second page (with limit=50) - `100` - Third page (with limit=50) [optional] [default to 0]
limit Number Maximum number of records to return. Constraints: - Minimum: 1 - Maximum: 100 - Default: 10 [optional] [default to 50]
search String Search term to filter contacts by name or email. Search Behavior: - Searches firstName, lastName, and email fields - Case-insensitive partial matching - Minimum 2 characters for search Examples: - `john` - Finds &quot;John Doe&quot;, &quot;johnson@example.com&quot; - `@company.com` - Finds all emails from company.com - `smith` - Finds &quot;John Smith&quot;, &quot;smith@email.com&quot; [optional]

Return type

[RestRContact]

Authorization

TeamApiKey

HTTP request headers

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

getContact

RestRContact getContact(identifier)

Get contact by ID

Retrieves detailed information about a specific contact. 🎯 Key Features: - Returns complete contact profile - Includes all lists and tags - Shows custom field values - Provides engagement metrics

Example

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

let apiInstance = new sendx.ContactApi();
let identifier = "contact_BnKjkbBBS500CoBCP0oChQ"; // String | Resource identifier with prefix (e.g., `contact_BnKjkbBBS500CoBCP0oChQ`)  **Format:** `<prefix>_<22-character-id>` 
apiInstance.getContact(identifier).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
identifier String Resource identifier with prefix (e.g., `contact_BnKjkbBBS500CoBCP0oChQ`) Format: `<prefix>_<22-character-id>`

Return type

RestRContact

Authorization

TeamApiKey

HTTP request headers

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

unsubscribeContact

MessageResponse unsubscribeContact(identifier)

Unsubscribe contact

Unsubscribes a contact from all marketing communications. 🎯 Key Features: - Marks contact as unsubscribed - Removes from all active campaigns - Maintains unsubscribe history - Complies with anti-spam regulations

Example

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

let apiInstance = new sendx.ContactApi();
let identifier = "contact_BnKjkbBBS500CoBCP0oChQ"; // String | Resource identifier with prefix (e.g., `contact_BnKjkbBBS500CoBCP0oChQ`)  **Format:** `<prefix>_<22-character-id>` 
apiInstance.unsubscribeContact(identifier).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
identifier String Resource identifier with prefix (e.g., `contact_BnKjkbBBS500CoBCP0oChQ`) Format: `<prefix>_<22-character-id>`

Return type

MessageResponse

Authorization

TeamApiKey

HTTP request headers

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

updateContact

RestRContact updateContact(restEContact, identifier)

Update contact

Updates an existing contact's information. 🎯 Key Features: - Partial updates supported - Add/remove lists and tags - Update custom fields - Change email address

Example

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

let apiInstance = new sendx.ContactApi();
let restEContact = {"firstName":"Alexander","lastName":"Johnson-Smith","company":"New Enterprise Corp"}; // RestEContact | 
let identifier = "contact_BnKjkbBBS500CoBCP0oChQ"; // String | Resource identifier with prefix (e.g., `contact_BnKjkbBBS500CoBCP0oChQ`)  **Format:** `<prefix>_<22-character-id>` 
apiInstance.updateContact(restEContact, identifier).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
restEContact RestEContact
identifier String Resource identifier with prefix (e.g., `contact_BnKjkbBBS500CoBCP0oChQ`) Format: `<prefix>_<22-character-id>`

Return type

RestRContact

Authorization

TeamApiKey

HTTP request headers

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