### Get Event Dumps List (Node.js) Source: https://godocs.unisender.ru/web-api-ref This Node.js example utilizes the node-fetch module to make an asynchronous POST request. It defines the request headers and an empty JSON body, then uses .then() to handle the JSON response. Ensure node-fetch is installed. ```javascript const fetch = require('node-fetch'); const headers = { 'Content-Type':'application/json', 'Accept':'application/json', 'X-API-KEY':'API_KEY' }; const inputBody = {}; fetch('https://go1.unisender.ru/ru/transactional/api/v1/event-dump/list.json', { method: 'POST', body: JSON.stringify(inputBody), headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Get Webhook List - C# HttpClient Source: https://godocs.unisender.ru/web-api-ref Demonstrates fetching webhooks in C# using `System.Net.Http.HttpClient`. This example sets up the client with the base URI and API key, constructs the JSON request body, sends a POST request, and processes the response. ```csharp using System; using System.IO; using System.Text; using System.Net.Http; using System.Net.Http.Headers; class Program { static HttpClient client; public static void Main(string[] args) { client = new HttpClient(); client.BaseAddress = new Uri("https://go1.unisender.ru/ru/transactional/api/v1/"); client.DefaultRequestHeaders.Add("X-API-KEY", "API_KEY"); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); string requestBody = "{" +" \"limit\": 0," +" \"offset\": 0" +"}"; var content = new StringContent(requestBody, Encoding.UTF8, "application/json"); var response = client.PostAsync("webhook/list.json", content).Result; var responseBody = response.Content.ReadAsStringAsync().Result; if(response.IsSuccessStatusCode) { Console.WriteLine(responseBody); } else { Console.WriteLine(String.Format("Request failed (HTTP {0}): {1}", (int)response.StatusCode, responseBody)); } } } ``` -------------------------------- ### Get System Info using C# with HttpClient Source: https://godocs.unisender.ru/web-api-ref This C# example shows how to call the system info endpoint using HttpClient. It configures the base address, default headers including the API key, and sends a POST request with JSON content. The response is read and displayed, with basic error handling. ```C# using System; using System.IO; using System.Text; using System.Net.Http; using System.Net.Http.Headers; class Program { static HttpClient client; public static void Main(string[] args) { client = new HttpClient(); client.BaseAddress = new Uri("https://go1.unisender.ru/ru/transactional/api/v1/"); client.DefaultRequestHeaders.Add("X-API-KEY", "API_KEY"); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); string requestBody = "{}"; var content = new StringContent(requestBody, Encoding.UTF8, "application/json"); var response = client.PostAsync("system/info.json", content).Result; var responseBody = response.Content.ReadAsStringAsync().Result; if(response.IsSuccessStatusCode) { Console.WriteLine(responseBody); } else { Console.WriteLine(String.Format("Request failed (HTTP {0}): {1}", (int)response.StatusCode, responseBody)); } } } ``` -------------------------------- ### GET /websites/godocs_unisender_ru/webhooks Source: https://godocs.unisender.ru/web-api-ref Retrieves a list of configured webhooks. You can control the number of results and the starting point using the 'limit' and 'offset' query parameters. ```APIDOC ## GET /webhooks ### Description Retrieves a list of configured webhooks. Supports pagination using `limit` and `offset` parameters. ### Method GET ### Endpoint `/webhooks` ### Parameters #### Query Parameters - **limit** (integer) - Optional - Maximum number of webhooks to return per call. Recommended value is 50. - **offset** (integer) - Optional - Index of the first webhook to return from the list, starting from zero. ### Request Example ``` GET /webhooks?limit=50&offset=0 ``` ### Response #### Success Response (200) - **status** (string) - Required - Indicates 'success'. - **objects** (array) - Optional - An array of webhook objects. - **id** (integer) - Unique identifier for the webhook. - **url** (string) - The URL endpoint for receiving webhook notifications. - **status** (string) - The status of the webhook ('active', 'disabled', 'stopped'). - **event_format** (string) - The format for sending event notifications ('json_post' or 'json_post_gzip'). - **delivery_info** (integer) - Indicates whether to return detailed delivery information (1) or not (0). - **single_event** (integer) - If set to 1, only one event will be sent per call (not recommended). - **max_parallel** (integer) - The maximum number of parallel requests allowed to your server. - **updated_at** (string) - Optional - The time the webhook properties were last updated in UTC (YYYY-MM-DD HH:MM:SS). - **events** (object) - Optional - An object specifying which events to be notified about. - **spam_block** (array) - Optional - If present, notifications for spam blocks will be sent. Should contain a single element with '*'. - **email_status** (array) - Optional - If present, notifications for email status changes will be sent. Lists the specific statuses to be notified about. #### Response Example (200) ```json { "status": "success", "objects": [ { "id": 0, "url": "http://example.com", "status": "active", "event_format": "json_post", "delivery_info": 0, "single_event": 0, "max_parallel": 10, "updated_at": "2023-10-27 10:00:00", "events": { "spam_block": [ "*" ], "email_status": [ "delivered", "opened" ] } } ] } ``` #### Error Response (default) - **status** (string) - Indicates 'error'. - **message** (string) - An error message in English. - **code** (integer) - An API error code. #### Error Response Example ```json { "status": "error", "message": "Invalid request parameters", "code": 400 } ``` ``` -------------------------------- ### Get System Info using Node.js with node-fetch Source: https://godocs.unisender.ru/web-api-ref This Node.js example uses the 'node-fetch' library to make a POST request to the system info endpoint. It defines the necessary headers and an empty input body, then sends the request and logs the JSON response to the console. ```JavaScript const fetch = require('node-fetch'); const headers = { 'Content-Type':'application/json', 'Accept':'application/json', 'X-API-KEY':'API_KEY' }; const inputBody = {}; fetch('https://go1.unisender.ru/ru/transactional/api/v1/system/info.json', { method: 'POST', body: JSON.stringify(inputBody), headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Get System Info using Python with Requests Source: https://godocs.unisender.ru/web-api-ref This Python example utilizes the 'requests' library to interact with the system info endpoint. It defines the base URL, headers, and an empty request body, then sends a POST request. The code includes error checking and prints the JSON response. ```Python import requests base_url = 'https://go1.unisender.ru/ru/transactional/api/v1' headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-API-KEY': 'API_KEY' } request_body = {} r = requests.post(base_url+'/system/info.json', json=request_body, headers=headers) r.raise_for_status() # throw an exception in case of error print(r.json()) ``` -------------------------------- ### Get Event Dumps List (Python) Source: https://godocs.unisender.ru/web-api-ref This Python example uses the requests library to call the event-dump/list.json endpoint. Ensure the requests library is installed. It sends a POST request with JSON payload and custom headers, then prints the JSON response. ```python import requests base_url = 'https://go1.unisender.ru/ru/transactional/api/v1' headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-API-KEY': 'API_KEY' } request_body = {} r = requests.post(base_url+'/event-dump/list.json', json=request_body, headers=headers) r.raise_for_status() # throw an exception in case of error print(r.json()) ``` -------------------------------- ### Get Event Dumps List (C#) Source: https://godocs.unisender.ru/web-api-ref This C# example demonstrates making the API call using HttpClient. It sets the base URI and default headers, including the API key and Accept header. The request body is a JSON string, and the response is read asynchronously. ```csharp using System; using System.IO; using System.Text; using System.Net.Http; using System.Net.Http.Headers; class Program { static HttpClient client; public static void Main(string[] args) { client = new HttpClient(); client.BaseAddress = new Uri("https://go1.unisender.ru/ru/transactional/api/v1/"); client.DefaultRequestHeaders.Add("X-API-KEY", "API_KEY"); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); string requestBody = "{}"; var content = new StringContent(requestBody, Encoding.UTF8, "application/json"); var response = client.PostAsync("event-dump/list.json", content).Result; var responseBody = response.Content.ReadAsStringAsync().Result; if(response.IsSuccessStatusCode) { Console.WriteLine(responseBody); } else { Console.WriteLine(String.Format("Request failed (HTTP {0}): {1}", (int)response.StatusCode, responseBody)); } } } ``` -------------------------------- ### Get Webhook List - Node.js Fetch Source: https://godocs.unisender.ru/web-api-ref Provides a Node.js example using the `node-fetch` module to get a list of webhooks. It defines headers and the request body, then sends a POST request to the API and logs the JSON response. ```javascript const fetch = require('node-fetch'); const headers = { 'Content-Type':'application/json', 'Accept':'application/json', 'X-API-KEY':'API_KEY' }; const inputBody = { "limit": 0, "offset": 0 }; fetch('https://go1.unisender.ru/ru/transactional/api/v1/webhook/list.json', { method: 'POST', body: JSON.stringify(inputBody), headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Domain Verification DNS Records Request (Example) Source: https://godocs.unisender.ru/web-api-ref This is a conceptual example of how to request DNS records required for domain verification. The actual implementation would involve an API call to the 'domain/get-dns-records' endpoint. ```plaintext POST /domain/get-dns-records { "domain": "yourdomain.com" } ``` -------------------------------- ### Get Webhook List - Python Requests Source: https://godocs.unisender.ru/web-api-ref Provides a Python example for retrieving webhooks using the `requests` library. It defines the API base URL, headers including the API key, and the JSON request body, then sends a POST request and prints the JSON response. ```python import requests base_url = 'https://go1.unisender.ru/ru/transactional/api/v1' headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-API-KEY': 'API_KEY' } request_body = { "limit": 0, "offset": 0 } r = requests.post(base_url+'/webhook/list.json', json=request_body, headers=headers) r.raise_for_status() # throw an exception in case of error print(r.json()) ``` -------------------------------- ### Send Resubscribe Email via API (Example) Source: https://godocs.unisender.ru/web-api-ref This example demonstrates sending a resubscribe email using the specified API endpoint. It outlines the request method, endpoint, and expected JSON response for a successful operation. The `from_email`, `from_name`, and `to_email` parameters are mandatory for this request. ```http POST /ru/transactional/api/v1/email/subscribe.json { "status": "success" } ``` -------------------------------- ### GET /websites/godocs_unisender_ru Source: https://godocs.unisender.ru/web-api-ref Retrieves a list of projects. Supports optional filtering by project ID or API key. ```APIDOC ## GET /websites/godocs_unisender_ru ### Description Retrieves a list of projects. This endpoint allows you to fetch project details and optionally filter the results by providing specific project IDs or API keys. ### Method GET ### Endpoint /websites/godocs_unisender_ru ### Parameters #### Query Parameters - **project_id** (string) - Optional - Allows specifying a project_id to include only the specified project in the list. - **project_api_key** (string) - Optional - Allows specifying a project_api_key to include only the specified project in the list. ### Request Example ```json { "project_id": "optional_project_id_if_needed" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation, typically 'success'. - **projects** (array) - An array of project objects. - **id** (string) - The unique identifier for the project. - **api_key** (string) - The API key for the project. - **name** (string) - The name of the project. - **country** (string) - The two-letter country code (ISO-3166 alpha-2). - **reg_time** (string) - The UTC date and time the project was registered. - **send_enabled** (boolean) - Indicates if sending emails is enabled for the project. - **custom_unsubscribe_url_enabled** (boolean) - Indicates if custom unsubscribe URLs are enabled. - **backend_domain_id** (integer) - The ID of the backend domain. - **email_counter** (integer) - The current email count for the project. - **email_counter_limit** (integer) - The limit for the email counter. - **email_counter_mode** (string) - The mode of the email counter ('default' or 'permanent'). - **unsubscribe_page_id** (integer) - The ID of the unsubscribe page. #### Response Example (Success) ```json { "status": "success", "projects": [ { "id": "6123462132634", "api_key": "string", "name": "Project 1A", "country": "ES", "reg_time": "2020-12-28 17:15:45", "send_enabled": true, "custom_unsubscribe_url_enabled": true, "backend_domain_id": 1234, "email_counter": 0, "email_counter_limit": 0, "email_counter_mode": "default", "unsubscribe_page_id": 1 } ] } ``` #### Error Response (Default) - **status** (string) - Indicates the status of the operation, typically 'error'. - **message** (string) - A message describing the error. - **code** (integer) - The API error code. #### Response Example (Error) ```json { "status": "error", "message": "An error occurred", "code": 123 } ``` ``` -------------------------------- ### Create Project via Node.js Fetch Source: https://godocs.unisender.ru/web-api-ref This snippet demonstrates how to create a new project using the Unisender Go API with Node.js and the 'node-fetch' library. It includes setting up request headers, defining the project details in the request body, and handling the JSON response. Ensure you replace 'API_KEY' with your actual API key. ```javascript const fetch = require('node-fetch'); const headers = { 'Content-Type':'application/json', 'Accept':'application/json', 'X-API-KEY':'API_KEY' }; const inputBody = { "project": { "name": "Project 1A", "country": "ES", "send_enabled": true, "custom_unsubscribe_url_enabled": true, "backend_domain_id": 1234, "unsubscribe_page_id": 1 } }; fetch('https://go1.unisender.ru/ru/transactional/api/v1/project/create.json', { method: 'POST', body: JSON.stringify(inputBody), headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Get System Info via HTTP Request Source: https://godocs.unisender.ru/web-api-ref Demonstrates making a raw HTTP POST request to the system info endpoint. It includes setting the host, content type, accept headers, and an empty JSON body. This is useful for understanding the fundamental API interaction. ```HTTP POST https://go1.unisender.ru/ru/transactional/api/v1/system/info.json HTTP/1.1 Host: go1.unisender.ru Content-Type: application/json Accept: application/json {} ``` -------------------------------- ### GET /api/ unsubscribe Source: https://godocs.unisender.ru/web-api-ref Retrieves a list of unsubscribed email addresses. You can filter the results by providing a start date. ```APIDOC ## GET /api/unsubscribe ### Description Retrieves a list of unsubscribed email addresses. You can filter the results by providing a start date. ### Method GET ### Endpoint /api/unsubscribe ### Parameters #### Query Parameters - **date_from** (string(utc-date)) - Optional - Date in YYYY-MM-DD format to get all unsubscribed addresses from 'date_from' to the current day. If not specified, the default period is from 00:00 today UTC. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **status** (string) - Required - 'success'. - **unsubscribed** (array) - Required - An array of objects with unsubscribe data. - **address** (string(email)) - Optional - The unsubscribed email address. - **unsubscribed_on** (string(utc-date-time)) - Optional - The date and time the address was unsubscribed in YYYY-MM-DD HH:MM:SS format in UTC. #### Response Example ```json { "status": "success", "unsubscribed": [ { "address": "user@example.com", "unsubscribed_on": "2020-10-15 22:14:59" } ] } ``` #### Error Response (default) - **status** (string) - Required - 'error'. - **message** (string) - Required - Error message in English. - **code** (integer) - Required - API error code. ``` -------------------------------- ### Get DNS Records via API (Java) Source: https://godocs.unisender.ru/web-api-ref This Java code example demonstrates how to make an HTTP POST request to the Unisender Go API to get DNS records. It uses HttpURLConnection to send a JSON payload with the domain name and includes necessary headers. The response code and body are then printed. ```java URL obj = new URL("https://go1.unisender.ru/ru/transactional/api/v1/domain/get-dns-records.json"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type", "application/json"); con.setRequestProperty("Accept", "application/json"); con.setRequestProperty("X-API-KEY", "API_KEY"); con.setDoOutput(true); String requestBody = "{" +" \"domain\": \"example.com\"" +"}"; try (OutputStream out = con.getOutputStream()) { out.write(requestBody.getBytes()); out.flush(); } int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(responseCode); System.out.println(response.toString()); ``` -------------------------------- ### Set Email to Unsubscribed List - Node.js Source: https://godocs.unisender.ru/web-api-ref This Node.js example uses the `node-fetch` library to send a POST request to the Unisender API's `unsubscribed/set.json` endpoint. It configures the request headers and the JSON body. The response is then parsed as JSON and logged to the console. Ensure `node-fetch` is installed (`npm install node-fetch`). ```javascript const fetch = require('node-fetch'); const headers = { 'Content-Type':'application/json', 'Accept':'application/json', 'X-API-KEY':'API_KEY' }; const inputBody = { "address": "user@example.com" }; fetch('https://go1.unisender.ru/ru/transactional/api/v1/unsubscribed/set.json', { method: 'POST', body: JSON.stringify(inputBody), headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Get System Info using Ruby with RestClient Source: https://godocs.unisender.ru/web-api-ref This Ruby code snippet demonstrates how to retrieve system information using the 'rest-client' gem. It sets up the necessary headers and parameters, then makes a POST request to the API. Exception handling for API errors is also included. ```Ruby require 'rest-client' require 'json' headers = { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-API-KEY' => 'API_KEY' } params = {} begin result = RestClient.post( 'https://go1.unisender.ru/ru/transactional/api/v1/system/info.json', params.to_json, headers ) p JSON.parse(result) rescue RestClient::ExceptionWithResponse => e puts e.response.code puts e.response.body end ``` -------------------------------- ### Get System Info using PHP with Guzzle Source: https://godocs.unisender.ru/web-api-ref This PHP snippet shows how to fetch system information using the Guzzle HTTP client. It configures headers, sets the base URI, and sends a POST request to the system info endpoint. Error handling for bad responses is included. ```PHP require 'vendor/autoload.php'; $headers = array( 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-API-KEY' => 'API_KEY', ); $client = new \GuzzleHttp\Client([ 'base_uri' => 'https://go1.unisender.ru/ru/transactional/api/v1/' ]); $requestBody = []; try { $response = $client->request('POST','system/info.json', array( 'headers' => $headers, 'json' => $requestBody, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` -------------------------------- ### GET /suppression Source: https://godocs.unisender.ru/web-api-ref Retrieves a list of email addresses that are suppressed, starting from a specified date or cursor. This endpoint is used to fetch suppressed emails and their associated reasons and sources. ```APIDOC ## GET /suppression ### Description Retrieves a list of email addresses that are suppressed, starting from a specified date or cursor. This endpoint is used to fetch suppressed emails and their associated reasons and sources. ### Method GET ### Endpoint /suppression ### Parameters #### Query Parameters - **cursor** (string) - Required - Parameter indicates from which position to start the selection. It should be empty or absent for the first portion of data and must be set for the second and subsequent portions, using the "cursor" field value from the previous portion. ### Request Example ```json { "cursor": "" } ``` ### Response #### Success Response (200) - **status** (string) - Required - Indicates "success" if the request was successful. - **suppressions** (array) - Required - An array of objects containing information about suppressed email addresses. - **email** (string) - Optional - The email address that is on the suppressed list. - **cause** (string) - Required - The reason why sending to this email is blocked. Possible values include: "unsubscribed", "temporary_unavailable", "permanent_unavailable", "complained", "blocked". - **source** (string) - Required - The source of the suppression. Possible values include: "user", "system", "subscriber". - **is_deletable** (boolean) - Required - Indicates whether the suppression record can be deleted using the suppression/delete call. - **created** (string) - Required - The date and time when the suppression was set, in UTC ("YYYY-MM-DD HH:MM:SS"). #### Response Example ```json { "status": "success", "suppressions": [ { "email": "example@example.com", "cause": "unsubscribed", "source": "user", "is_deletable": true, "created": "2023-10-27 10:00:00" } ], "cursor": "some_cursor_value" } ``` #### Error Response (default) - **status** (string) - Indicates "error" if the request failed. - **message** (string) - The error message in English. - **code** (integer) - The API error code. ``` -------------------------------- ### POST /ru/transactional/api/v1/project/create.json Source: https://godocs.unisender.ru/web-api-ref Creates a new project within your Unisender Go account. This allows you to manage email sending configurations for different projects. ```APIDOC ## POST /ru/transactional/api/v1/project/create.json ### Description Creates a new project within your Unisender Go account. This allows you to manage email sending configurations for different projects. ### Method POST ### Endpoint /ru/transactional/api/v1/project/create.json ### Parameters #### Request Body - **project** (object) - Required - An object containing the properties of the project. - **name** (string) - Required - The name of the project, unique within the user's account. - **country** (string) - Optional - A two-letter country code according to ISO-3166 alpha-2. If specified, Unisender Go processes the project's personal data in accordance with the laws of the specified country (e.g., GDPR for European countries). - **send_enabled** (boolean) - Optional - Whether email sending is enabled for the project. - **custom_unsubscribe_url_enabled** (boolean) - Optional - If false, Unisender Go adds a system unsubscribe link to the end of each email. Setting to true disables the automatic addition of the system unsubscribe link and allows you to use your own unsubscribe link or send emails without one. - **backend_domain_id** (integer) - Optional - A unique identifier for the backend domain that determines the default link domain or IP address pool. If absent, a default backend domain will be assigned to the account/project. - **unsubscribe_page_id** (integer) - Optional - A unique identifier that determines the default unsubscribe page. If absent, a default system unsubscribe page will be assigned to the account/project. ### Request Example ```json { "project": { "name": "Project 1A", "country": "ES", "send_enabled": true, "custom_unsubscribe_url_enabled": true, "backend_domain_id": 1234, "unsubscribe_page_id": 1 } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates "success" if the project was created successfully. - **project_id** (string) - The unique identifier for the newly created project. - **project_api_key** (string) - The API key for the project, which can be used for project-specific API calls. #### Response Example ```json { "status": "success", "project_id": "6123462132634", "project_api_key": "string" } ``` #### Error Response (default) - **status** (string) - Indicates "error" if the creation failed. - **message** (string) - A message describing the error in English. - **code** (integer) - The API error code. ``` -------------------------------- ### GET /websites/godocs_unisender_ru Source: https://godocs.unisender.ru/web-api-ref Retrieves domain verification and DKIM records for a specified domain. This is essential for sending emails via Unisender Go, as it requires domain ownership confirmation and DKIM signature setup. ```APIDOC ## GET /websites/godocs_unisender_ru ### Description Retrieves domain verification and DKIM records for a specified domain. This is essential for sending emails via Unisender Go, as it requires domain ownership confirmation and DKIM signature setup. ### Method GET ### Endpoint /websites/godocs_unisender_ru ### Parameters #### Query Parameters - **domain** (string) - Required - The domain for which to obtain DNS record information. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **status** (string) - Indicates 'success'. - **domain** (string) - The domain for which the DNS records were retrieved. - **verification-record** (string) - The record to be added as is for domain ownership verification. - **dkim** (string) - The DKIM signature key for the domain. Note: The full DNS record requires prepending 'k=rsa; p=' to this value. #### Response Example ```json { "status": "success", "domain": "example.com", "verification-record": "unisender-go-validate-hash=483bb362ebdbeedd755cfb1d4d661", "dkim": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDo7" } ``` #### Error Response (Default) - **status** (string) - Indicates 'error'. - **message** (string) - An error message in English. - **code** (integer) - The API error code. ``` -------------------------------- ### Get System Info using Java Source: https://godocs.unisender.ru/web-api-ref This Java code demonstrates retrieving system information via a POST request to the specified endpoint. It uses HttpURLConnection to set request properties like method, content type, and API key, then sends an empty JSON body and processes the response code and content. ```Java URL obj = new URL("https://go1.unisender.ru/ru/transactional/api/v1/system/info.json"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type", "application/json"); con.setRequestProperty("Accept", "application/json"); con.setRequestProperty("X-API-KEY", "API_KEY"); con.setDoOutput(true); String requestBody = "{}"; try (OutputStream out = con.getOutputStream()) { out.write(requestBody.getBytes()); out.flush(); } int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(responseCode); System.out.println(response.toString()); ``` -------------------------------- ### Get Event Dumps List (PHP) Source: https://godocs.unisender.ru/web-api-ref This PHP code snippet uses the Guzzle HTTP client to fetch the event dump list. It requires the Guzzle library installed via Composer. The request includes necessary headers and an empty JSON body. ```php require 'vendor/autoload.php'; $headers = array( 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-API-KEY' => 'API_KEY', ); $client = new \GuzzleHttp\Client([ 'base_uri' => 'https://go1.unisender.ru/ru/transactional/api/v1/' ]); $requestBody = []; try { $response = $client->request('POST','event-dump/list.json', array( 'headers' => $headers, 'json' => $requestBody, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` -------------------------------- ### POST /ru/transactional/api/v1/system/info.json Source: https://godocs.unisender.ru/web-api-ref Retrieves information about the user or project associated with the provided API key. ```APIDOC ## POST /ru/transactional/api/v1/system/info.json ### Description Retrieves information about the user or project associated with the provided API key. ### Method POST ### Endpoint https://go1.unisender.ru/ru/transactional/api/v1/system/info.json ### Parameters #### Request Body - **{}** (object) - An empty JSON object is expected. ### Request Example ```json { } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the request. - **user_id** (integer) - The unique identifier for the user. - **email** (string) - The email address associated with the user account. - **project_id** (string) - The unique identifier for the project. - **project_name** (string) - The name of the project. - **project_accounting** (object) - Accounting details for the project. - **email_counter** (integer) - Current email count for the project. - **email_counter_limit** (integer) - The limit for the email counter. - **email_counter_mode** (string) - The mode of the email counter (e.g., 'default'). - **accounting** (object) - Overall accounting details. - **period_start** (string) - The start date of the accounting period. - **period_end** (string) - The end date of the accounting period. - **emails_included** (integer) - The number of emails included in the accounting period. - **emails_sent** (integer) - The total number of emails sent. #### Response Example ```json { "status": "success", "user_id": 11344, "email": "user@example.com", "project_id": "6123462132634", "project_name": "Project 1A", "project_accounting": { "email_counter": 0, "email_counter_limit": 0, "email_counter_mode": "default" }, "accounting": { "period_start": "2016-08-29 09:12:33", "period_end": "2016-09-29 09:12:33", "emails_included": 0, "emails_sent": 0 } } ``` ``` -------------------------------- ### API Email Send with Sandbox Domain (JSON) Source: https://godocs.unisender.ru/sandbox-domain Example of using the `email-send` API method to send a test email. The `from_email` parameter should be set to an address using your issued sandbox domain. ```json { "from_email": "test@sandbox-1234567-890fdd.unigosendbox.com" } ``` -------------------------------- ### Get Email Suppression Info (C#) Source: https://godocs.unisender.ru/web-api-ref This C# example shows how to use HttpClient to interact with the Unisender suppression API. It sets up the base URI, default headers, and constructs the JSON request body. The code sends a POST request and reads the response, handling success and error cases. ```csharp using System; using System.IO; using System.Text; using System.Net.Http; using System.Net.Http.Headers; class Program { static HttpClient client; public static void Main(string[] args) { client = new HttpClient(); client.BaseAddress = new Uri("https://go1.unisender.ru/ru/transactional/api/v1/"); client.DefaultRequestHeaders.Add("X-API-KEY", "API_KEY"); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); string requestBody = "{" +" \"email\": \"user@example.com\"," +" \"all_projects\": false" +"}"; var content = new StringContent(requestBody, Encoding.UTF8, "application/json"); var response = client.PostAsync("suppression/get.json", content).Result; var responseBody = response.Content.ReadAsStringAsync().Result; if(response.IsSuccessStatusCode) { Console.WriteLine(responseBody); } else { Console.WriteLine(String.Format("Request failed (HTTP {0}): {1}", (int)response.StatusCode, responseBody)); } } } ``` -------------------------------- ### Example API Response for Fetching Templates (JSON) Source: https://godocs.unisender.ru/web-api-ref This JSON structure represents a successful response from the Unisender Go API when requesting a list of templates. It includes pagination parameters and detailed information about each template, such as its ID, name, content, and sender details. The response format is consistent for requests specifying 'limit' and 'offset'. ```json { "status": "success", "templates": [ { "id": "string", "name": "string", "editor_type": "html", "template_engine": "simple", "global_substitutions": { "property1": "string", "property2": "string" }, "global_metadata": { "property1": "string", "property2": "string" }, "body": { "html": "Hello, {{to_name}}", "plaintext": "Hello, {{to_name}}", "amp": " Hello, AMP4EMAIL world." }, "subject": "Unisender Go test email", "from_email": "user@example.com", "from_name": "John Smith", "reply_to": "user@example.com", "reply_to_name": "John Smith", "track_links": 0, "track_read": 0, "headers": { "X-MyHeader": "some data", "Test-List-Unsubscribe": ", " }, "attachments": [ { "type": "text/plain", "name": "readme.txt", "content": "SGVsbG8sIHdvcmxkIQ==" } ], "inline_attachments": [ { "type": "image/gif", "name": "IMAGECID1", "content": "R0lGODdhAwADAIABAP+rAP///ywAAAAAAwADAAACBIQRBwUAOw==" } ], "created": "string", "user_id": 11344, "project_id": "6123462132634", "project_name": "Project 1A" } ] } ``` -------------------------------- ### Email Sending API Source: https://godocs.unisender.ru/velocity-example This section outlines the process of creating and sending emails using the Unisender Go API, with a focus on integrating Velocity templates. ```APIDOC ## POST /email/send ### Description This endpoint allows you to send emails. It supports the use of Velocity templating for dynamic content. You can define substitutions in the `substitutions` and `global_substitutions` parameters. ### Method POST ### Endpoint /email/send ### Parameters #### Query Parameters None #### Request Body - **api_key** (string) - Required - Your API key. - **email_template** (object) - Optional - Configuration for the email template. - **body.html** (string) - The HTML content of the email, can include Velocity and substitutions. - **body.plaintext** (string) - The plain text version of the email. - **subject** (string) - The subject of the email, can include Velocity and substitutions. - **options.unsubscribe_url** (string) - Optional - URL for unsubscribing. - **substitutions** (object) - Optional - Key-value pairs for specific email substitutions. - **global_substitutions** (object) - Optional - Key-value pairs for global substitutions applied across emails. ### Request Example ```json { "api_key": "YOUR_API_KEY", "email_template": { "body.html": "

