Welcome to Inboxroad WEBApi's documentation! ============================================ Indices and tables ================== * `Overview`_ * `How to obtain token`_ * `How to send a message`_ * `Interactive `_ .. _Overview: Overview ================== Inboxroad is a company that allows you to send millions of emails per day for fair price. We provide emails servers for sending campaigns, personal letters and many other thing. We encourage our costumers to create campaigns using our services. WEB Api is a service that can help you to develop/integrate you solution for ability to send emails. WEB Api is a similar to the Amazon SES and Sendgrid. But instead of playing around with bad APIs and figuring out `How` it works you can try it. Our API gives you all the functionality for sending letter but with a single HTTP request as well as an ability to fully customize it. Getting Started ================== 1. Before you start you have to get profile and account in the system. It can be easily obtained by following the `link `_ 2. Obtain an Api token. `How to obtain token`_ 3. Sending message. `How to send a message`_ .. _How to obtain token: Obtain a token ================== For obtaining an API token for profiles, send a ``POST`` request to the endpoint: ``https://webapi.inboxroad.com/api/token/`` There is also interactive version where you can try out sending requests: `link `_ The payload for the request should be a ``JSON`` of the following type: .. code-block:: { "username": "string", "password": "string" } *All fields are required!* Examples: .. code-tabs:: .. code-tab:: bash :title: Bash curl --location --request POST 'https://webapi.inboxroad.com/api/token/' \ --header 'Content-Type: application/json' \ --data-raw '{ "username": "test@test.test", "passowrd": "etesttes" }' .. code-tab:: python :title: Python import requests import json url = "https://webapi.inboxroad.com/api/token/" payload = {"username": "test@test.test", "password": "etestetst"} response = requests.post(url, json=payload) print(response.text) .. code-tab:: php :title: PHP setRequestUrl('https://webapi.inboxroad.com/api/token/'); $request->setRequestMethod('POST'); $body = new http\Message\Body; $body->append('{ "username": "test@test.test", "passowrd": "etesttes" }'); $request->setBody($body); $request->setOptions(array()); $request->setHeaders(array( 'Content-Type' => 'application/json' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody();> .. code-tab:: ruby :title: Ruby require "uri" require "net/http" url = URI("https://webapi.inboxroad.com/api/token/") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = "application/json" request.body = "{\n \"username\": \"test@test.test\",\n \"passowrd\": \"etesttes\"\n}" response = https.request(request) puts response.read_body .. _How to send a message: Sending message ================== Before sending a message retrieve a token. :ref: How to obtain token Token should be provided in headers as an ``Authorization`` header with following format: ``Basic `` To send a message provide a ``POST`` request with a ``JSON`` payload for the endpoint: ``https://webapi.inboxroad.com/api/v1/messages/`` The payload should be the following format: .. code-block:: { "from_email": "user@example.com", "from_name": "string", "to_email": "user@example.com", "to_name": "string", "reply_to_email": "user@example.com", "reply_to_name": "string", "subject": "string", "text": "string", "headers": {}, "html": "string", "attachments": [ { "filename": "string", "mime_type": "string", "file_data": "base64_string" } ]} .. list-table:: Required fields :widths: 25 150 :header-rows: 1 * - Field name - Description * - from_email - ``string`` - a valid email like string that represent from whom this email was sent of * - to_email - ``string`` - a valid email like string that is presenting a person who would receive an email * - text - ``string`` - a text field that contains a body of the message. If ``html`` is empty this field is ``required`` * - html - ``string`` - a html formatted string field that contains html template for the email. If ``text`` is empty this field is ``required`` For more details and interactive behaviour please visit this `link `_ Examples: .. code-tabs:: .. code-tab:: bash :title: Bash curl --location --request POST 'https://webapi.inboxroad.com/api/v1/messages' \ --header 'Authorization: Basic ' \ --header 'Content-Type: application/json' \ --data-raw '{ "from_email": "example@example.com", "from_name": "Example", "to_email": "example@example.com", "to_name": "Example", "reply_to_email": "example@example.com", "reply_to_name": "Example", "subject": "Example", "text": "Example", "html": "

example@example.com

" }' .. code-tab:: python :title: Python import requests url = "https://webapi.inboxroad.com/api/v1/messages" payload={ "from_email": "example@example.com", "from_name": "Example", "to_email": "example@example.com", "to_name": "Example", "reply_to_email": "example@example.com", "reply_to_name": "Example", "subject": "Example", "text": "Example", "html": "

example@example.com

" } headers = { 'Authorization': 'Basic ', 'Content-Type': 'application/json' } response = requests.post(url, headers=headers, json=payload) print(response.text) .. code-tab:: php :title: PHP setRequestUrl('https://webapi.inboxroad.com/api/v1/messages'); $request->setRequestMethod('POST'); $body = new http\Message\Body; $body->append('{ "from_email": "example@example.com", "from_name": "Example", "to_email": "example@example.com", "to_name": "Example", "reply_to_email": "example@example.com", "reply_to_name": "Example", "subject": "Example", "text": "Example", "html": "

example@example.com

" }'); $request->setBody($body); $request->setOptions(array()); $request->setHeaders(array( 'Authorization' => 'Basic ', 'Content-Type' => 'application/json' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody();> .. code-tab:: ruby :title: Ruby require "uri" require "net/http" url = URI("https://webapi.inboxroad.com/api/v1/messages") http = Net::HTTP.new(url.host, url.port); request = Net::HTTP::Post.new(url) request["Authorization"] = "Basic " request["Content-Type"] = "application/json" request.body = "{\n \"from_email\": \"example@example.com\",\n \"from_name\": \"Example\",\n \"to_email\": \"example@example.com\",\n \"to_name\": \"Example\",\n \"reply_to_email\": \"example@example.com\",\n \"reply_to_name\": \"Example\",\n \"subject\": \"Example\",\n \"text\": \"Example\",\n \"html\": \"

example@example.com

\"\n}" response = http.request(request) puts response.read_body