Skip to content

sendx/sendx-go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Go API client for sendx

πŸš€ 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

<img src="https://run.pstmn.io/button.svg" alt="Run In Postman" style="width: 128px; height: 32px;">

Installation

Install the following dependencies:

go get github.com/sendx/sendx-go-sdk

Examples

package main

import (
	"context"
	"fmt"
	"os"
	
	sendx "github.com/sendx/sendx-go-sdk"
)

func main() {
	ctx := context.WithValue(
		context.Background(),
		sendx.ContextAPIKeys,
		map[string]sendx.APIKey{
			"apiKeyAuth": {Key: "YOUR_API_KEY"},
		},
	)

	contactRequest := *sendx.NewContactRequest() // ContactRequest |
	contactRequest.Email = sendx.PtrString("jane@doe.com")
	contactRequest.FirstName = sendx.PtrString("Jane")
	contactRequest.LastName = sendx.PtrString("Doe")
	contactRequest.Company = sendx.PtrString("Tech Solutions Inc.")
	contactRequest.LastTrackedIp = sendx.PtrString("34.94.159.140")
	contactRequest.CustomFields = &map[string]string{"K2mxBVReqBhbwx9e0ItSea": "VIP", "7o3Tl1aY2yKp2X1aflRjOL": "Special Offer Subscriber"}
	contactRequest.Lists = []string{"1244"}
	contactRequest.Tags = []string{"MKdhTovsTJDetCyrJmRySL"}

	configuration := sendx.NewConfiguration()
	apiClient := sendx.NewAPIClient(configuration)
	resp, r, err := apiClient.ContactAPI.CreateContact(ctx).ContactRequest(contactRequest).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `ContactAPI.CreateContact``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `CreateContact`: Response
	fmt.Fprintf(os.Stdout, "Response from `ContactAPI.CreateContact`: %v\n", resp)

}

Note, enum values are always validated and all unused variables are silently ignored.

Documentation for API Endpoints

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

Class Method HTTP request Description
CampaignAPI CreateCampaign Post /campaign Create campaign
CampaignAPI DeleteCampaign Delete /campaign/{identifier} Delete campaign
CampaignAPI GetAllCampaigns Get /campaign Get all campaigns
CampaignAPI GetCampaign Get /campaign/{identifier} Get campaign by ID
ContactAPI CreateContact Post /contact Create a new contact
ContactAPI DeleteContact Delete /contact/{identifier} Delete contact
ContactAPI GetAllContacts Get /contact Get all contacts
ContactAPI GetContact Get /contact/{identifier} Get contact by ID
ContactAPI UnsubscribeContact Post /contact/unsubscribe/{identifier} Unsubscribe contact
ContactAPI UpdateContact Put /contact/{identifier} Update contact
CustomFieldAPI CreateCustomField Post /customfield Create custom field
CustomFieldAPI DeleteCustomField Delete /customfield/{identifier} Delete custom field
CustomFieldAPI GetAllCustomFields Get /customfield Get all custom fields
CustomFieldAPI GetCustomField Get /customfield/{identifier} Get custom field by ID
CustomFieldAPI UpdateCustomField Put /customfield/{identifier} Update custom field
EmailSendingAPI SendEmail Post /send/email Send transactional email
EmailSendingAPI SendEmailWithTemplate Post /send/template Send email using template
EventAPI EventsCustomPostbackGet Get /events/custom/postback Custom Event Postback URL
EventAPI EventsRevenuePostbackGet Get /events/revenue/postback Revenue Event Postback URL
EventsAPI TrackCustomEvent Post /events/custom Track custom event
EventsAPI TrackRevenueEvent Post /events/revenue Track revenue event
ListAPI CreateList Post /list Create list
ListAPI DeleteList Delete /list/{identifier} Delete list
ListAPI GetAllLists Get /list Get all lists
ListAPI GetList Get /list/{identifier} Get list by ID
ListAPI UpdateList Put /list/{identifier} Update list
PostAPI CreatePost Post /post Create blog post
PostAPI DeletePost Delete /post/{identifier} Delete post
PostAPI GetAllPosts Get /post Get all posts
PostAPI GetPost Get /post/{identifier} Get post by ID
PostAPI UpdatePost Put /post/{identifier} Update post
PostCategoryAPI CreatePostCategory Post /post/category Create post category
PostCategoryAPI DeletePostCategory Delete /post/category/{identifier} Delete post category
PostCategoryAPI GetAllPostCategories Get /post/category Get all post categories
PostCategoryAPI GetPostCategory Get /post/category/{identifier} Get post category by ID
PostCategoryAPI UpdatePostCategory Put /post/category/{identifier} Update post category
PostTagAPI CreatePostTag Post /post/tag Create post tag
PostTagAPI DeletePostTag Delete /post/tag/{identifier} Delete post tag
PostTagAPI GetAllPostTags Get /post/tag Get all post tags
PostTagAPI GetPostTag Get /post/tag/{identifier} Get post tag by ID
PostTagAPI UpdatePostTag Put /post/tag/{identifier} Update post tag
ReportAPI GetCampaignReport Get /report/campaign/{identifier} Get campaign report
SenderAPI CreateSender Post /sender Create sender
SenderAPI GetAllSenders Get /sender Get all senders
TagAPI CreateTag Post /tag Create tag
TagAPI DeleteTag Delete /tag/{identifier} Delete tag
TagAPI GetAllTags Get /tag Get all tags
TagAPI GetTag Get /tag/{identifier} Get tag by ID
TagAPI UpdateTag Put /tag/{identifier} Update tag
TeamMemberAPI GetAllTeamMembers Get /team/member Get all team members
TeamMemberAPI GetTeamMember Get /team/member/{identifier} Get a team member by ID
TemplateAPI CreateEmailTemplate Post /template/email Create email template
TemplateAPI DeleteEmailTemplate Delete /template/email/{identifier} Delete template
TemplateAPI GetAllEmailTemplates Get /template/email Get all templates
TemplateAPI GetEmailTemplate Get /template/email/{identifier} Get template by ID
TemplateAPI UpdateEmailTemplate Put /template/email/{identifier} Update template
TrackingAPI IdentifyContact Post /contact/identify Identify contact
TrackingAPI TrackContact Post /contact/track Track contact
WebhookAPI CreateWebhook Post /webhook Create webhook
WebhookAPI DeleteWebhook Delete /webhook/{identifier} Delete webhook
WebhookAPI GetAllWebhooks Get /webhook Get all webhooks
WebhookAPI GetWebhook Get /webhook/{identifier} Get webhook by ID
WebhookAPI UpdateWebhook 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

Note, each API key must be added to a map of map[string]APIKey where the key is: TeamApiKey and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		sendx.ContextAPIKeys,
		map[string]sendx.APIKey{
			"TeamApiKey": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

hello@sendx.io

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages