Skip to content

sendx/sendx-python-sdk

Repository files navigation

SendX Python 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:

  1. Input Models (RestE*): For API requests
  2. Output Models (RestR*): For API responses with prefixed IDs
  3. 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: hello@sendx.io
  • πŸ“š Documentation: Full guides at help.sendx.io

API Endpoint: https://api.sendx.io/api/v1/rest

Requirements.

Python 3.9+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install sendx

(you may need to run pip with root permission: sudo pip install git+https://github.com/sendx/sendx-python-sdk.git)

Then import the package:

import sendx_python_sdk

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

import sendx_python_sdk
from sendx_python_sdk.models.contact_request import ContactRequest
from sendx_python_sdk.models.response import Response
from sendx_python_sdk.rest import ApiException
from pprint import pprint


configuration = sendx_python_sdk.Configuration()

# Configure API key authorization: TeamApiKey
configuration.api_key['TeamApiKey'] = os.environ["API_KEY"]

# Enter a context with an instance of the API client
with sendx_python_sdk.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = sendx_python_sdk.ContactApi(api_client)
    contact_request = sendx_python_sdk.ContactRequest() # ContactRequest | 
    contact_request.email = "johndoe@sendx.io"
    contact_request.first_name = "John"
    contact_request.last_name = "Doe"
    contact_request.company = "SendX"
    contact_request.tags = ["12nb32nk43k2", "34njnk42bkj3"]
    contact_request.custom_fields = {"1434nfk324kn4d": "VIP", "34njnk42bkj3": "Gold"}
    contact_request.last_tracked_ip = "34.212.42.122"

    try:
        # Create a contact
        api_response = api_instance.create_contact(contact_request)
        print("The response of ContactApi->create_contact:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling CampaignApi->create_campaign: %s\n" % e)

Documentation for API Endpoints

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

Class Method HTTP request Description
CampaignApi create_campaign POST /campaign Create campaign
CampaignApi delete_campaign DELETE /campaign/{identifier} Delete campaign
CampaignApi get_all_campaigns GET /campaign Get all campaigns
CampaignApi get_campaign GET /campaign/{identifier} Get campaign by ID
ContactApi create_contact POST /contact Create a new contact
ContactApi delete_contact DELETE /contact/{identifier} Delete contact
ContactApi get_all_contacts GET /contact Get all contacts
ContactApi get_contact GET /contact/{identifier} Get contact by ID
ContactApi unsubscribe_contact POST /contact/unsubscribe/{identifier} Unsubscribe contact
ContactApi update_contact PUT /contact/{identifier} Update contact
CustomFieldApi create_custom_field POST /customfield Create custom field
CustomFieldApi delete_custom_field DELETE /customfield/{identifier} Delete custom field
CustomFieldApi get_all_custom_fields GET /customfield Get all custom fields
CustomFieldApi get_custom_field GET /customfield/{identifier} Get custom field by ID
CustomFieldApi update_custom_field PUT /customfield/{identifier} Update custom field
EmailSendingApi send_email POST /send/email Send transactional email
EmailSendingApi send_email_with_template POST /send/template Send email using template
EventApi events_custom_postback_get GET /events/custom/postback Custom Event Postback URL
EventApi events_revenue_postback_get GET /events/revenue/postback Revenue Event Postback URL
EventsApi track_custom_event POST /events/custom Track custom event
EventsApi track_revenue_event POST /events/revenue Track revenue event
ListApi create_list POST /list Create list
ListApi delete_list DELETE /list/{identifier} Delete list
ListApi get_all_lists GET /list Get all lists
ListApi get_list GET /list/{identifier} Get list by ID
ListApi update_list PUT /list/{identifier} Update list
PostApi create_post POST /post Create blog post
PostApi delete_post DELETE /post/{identifier} Delete post
PostApi get_all_posts GET /post Get all posts
PostApi get_post GET /post/{identifier} Get post by ID
PostApi update_post PUT /post/{identifier} Update post
PostCategoryApi create_post_category POST /post/category Create post category
PostCategoryApi delete_post_category DELETE /post/category/{identifier} Delete post category
PostCategoryApi get_all_post_categories GET /post/category Get all post categories
PostCategoryApi get_post_category GET /post/category/{identifier} Get post category by ID
PostCategoryApi update_post_category PUT /post/category/{identifier} Update post category
PostTagApi create_post_tag POST /post/tag Create post tag
PostTagApi delete_post_tag DELETE /post/tag/{identifier} Delete post tag
PostTagApi get_all_post_tags GET /post/tag Get all post tags
PostTagApi get_post_tag GET /post/tag/{identifier} Get post tag by ID
PostTagApi update_post_tag PUT /post/tag/{identifier} Update post tag
ReportApi get_campaign_report GET /report/campaign/{identifier} Get campaign report
SenderApi create_sender POST /sender Create sender
SenderApi get_all_senders GET /sender Get all senders
TagApi create_tag POST /tag Create tag
TagApi delete_tag DELETE /tag/{identifier} Delete tag
TagApi get_all_tags GET /tag Get all tags
TagApi get_tag GET /tag/{identifier} Get tag by ID
TagApi update_tag PUT /tag/{identifier} Update tag
TeamMemberApi get_all_team_members GET /team/member Get all team members
TeamMemberApi get_team_member GET /team/member/{identifier} Get a team member by ID
TemplateApi create_email_template POST /template/email Create email template
TemplateApi delete_email_template DELETE /template/email/{identifier} Delete template
TemplateApi get_all_email_templates GET /template/email Get all templates
TemplateApi get_email_template GET /template/email/{identifier} Get template by ID
TemplateApi update_email_template PUT /template/email/{identifier} Update template
TrackingApi identify_contact POST /contact/identify Identify contact
TrackingApi track_contact POST /contact/track Track contact
WebhookApi create_webhook POST /webhook Create webhook
WebhookApi delete_webhook DELETE /webhook/{identifier} Delete webhook
WebhookApi get_all_webhooks GET /webhook Get all webhooks
WebhookApi get_webhook GET /webhook/{identifier} Get webhook by ID
WebhookApi update_webhook PUT /webhook/{identifier} Update webhook

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

TeamApiKey

  • Type: API key
  • API key parameter name: X-Team-ApiKey
  • Location: HTTP header

Author

hello@sendx.io

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published