sendx-javascript-sdk
v2.0.0
Published
# SendX REST API Documentation ## π Introduction The SendX API is organized around REST principles. Our API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response cod
Readme
SendX JavaScript SDK
π Introduction
The SendX API is organized around REST principles. Our API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
Key Features:
- π Security: Team-based authentication with optional member-level access
- π― Resource-Oriented: RESTful design with clear resource boundaries
- π Rich Data Models: Three-layer model system (Input/Output/Internal)
- π Relationships: Automatic prefix handling for resource relationships
- π Scalable: Built for high-volume email marketing operations
ποΈ Architecture Overview
SendX uses a three-layer model architecture:
- Input Models (
RestE*): For API requests - Output Models (
RestR*): For API responses with prefixed IDs - Internal Models: Core business logic (not exposed in API)
π Security & Authentication
SendX uses API key authentication:
Team API Key
X-Team-ApiKey: YOUR_TEAM_API_KEY- Required for all requests
- Team-level access to resources
- Available in SendX Settings β Team API Key
π Encrypted ID System
SendX uses encrypted IDs for security and better developer experience:
- Internal IDs: Sequential integers (not exposed)
- Encrypted IDs: 22-character alphanumeric strings
- Prefixed IDs: Resource-type prefixes in API responses (
contact_<22-char-id>)
ID Format
All resource IDs follow this pattern:
<resource_prefix>_<22_character_alphanumeric_string>Example:
{
"id": "contact_BnKjkbBBS500CoBCP0oChQ",
"lists": ["list_OcuxJHdiAvujmwQVJfd3ss", "list_0tOFLp5RgV7s3LNiHrjGYs"],
"tags": ["tag_UhsDkjL772Qbj5lWtT62VK", "tag_fL7t9lsnZ9swvx2HrtQ9wM"]
}π Resource Prefixes
| Resource | Prefix | Example |
|----------|--------|---------|
| Contact | contact_ | contact_BnKjkbBBS500CoBCP0oChQ |
| Campaign | campaign_ | campaign_LUE9BTxmksSmqHWbh96zsn |
| List | list_ | list_OcuxJHdiAvujmwQVJfd3ss |
| Tag | tag_ | tag_UhsDkjL772Qbj5lWtT62VK |
| Sender | sender_ | sender_4vK3WFhMgvOwUNyaL4QxCD |
| Template | template_ | template_f3lJvTEhSjKGVb5Lwc5SWS |
| Custom Field | field_ | field_MnuqBAG2NPLm7PZMWbjQxt |
| Webhook | webhook_ | webhook_9l154iiXlZoPo7vngmamee |
| Post | post_ | post_XyZ123aBc456DeF789GhI |
| Post Category | post_category_ | post_category_YzS1wOU20yw87UUHKxMzwn |
| Post Tag | post_tag_ | post_tag_123XyZ456AbC |
| Member | member_ | member_JkL012MnO345PqR678 |
π― Best Practices
Error Handling
- Always check status codes: 2xx = success, 4xx = client error, 5xx = server error
- Read error messages: Descriptive messages help debug issues
- Handle rate limits: Respect API rate limits for optimal performance
Data Validation
- Email format: Must be valid email addresses
- Required fields: Check documentation for mandatory fields
- Field lengths: Respect maximum length constraints
Performance
- Pagination: Use offset/limit for large datasets
- Batch operations: Process multiple items when supported
- Caching: Cache responses when appropriate
π οΈ SDKs & Integration
Official SDKs available for:
π Support
Need help? Contact us:
- π¬ Website Chat: Available on sendx.io
- π§ Email: [email protected]
- π Documentation: Full guides at help.sendx.io
API Endpoint: https://api.sendx.io/api/v1/rest
<img src="https://run.pstmn.io/button.svg" alt="Run In Postman" style="width: 128px; height: 32px;">
Installation
For Node.js
npm
To install it via npm:
npm install sendx-javascript-sdk Getting Started
Please follow the installation instruction and execute the following JS code:
import sendx from 'sendx-javascript-sdk';
let defaultClient = sendx.ApiClient.instance;
// Configure API key authorization: TeamApiKey
var TeamApiKey = defaultClient.authentications['TeamApiKey'];
TeamApiKey.apiKey = "YOUR API KEY"
let apiInstance = new sendx.ContactApi(); // ContactApi |
let contactRequest = new sendx.ContactRequest(); // ContactRequest |
contactRequest.email = "[email protected]";
contactRequest.firstName = "Jane";
contactRequest.lastName = "Doe";
contactRequest.company = "Tech Solutions Inc.";
contactRequest.lastTrackedIp = "34.94.159.140";
contactRequest.customFields = { "1231nfenife213": "VIP", "1434bife23bfij32": "Special Offer Subscriber" };
contactRequest.lists = ["234b324bjed32", "234bij3e2eyv3v2i"];
contactRequest.tags = ["234bijn2ei2jbu4", "2342bijhb2ijneni"];
apiInstance.createContact(contactRequest).then((data) => {
console.log('API called successfully. Contact created: ' + JSON.stringify(data, null, 2));
}, (error) => {
console.error(error);
});
Documentation for API Endpoints
All URIs are relative to https://api.sendx.io/api/v1/rest
Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- sendx.CampaignApi | createCampaign | POST /campaign | Create campaign sendx.CampaignApi | deleteCampaign | DELETE /campaign/{identifier} | Delete campaign sendx.CampaignApi | getAllCampaigns | GET /campaign | Get all campaigns sendx.CampaignApi | getCampaign | GET /campaign/{identifier} | Get campaign by ID sendx.ContactApi | createContact | POST /contact | Create a new contact sendx.ContactApi | deleteContact | DELETE /contact/{identifier} | Delete contact sendx.ContactApi | getAllContacts | GET /contact | Get all contacts sendx.ContactApi | getContact | GET /contact/{identifier} | Get contact by ID sendx.ContactApi | unsubscribeContact | POST /contact/unsubscribe/{identifier} | Unsubscribe contact sendx.ContactApi | updateContact | PUT /contact/{identifier} | Update contact sendx.CustomFieldApi | createCustomField | POST /customfield | Create custom field sendx.CustomFieldApi | deleteCustomField | DELETE /customfield/{identifier} | Delete custom field sendx.CustomFieldApi | getAllCustomFields | GET /customfield | Get all custom fields sendx.CustomFieldApi | getCustomField | GET /customfield/{identifier} | Get custom field by ID sendx.CustomFieldApi | updateCustomField | PUT /customfield/{identifier} | Update custom field sendx.EmailSendingApi | sendEmail | POST /send/email | Send transactional email sendx.EmailSendingApi | sendEmailWithTemplate | POST /send/template | Send email using template sendx.EventApi | eventsCustomPostbackGet | GET /events/custom/postback | Custom Event Postback URL sendx.EventApi | eventsRevenuePostbackGet | GET /events/revenue/postback | Revenue Event Postback URL sendx.EventsApi | trackCustomEvent | POST /events/custom | Track custom event sendx.EventsApi | trackRevenueEvent | POST /events/revenue | Track revenue event sendx.ListApi | createList | POST /list | Create list sendx.ListApi | deleteList | DELETE /list/{identifier} | Delete list sendx.ListApi | getAllLists | GET /list | Get all lists sendx.ListApi | getList | GET /list/{identifier} | Get list by ID sendx.ListApi | updateList | PUT /list/{identifier} | Update list sendx.PostApi | createPost | POST /post | Create blog post sendx.PostApi | deletePost | DELETE /post/{identifier} | Delete post sendx.PostApi | getAllPosts | GET /post | Get all posts sendx.PostApi | getPost | GET /post/{identifier} | Get post by ID sendx.PostApi | updatePost | PUT /post/{identifier} | Update post sendx.PostCategoryApi | createPostCategory | POST /post/category | Create post category sendx.PostCategoryApi | deletePostCategory | DELETE /post/category/{identifier} | Delete post category sendx.PostCategoryApi | getAllPostCategories | GET /post/category | Get all post categories sendx.PostCategoryApi | getPostCategory | GET /post/category/{identifier} | Get post category by ID sendx.PostCategoryApi | updatePostCategory | PUT /post/category/{identifier} | Update post category sendx.PostTagApi | createPostTag | POST /post/tag | Create post tag sendx.PostTagApi | deletePostTag | DELETE /post/tag/{identifier} | Delete post tag sendx.PostTagApi | getAllPostTags | GET /post/tag | Get all post tags sendx.PostTagApi | getPostTag | GET /post/tag/{identifier} | Get post tag by ID sendx.PostTagApi | updatePostTag | PUT /post/tag/{identifier} | Update post tag sendx.ReportApi | getCampaignReport | GET /report/campaign/{identifier} | Get campaign report sendx.SenderApi | createSender | POST /sender | Create sender sendx.SenderApi | getAllSenders | GET /sender | Get all senders sendx.TagApi | createTag | POST /tag | Create tag sendx.TagApi | deleteTag | DELETE /tag/{identifier} | Delete tag sendx.TagApi | getAllTags | GET /tag | Get all tags sendx.TagApi | getTag | GET /tag/{identifier} | Get tag by ID sendx.TagApi | updateTag | PUT /tag/{identifier} | Update tag sendx.TeamMemberApi | getAllTeamMembers | GET /team/member | Get all team members sendx.TeamMemberApi | getTeamMember | GET /team/member/{identifier} | Get a team member by ID sendx.TemplateApi | createEmailTemplate | POST /template/email | Create email template sendx.TemplateApi | deleteEmailTemplate | DELETE /template/email/{identifier} | Delete template sendx.TemplateApi | getAllEmailTemplates | GET /template/email | Get all templates sendx.TemplateApi | getEmailTemplate | GET /template/email/{identifier} | Get template by ID sendx.TemplateApi | updateEmailTemplate | PUT /template/email/{identifier} | Update template sendx.TrackingApi | identifyContact | POST /contact/identify | Identify contact sendx.TrackingApi | trackContact | POST /contact/track | Track contact sendx.WebhookApi | createWebhook | POST /webhook | Create webhook sendx.WebhookApi | deleteWebhook | DELETE /webhook/{identifier} | Delete webhook sendx.WebhookApi | getAllWebhooks | GET /webhook | Get all webhooks sendx.WebhookApi | getWebhook | GET /webhook/{identifier} | Get webhook by ID sendx.WebhookApi | updateWebhook | PUT /webhook/{identifier} | Update webhook
Documentation for Models
- sendx.CustomEventRequest
- sendx.DeleteResponse
- sendx.ErrorResponse
- sendx.EventResponse
- sendx.EventsRevenuePostbackGet200Response
- sendx.EventsRevenuePostbackGet400Response
- sendx.EventsRevenuePostbackGet500Response
- sendx.IdentifyRequest
- sendx.IdentifyResponse
- sendx.LinkStat
- sendx.MessageResponse
- sendx.PostbackResponse
- sendx.RestECampaign
- sendx.RestEContact
- sendx.RestECustomField
- sendx.RestEList
- sendx.RestEPost
- sendx.RestEPostCategory
- sendx.RestEPostTag
- sendx.RestESender
- sendx.RestETag
- sendx.RestETemplate
- sendx.RestEWebhook
- sendx.RestRCampaign
- sendx.RestRContact
- sendx.RestRCustomField
- sendx.RestRList
- sendx.RestRMember
- sendx.RestRPost
- sendx.RestRPostCategory
- sendx.RestRPostTag
- sendx.RestRSender
- sendx.RestRTag
- sendx.RestRTemplate
- sendx.RestRWebhook
- sendx.RestReportData
- sendx.RevenueEventRequest
- sendx.TemplateEmailMessage
- sendx.TrackRequest
- sendx.TrackResponse
- sendx.WebhookObject
- sendx.XAttachment
- sendx.XEmailMessage
- sendx.XEmailResponse
- sendx.XFrom
- sendx.XReplyTo
- sendx.XTo
Documentation for Authorization
Authentication schemes defined for the API:
TeamApiKey
- Type: API key
- API key parameter name: X-Team-ApiKey
- Location: HTTP header