Hello, $name!

Your order total is: $order_total

", "subject": "Order Confirmation for $order_id" }, "substitutions": { "name": "John Doe", "order_total": "$100.00" }, "global_substitutions": { "order_id": "#12345" } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation (e.g., "success"). - **message_id** (string) - The ID of the sent message. #### Response Example ```json { "status": "success", "message_id": "msg_1234567890" } ``` ``` -------------------------------- ### GET /websites/godocs_unisender_ru Source: https://godocs.unisender.ru/web-api-ref Retrieves the details of a specific webhook. This endpoint allows you to get all the configuration and status information for a given webhook. ```APIDOC ## GET /websites/godocs_unisender_ru ### Description Retrieves the details of a specific webhook. This endpoint allows you to get all the configuration and status information for a given webhook. ### Method GET ### Endpoint /websites/godocs_unisender_ru ### Parameters #### Query Parameters - **url** (string(uri)) - Required - URL of the webhook. ### Request Example ```json { "url": "http://example.com/webhook" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation, should be "success". - **object** (object) - Contains the webhook details. - **id** (integer) - Unique identifier for the webhook. - **url** (string(uri)) - The URL configured for the webhook. - **status** (string) - The current status of the webhook (e.g., "active", "disabled", "stopped"). - **event_format** (string) - The format of the event notifications (e.g., "json_post", "json_post_gzip"). - **delivery_info** (integer) - Flag to include delivery information (1) or not (0). - **single_event** (integer) - Flag to send one event per call (1) or multiple (0). - **max_parallel** (integer) - Maximum number of parallel requests allowed to your server. - **updated_at** (string(utc-date-time)) - The timestamp of the last webhook update in UTC. - **events** (object) - An object specifying which events to be notified about. - **spam_block** (array) - If present, notifications for spam blocks will be sent. Must contain "*". - **email_status** (array) - If present, notifications for email status changes will be sent. Lists the specific statuses to be notified about. #### Response Example (200) ```json { "status": "success", "object": { "id": 0, "url": "http://example.com", "status": "active", "event_format": "json_post", "delivery_info": 0, "single_event": 0, "max_parallel": 10, "updated_at": "2023-10-27 10:00:00", "events": { "spam_block": [ "*" ], "email_status": [ "delivered", "opened", "clicked", "unsubscribed", "subscribed", "soft_bounced", "hard_bounced", "spam" ] } } } ``` #### Error Response (Default) - **status** (string) - Indicates an error, should be "error". - **message** (string) - A message describing the error in English. - **code** (integer) - The API error code. #### Response Example (Default) ```json { "status": "error", "message": "An error occurred.", "code": 123 } ``` ``` -------------------------------- ### Project Methods - General Information Source: https://godocs.unisender.ru/web-api-ref Projects in Unisender Go allow you to group multiple independent domains with webhooks, templates, and unsubscribe lists. This is useful for managing data for different clients from a single Unisender Go account. Each project has its own API key, and API calls with this key will only process data for that specific project. Project methods are disabled by default for spam protection and require activation by contacting support. Domain verification can be set to be independent for each project or shared from the main account upon request to support. ```APIDOC ## Project Methods ### Description Projects allow for the grouping of multiple independent domains, webhooks, templates, and unsubscribe lists. This feature is particularly useful for managing data for separate clients from a single Unisender Go account. Each project is assigned its own API key, ensuring that API calls made with that key only interact with the data belonging to that specific project. This segregation prevents conflicts, such as an unsubscribe action in one project not affecting another. Project methods are disabled by default as a spam prevention measure. To enable them, you must contact the support team. **Domain Verification Note:** By default, sending domains are verified and used independently for the main account and each project. However, it is possible to enable the use of domains verified in the main account for projects. This can be requested from the technical support team. ### Method N/A (General information about project methods, not a specific endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ```