In a text editor, write your API call. You can use the following sample code by replacing the placeholders with valid data: [su_tabs active="1"][su_tab title="cURL" disabled="no" anchor="" url="" target="blank" class=""]
curl --location --request POST 'https://app.jetsend.com/api/v1/transmission/email'; \
--header 'accept: application/json' \
--header 'Authorization: Bearer [YOUR_API_KEY]' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": {
"options": {
"description": "Testing Jetsend Email Transimission API",
"tracking_domain": "app-tracking@jetsend.xyz"
},
"recipients": [
{
"address": {
"email": "manjinder@maropost.com",
"name": "Manjinder Singh"
}
}
],
"content": {
"from": {
"name": "Jetsend Test Account",
"email": "test@jetsend.xyz"
},
"subject": "Welcome to Jetsend!",
"reply_to": "Jetsend Support <support@jetsend.xyz>",
"html": "<h2>Hello!</h2><p>You have successfully sent an email via JetSend API.</p><p>Click this link to check our help center page: <a href='\''http://support.jetsend.com'\''>JetSend Support</a></p>this is just a test email."
}
}
}'
[/su_tab] [su_tab title="Go" disabled="no" anchor="" url="" target="blank" class=""]
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://app.jetsend.com/api/v1/transmission/email"
method := "POST"
payload := strings.NewReader("{\n \"email\": {\n \"options\": {\n \"description\": \"Testing Jetsend Email Transimission API\",\n \"tracking_domain\": \"app-tracking@jetsend.xyz\"\n },\n \"recipients\": [\n {\n \"address\": {\n \"email\": \"manjinder@maropost.com\",\n \"name\": \"Manjinder Singh\"\n }\n }\n ],\n \"content\": {\n \"from\": {\n \"name\": \"Jetsend Test Account\",\n \"email\": \"test@jetsend.xyz\"\n },\n \"subject\": \"Welcome to Jetsend!\",\n \"reply_to\": \"Jetsend Support <support@jetsend.xyz>\",\n \"html\": \"<h2>Hello!</h2><p>You have successfully sent an email via JetSend API.</p><p>Click this link to check our help center page: <a href='http://support.jetsend.com'>JetSend Support</a></p>this is just a test email.\"\n }\n }\n}")
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
}
req.Header.Add("accept", "application/json")
req.Header.Add("Authorization", "Bearer [YOUR_API_KEY]")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
[/su_tab] [su_tab title="JavaScript XHR" disabled="no" anchor="" url="" target="blank" class=""]
var data = JSON.stringify({"email":{"options":{"description":"Testing Jetsend Email Transimission API","tracking_domain":"app-tracking@jetsend.xyz"},"recipients":[{"address":{"email":"manjinder@maropost.com","name":"Manjinder Singh"}}],"content":{"from":{"name":"Jetsend Test Account","email":"test@jetsend.xyz"},"subject":"Welcome to Jetsend!","reply_to":"Jetsend Support <support@jetsend.xyz>","html":"<h2>Hello!</h2><p>You have successfully sent an email via JetSend API.</p><p>Click this link to check our help center page: <a href='http://support.jetsend.com'>JetSend Support</a></p>this is just a test email."}}});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://app.jetsend.com/api/v1/transmission/email");
xhr.setRequestHeader("accept", "application/json");
xhr.setRequestHeader("Authorization", "Bearer [YOUR_API_KEY]");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
[/su_tab] [su_tab title="Node.js" disabled="no" anchor="" url="" target="blank" class=""]
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://app.jetsend.com/api/v1/transmission/email',
'headers': {
'accept': 'application/json',
'Authorization': 'Bearer [YOUR API KEY]',
'Content-Type': 'application/json'
},
body: JSON.stringify({"email":{"options":{"description":"Testing Jetsend Email Transimission API","tracking_domain":"app-tracking@jetsend.xyz"},"recipients":[{"address":{"email":"manjinder@maropost.com","name":"Manjinder Singh"}}],"content":{"from":{"name":"Jetsend Test Account","email":"test@jetsend.xyz"},"subject":"Welcome to Jetsend!","reply_to":"Jetsend Support <support@jetsend.xyz>","html":"<h2>Hello!</h2><p>You have successfully sent an email via JetSend API.</p><p>Click this link to check our help center page: <a href='http://support.jetsend.com'>JetSend Support</a></p>this is just a test email."}}})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
[/su_tab] [su_tab title="Python" disabled="no" anchor="" url="" target="blank" class=""]
import requests
url = "https://app.jetsend.com/api/v1/transmission/email"
payload = "{\n \"email\": {\n \"options\": {\n \"description\": \"Testing Jetsend Email Transimission API\",\n \"tracking_domain\": \"app-tracking@jetsend.xyz\"\n },\n \"recipients\": [\n {\n \"address\": {\n \"email\": \"manjinder@maropost.com\",\n \"name\": \"Manjinder Singh\"\n }\n }\n ],\n \"content\": {\n \"from\": {\n \"name\": \"Jetsend Test Account\",\n \"email\": \"test@jetsend.xyz\"\n },\n \"subject\": \"Welcome to Jetsend!\",\n \"reply_to\": \"Jetsend Support <support@jetsend.xyz>\",\n \"html\": \"<h2>Hello!</h2><p>You have successfully sent an email via JetSend API.</p><p>Click this link to check our help center page: <a href='http://support.jetsend.com'>JetSend Support</a></p>this is just a test email.\"\n }\n }\n}"
headers = {
'accept': 'application/json',
'Authorization': 'Bearer [YOUR_API_KEY],
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
[/su_tab] [su_tab title="Ruby" disabled="no" anchor="" url="" target="blank" class=""]
require "uri"
require "net/http"
url = URI("https://app.jetsend.com/api/v1/transmission/email")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["Authorization"] = "Bearer [YOUR_API_KEY]"
request["Content-Type"] = "application/json"
request.body = "{\n \"email\": {\n \"options\": {\n \"description\": \"Testing Jetsend Email Transimission API\",\n \"tracking_domain\": \"app-tracking@jetsend.xyz\"\n },\n \"recipients\": [\n {\n \"address\": {\n \"email\": \"manjinder@maropost.com\",\n \"name\": \"Manjinder Singh\"\n }\n }\n ],\n \"content\": {\n \"from\": {\n \"name\": \"Jetsend Test Account\",\n \"email\": \"test@jetsend.xyz\"\n },\n \"subject\": \"Welcome to Jetsend!\",\n \"reply_to\": \"Jetsend Support <support@jetsend.xyz>\",\n \"html\": \"<h2>Hello!</h2><p>You have successfully sent an email via JetSend API.</p><p>Click this link to check our help center page: <a href='http://support.jetsend.com'>JetSend Support</a></p>this is just a test email.\"\n }\n }\n}"
response = https.request(request)
puts response.read_body
[/su_tab] [su_tab title="Swift" disabled="no" anchor="" url="" target="blank" class=""]
import Foundation
var semaphore = DispatchSemaphore (value: 0)
let parameters = "{\n \"email\": {\n \"options\": {\n \"description\": \"Testing Jetsend Email Transimission API\",\n \"tracking_domain\": \"app-tracking@jetsend.xyz\"\n },\n \"recipients\": [\n {\n \"address\": {\n \"email\": \"manjinder@maropost.com\",\n \"name\": \"Manjinder Singh\"\n }\n }\n ],\n \"content\": {\n \"from\": {\n \"name\": \"Jetsend Test Account\",\n \"email\": \"test@jetsend.xyz\"\n },\n \"subject\": \"Welcome to Jetsend!\",\n \"reply_to\": \"Jetsend Support <support@jetsend.xyz>\",\n \"html\": \"<h2>Hello!</h2><p>You have successfully sent an email via JetSend API.</p><p>Click this link to check our help center page: <a href='http://support.jetsend.com'>JetSend Support</a></p>this is just a test email.\"\n }\n }\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://app.jetsend.com/api/v1/transmission/email")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "accept")
request.addValue("Bearer [YOUR_API_KEY]", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
[/su_tab][/su_tabs]