### Get Subscribers Go Example Source: https://ecomailczv2.docs.apiary.io/reference/lists/list-subscribers/get-subscribers Example of how to retrieve subscribers using Go. This code demonstrates making a GET request with a custom header for the API key. ```Go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { client := &http.Client{} req, err := http.NewRequest("GET", "https://api2.ecomailapp.cz/lists/list_id/subscribers", nil) if err != nil { fmt.Print(err) } req.Header.Add("key", "YOUR_API_KEY") resp, err := client.Do(req) if err != nil { fmt.Print(err) } defer resp.Body.Close() bodyBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Print(err) } bodyString := string(bodyBytes) fmt.Print(bodyString) } ``` -------------------------------- ### Get Subscribers Visual Basic Example Source: https://ecomailczv2.docs.apiary.io/reference/lists/list-subscribers/get-subscribers Example of how to retrieve subscribers using Visual Basic. This code snippet demonstrates using HttpClient to perform the GET request. ```Visual Basic Imports System Imports System.Net.Http Imports System.Threading.Tasks Public Class Example Public Shared Async Function Main() As Task Using client As New HttpClient() Dim request As New HttpRequestMessage With { [Method] = HttpMethod.Get, [RequestUri] = New Uri("https://api2.ecomailapp.cz/lists/list_id/subscribers") } client.DefaultRequestHeaders.Add("key", "YOUR_API_KEY") Dim response As HttpResponseMessage = Await client.SendAsync(request) response.EnsureSuccessStatusCode() Dim body As String = Await response.Content.ReadAsStringAsync() Console.WriteLine(body) End Using End Function End Class ``` -------------------------------- ### Get Subscribers PHP Example Source: https://ecomailczv2.docs.apiary.io/reference/lists/list-subscribers/get-subscribers Example of how to retrieve subscribers using PHP. This code snippet demonstrates a GET request with the necessary API key header. ```PHP "https://api2.ecomailapp.cz/lists/list_id/subscribers", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "key: YOUR_API_KEY" ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #" . $err; } else { echo $response; } ``` -------------------------------- ### Get Subscribers C# Example Source: https://ecomailczv2.docs.apiary.io/reference/lists/list-subscribers/get-subscribers Example of how to retrieve subscribers using C#. This code snippet uses HttpClient to make the GET request and includes the API key in the headers. ```C# using System; using System.Net.Http; using System.Threading.Tasks; public class Example { public static async Task Main() { using (var client = new HttpClient()) { var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://api2.ecomailapp.cz/lists/list_id/subscribers") }; client.DefaultRequestHeaders.Add("key", "YOUR_API_KEY"); HttpResponseMessage response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } } } ``` -------------------------------- ### Get Subscribers JavaScript Example Source: https://ecomailczv2.docs.apiary.io/reference/lists/list-subscribers/get-subscribers Example of how to retrieve subscribers using JavaScript's fetch API. Replace 'list_id' and 'YOUR_API_KEY' accordingly. ```JavaScript fetch("https://api2.ecomailapp.cz/lists/list_id/subscribers", { "method": "GET", "headers": { "key": "YOUR_API_KEY" } }) .then(response => { console.log(response); }) .catch(err => { console.error(err); }); ``` -------------------------------- ### Get Subscribers Swift Example Source: https://ecomailczv2.docs.apiary.io/reference/lists/list-subscribers/get-subscribers Example of how to retrieve subscribers using Swift. This code snippet uses URLSession to make the GET request. ```Swift import Foundation let url = URL(string: "https://api2.ecomailapp.cz/lists/list_id/subscribers") var request = URLRequest(url: url!) request.httpMethod = "GET" request.setValue("YOUR_API_KEY", forHTTPHeaderField: "key") let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error.localizedDescription)") return } guard let data = data else {\n print("No data received") return } if let responseString = String(data: data, encoding: .utf8) { print("Response: \(responseString)") } } task.resume() ``` -------------------------------- ### Create Domain Go Example Source: https://ecomailczv2.docs.apiary.io/reference/domains/domains-collection/create-a-new-domain Example of how to create a new domain using Go. Replace API_KEY with your actual API key. ```go package main import ( "bytes" "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api2.ecomailapp.cz/domains" payload := []byte(`{ "name": "newdomain.cz" }`) req, err := http.NewRequest("POST", url, bytes.NewBuffer(payload)) if err != nil { fmt.Println(err) return } req.Header.Set("Content-Type", "application/json") req.Header.Set("key", "API_KEY") client := &http.Client{} res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Create Domain Swift Example Source: https://ecomailczv2.docs.apiary.io/reference/domains/domains-collection/create-a-new-domain Example of how to create a new domain using Swift. Replace API_KEY with your actual API key. ```swift import Foundation let urlString = "https://api2.ecomailapp.cz/domains" let apiKey = "API_KEY" let domainName = "newdomain.cz" guard let url = URL(string: urlString) else { return } var request = URLRequest(url: url) request.httpMethod = "POST" request.setValue("application/json", forHTTPHeaderField: "Content-Type") request.setValue(apiKey, forHTTPHeaderField: "key") let jsonDict = ["name": domainName] guard let jsonData = try? JSONSerialization.data(withJSONObject: jsonDict, options: []) else { return } request.httpBody = jsonData let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error.localizedDescription)") return } guard let data = data else { return } if let responseString = String(data: data, encoding: .utf8) { print("Response: \(responseString)") } } task.resume() ``` -------------------------------- ### Get Subscribers Objective-C Example Source: https://ecomailczv2.docs.apiary.io/reference/lists/list-subscribers/get-subscribers Example of how to retrieve subscribers using Objective-C. This code snippet uses NSURLSession to make the GET request. ```Objective-C #import int main(int argc, const char * argv[]) { @autoreleasepool { NSURL *url = [NSURL URLWithString:@"https://api2.ecomailapp.cz/lists/list_id/subscribers"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"GET"]; [request setValue:@"YOUR_API_KEY" forHTTPHeaderField:@"key"]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@"Error: %@", error.localizedDescription); return; } NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"Response: %@", responseString); }]; [task resume]; } return 0; } ``` -------------------------------- ### Create Domain C# Example Source: https://ecomailczv2.docs.apiary.io/reference/domains/domains-collection/create-a-new-domain Example of how to create a new domain using C#. Replace API_KEY with your actual API key. ```csharp using System; using System.Net.Http; using System.Text; using System.Threading.Tasks; public class Example { public static async Task Main(string[] args) { var client = new HttpClient(); var url = "https://api2.ecomailapp.cz/domains"; var apiKey = "API_KEY"; var jsonPayload = "{\"name\": \"newdomain.cz\"}"; var content = new StringContent(jsonPayload, Encoding.UTF8, "application/json"); client.DefaultRequestHeaders.Add("key", apiKey); try { HttpResponseMessage response = await client.PostAsync(url, content); response.EnsureSuccessStatusCode(); // Throw an exception if the status code is not a success code string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } catch (HttpRequestException e) { Console.WriteLine($"Request error: {e.Message}"); } } } ``` -------------------------------- ### Create Domain Ruby Example Source: https://ecomailczv2.docs.apiary.io/reference/domains/domains-collection/create-a-new-domain Example of how to create a new domain using Ruby. Replace API_KEY with your actual API key. ```ruby require 'uri' require 'net/http' require 'openssl' url = URI("https://api2.ecomailapp.cz/domains") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = "application/json" request["key"] = "API_KEY" request.body = "{\"name\": \"newdomain.cz\"}" response = https.request(request) puts response.read_body ``` -------------------------------- ### Create Domain JavaScript Example Source: https://ecomailczv2.docs.apiary.io/reference/domains/domains-collection/create-a-new-domain Example of how to create a new domain using JavaScript's fetch API. Replace API_KEY with your actual API key. ```javascript fetch("https://api2.ecomailapp.cz/domains", { "method": "POST", "headers": { "Content-Type": "application/json", "key": "API_KEY" }, "body": "{\"name\": \"newdomain.cz\"}" }) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err)); ``` -------------------------------- ### Get Subscribers Node.js Example Source: https://ecomailczv2.docs.apiary.io/reference/lists/list-subscribers/get-subscribers Example of how to retrieve subscribers using Node.js. Ensure you replace 'list_id' and 'YOUR_API_KEY' with your specific values. ```Node.js const fetch = require('node-fetch'); fetch('https://api2.ecomailapp.cz/lists/list_id/subscribers', { "method": "GET", "headers": { "key": "YOUR_API_KEY" } }) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err)); ``` -------------------------------- ### Create Domain Visual Basic Example Source: https://ecomailczv2.docs.apiary.io/reference/domains/domains-collection/create-a-new-domain Example of how to create a new domain using Visual Basic. Replace API_KEY with your actual API key. ```vb Imports System Imports System.Net.Http Imports System.Text Imports System.Threading.Tasks Public Module Example Public Async Function Main() Dim client As New HttpClient() Dim url As String = "https://api2.ecomailapp.cz/domains" Dim apiKey As String = "API_KEY" Dim jsonPayload As String = "{\"name\": \"newdomain.cz\"}" Dim content As New StringContent(jsonPayload, Encoding.UTF8, "application/json") client.DefaultRequestHeaders.Add("key", apiKey) Try Dim response As HttpResponseMessage = Await client.PostAsync(url, content) response.EnsureSuccessStatusCode() Dim responseBody As String = Await response.Content.ReadAsStringAsync() Console.WriteLine(responseBody) Catch ex As HttpRequestException Console.WriteLine($"Request error: {ex.Message}") End Try End Function End Module ``` -------------------------------- ### Create Domain Objective-C Example Source: https://ecomailczv2.docs.apiary.io/reference/domains/domains-collection/create-a-new-domain Example of how to create a new domain using Objective-C. Replace API_KEY with your actual API key. ```objectivec #import int main(int argc, const char * argv[]) { @autoreleasepool { NSString *urlString = @"https://api2.ecomailapp.cz/domains"; NSString *apiKey = @"API_KEY"; NSString *domainName = @"newdomain.cz"; NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; request.HTTPMethod = @"POST"; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setValue:apiKey forHTTPHeaderField:@"key"]; NSDictionary *jsonDict = @{@"name": domainName}; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:0 error:nil]; request.HTTPBody = jsonData; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@"Error: %@", error.localizedDescription); return; } NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"Response: %@", responseString); }]; [task resume]; } return 0; } ``` -------------------------------- ### Get Segments - Example Response Source: https://ecomailczv2.docs.apiary.io/reference/lists/get-segments/get-segments This is an example of a successful response when retrieving segments for a list. It includes segment IDs, names, and counts. ```json { "segments": { "5c36008811e45": { "name": "Segment 1", "id": "5c36008811e45", "count": 860 }, "5cbf2405a77ce": { "name": "Segment 2", "id": "5cbf2405a77ce", "count": 540 } } } ``` -------------------------------- ### Get Subscribers Groovy Example Source: https://ecomailczv2.docs.apiary.io/reference/lists/list-subscribers/get-subscribers Example of how to retrieve subscribers using Groovy. This snippet uses the 'http-builder-ng' library for making HTTP requests. ```Groovy import groovy.json.JsonSlurper import groovy.transform.Field @Field String API_KEY = "YOUR_API_KEY" @Field String LIST_ID = "list_id" HTTPBuilder http = new HTTPBuilder('https://api2.ecomailapp.cz') http.get(path: "/lists/${LIST_ID}/subscribers", contentType: 'application/json', headers: [key: API_KEY]) { resp, reader -> assert resp.status == 200 println reader } ``` -------------------------------- ### Trigger Automation Go Example Source: https://ecomailczv2.docs.apiary.io/reference/automations/trigger-automation/trigger-automation Example of how to trigger an automation using Go with the 'net/http' package. ```go package main import ( "bytes" "fmt" "net/http" "io/ioutil" ) func main() { apiKey := "API_KEY" pipelineID := "pipeline_id" email := "foo@bar.cz" url := fmt.Sprintf("https://api2.ecomailapp.cz/pipelines/%s/trigger/", pipelineID) requestBody := []byte(fmt.Sprintf(`{"email": "%s"}`, email)) req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody)) if err != nil { fmt.Printf("Error creating request: %s\n", err) return } req.Header.Set("Content-Type", "application/json") req.Header.Set("key", apiKey) client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Printf("Error sending request: %s\n", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Printf("Error reading response body: %s\n", err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Get Subscribers Ruby Example Source: https://ecomailczv2.docs.apiary.io/reference/lists/list-subscribers/get-subscribers Example of how to retrieve subscribers using Ruby. This snippet uses the 'httparty' gem for making HTTP requests. ```Ruby require 'httparty' response = HTTParty.get('https://api2.ecomailapp.cz/lists/list_id/subscribers', headers: { "key" => "YOUR_API_KEY" }) puts response ``` -------------------------------- ### Create Domain Groovy Example Source: https://ecomailczv2.docs.apiary.io/reference/domains/domains-collection/create-a-new-domain Example of how to create a new domain using Groovy. Replace API_KEY with your actual API key. ```groovy import groovy.json.JsonOutput import groovy.json.JsonSlurper def url = "https://api2.ecomailapp.cz/domains" def apiKey = "API_KEY" def payload = [name: 'newdomain.cz'] def jsonPayload = JsonOutput.toJson(payload) def request = new URL(url).openConnection() as HttpURLConnection request.setRequestMethod('POST') request.setRequestProperty('Content-Type', 'application/json') request.setRequestProperty('key', apiKey) request.setDoOutput(true) def outputStream = request.getOutputStream() outputStream.write(jsonPayload.getBytes()) outputStream.flush() outputStream.close() def responseCode = request.getResponseCode() def responseStream = (responseCode >= 200 && responseCode < 300) ? request.getInputStream() : request.getErrorStream() def reader = new BufferedReader(new InputStreamReader(responseStream)) def response = reader.readLine() println "Response Code: ${responseCode}" println "Response Body: ${response}" reader.close() request.disconnect() ``` -------------------------------- ### Create Domain PHP Example Source: https://ecomailczv2.docs.apiary.io/reference/domains/domains-collection/create-a-new-domain Example of how to create a new domain using PHP. Replace API_KEY with your actual API key. ```php "https://api2.ecomailapp.cz/domains", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"name\": \"newdomain.cz\"}", CURLOPT_HTTPHEADER => array( "Content-Type: application/json", "key: API_KEY" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #" . $err; } else { echo $response; } ``` -------------------------------- ### Get Automation Stats Detail (PHP) Source: https://ecomailczv2.docs.apiary.io/reference/automations/get-automation-stats-detail/get-automation-stats-detail Example of how to retrieve automation statistics using PHP. This snippet demonstrates making a GET request with necessary headers. ```PHP ``` -------------------------------- ### Create Domain Node.js Example Source: https://ecomailczv2.docs.apiary.io/reference/domains/domains-collection/create-a-new-domain Example of how to create a new domain using Node.js. Replace API_KEY with your actual API key. ```javascript const https = require('https'); const data = JSON.stringify({ name: 'newdomain.cz' }); const options = { hostname: 'api2.ecomailapp.cz', port: 443, path: '/domains', method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': data.length, 'key': 'API_KEY' } }; const req = https.request(options, (res) => { console.log(`statusCode: ${res.statusCode}`); res.on('data', (d) => { process.stdout.write(d); }); }); req.on('error', (error) => { console.error(error); }); req.write(data); req.end(); ```