Xeams API offers a robust way of sending emails and managing administrative tasks using RESTful API that is based on OpenAPI standards v3.0. You can use this API if you have a Xeams server installed on your premise. This feature is NOT available in Xeams Cloud.
Use the following steps to create an API Key and a Secret before sending requests.
You will need to send the API Key and Secret with every request you make, which can be done in two ways:
?auth-key=YourKey&secret=YourSecret
The following examples sends a request to /info
, which is a convinient method for testing connectivity and authentication with your Xeams
Server.
It uses JZ5UMPFLSQXZ1YRAQXLUI1XC6Z4ZZN0S
for API Key, and Xjtg1ctJprsEmfbjZ7g8
for the secret. You will need to replace
these strings with actual values generated by your Xeams.
curl -X 'GET' \ "http://localhost:5272/api/info?auth-key=JZ5UMPFLSQXZ1YRAQXLUI1XC6Z4ZZN0S&secret=Xjtg1ctJprsEmfbjZ7g8" \ -H "accept: application/json"
curl -X GET "http://localhost:7860/api/info" \ -H "accept: application/json" \ -u "JZ5UMPFLSQXZ1YRAQXLUI1XC6Z4ZZN0S:Xjtg1ctJprsEmfbjZ7g8"
{ "code": 200, "description": "9.3 - build: 6321" }
This example sends an email to Xeams, which then relays this message to a foreign domain. This example demonstrates the following features:
An HTTP POST method is required when sending emails. The screenshot below demonstrates sending a request using PostMan
A few important points to note when sending emails are:
application/json
template-id
field. {
"from-email": "user@your-company.com",
"from-name": "John Doe",
"recipient-fn": "Bob",
"recipient-ln": "Smith",
"to": "user@example.com,user2@example.com",
"subject": "This is a test message",
"cc": "cc_user@example.com",
"bcc": "bcc_user@example.com",
"template-id" : 1, /* Specified the template for this message. */
"is_html": true,
"body": "This is HTML version of the message.",
"custom_headers": {
"List-Unsubscribe": "",
"X-Entity-Ref-ID": "123",
"Tracking-Id": "888884433",
"reply-to": "alternative-email@domain.com"
},
"attachments": [
{
"content": "iVBORw0KGgoAAN11SQpl2E1KEkUIS7FaMDTbK...truncated",
"name": "email.gif",
"type": "image/gif",
"inline": false,
"content-id": "does not matter"
}
]
}
When sending emails in HTML, you can wrap your body in predefined templates. You are encouraged to modify existing templates or add as many templates as you like, provided following rules are applied.
$INSTALL_DIR/EmailTemplates
, where $INSTALL_DIR refers to the folder where Xeams is installed.5-My Template.htm
template-id
field in the JSON request. If two files are found with the same number, Xeams will pick the first available. template-id
field is missing, no template will be applied.In addition to sending emails, you can use this API to perform certain administrative tasks, provided your API key has been granted permission. For example, you can:
Refer to the API Reference for details.
Xeams API is based on OpenAPI 3.0 standards. Therefore, you can use the code generation tool on Swagger to create client-side code for your favorite language.