### Add Webhook API Endpoint
Source: https://developers.smtp2go.com/docs/setup-a-webhook
This example demonstrates how to add a new webhook using the SMTP2GO API. It includes common events and specifies the target URL and usernames for triggering the webhook.
```APIDOC
## POST /v3/webhook/add
### Description
Adds a new webhook to your account to receive event notifications.
### Method
POST
### Endpoint
https://api.smtp2go.com/v3/webhook/add
### Parameters
#### Request Body
- **events** (array) - Required - A list of email events that will trigger the webhook (e.g., "open", "click", "bounce").
- **usernames** (array) - Required - A list of SMTP Users or API Keys for which the webhook should trigger.
- **url** (string) - Required - The URL endpoint where the webhook data will be POSTed.
### Request Example
```json
{
"events": [
"open",
"click",
"bounce"
],
"usernames": [
"api-*********APIKey**************",
"Usernametest123"
],
"url": "https//webhook.example.com/webhook12345"
}
```
### Response
#### Success Response (200)
(Response schema not provided in source)
#### Response Example
(Response example not provided in source)
```
--------------------------------
### Search for Bounced Emails
Source: https://developers.smtp2go.com/docs/view-account-activity
This example demonstrates how to search for soft and hard bounces within a specific date range for a given sender. It utilizes parameters such as start_date, end_date, search_sender, event_types, and limit.
```APIDOC
## POST /v3/activity/search
### Description
Searches the email activity log for specific events based on provided criteria.
### Method
POST
### Endpoint
https://api.smtp2go.com/v3/activity/search
### Headers
- Content-Type: application/json
- X-Smtp2go-Api-Key: api-xxxxxxxxxxxx
- accept: application/json
### Request Body
- **start_date** (string) - Required - The start date for the search (YYYY-MM-DD).
- **end_date** (string) - Required - The end date for the search (YYYY-MM-DD).
- **event_types** (array of strings) - Required - A list of event types to filter by (e.g., "soft-bounced", "hard-bounced").
- **search_sender** (string) - Required - The email address of the sender to search for.
- **limit** (integer) - Optional - The maximum number of results to return.
### Request Example
```curl
curl --request POST \
--url https://api.smtp2go.com/v3/activity/search \
--header 'Content-Type: application/json' \
--header 'X-Smtp2go-Api-Key: api-xxxxxxxxxxxx' \
--header 'accept: application/json' \
--data '{
"start_date": "2024-02-11",
"end_date": "2024-02-13",
"event_types": [
"soft-bounced",
"hard-bounced"
],
"search_sender": "sender@example.com",
"limit": 1
}'
```
### Response
#### Success Response (200)
- **request_id** (string) - Unique identifier for the request.
- **data** (object) - Contains the search results.
- **events** (array) - A list of email events matching the search criteria.
- **from** (string) - The sender's email address.
- **recipient** (string) - The recipient's email address.
- **subaccount_name** (string) - The name of the subaccount used.
- **email_id** (string) - The unique identifier for the email.
- **date** (string) - The date and time the event occurred.
- **event** (string) - The type of event (e.g., "hard-bounced").
- **subject** (string) - The subject of the email.
- **username** (string) - The username associated with the sending account.
- **sender** (string) - The sender's email address.
- **sender_full** (string) - The sender's full email address.
- **to** (string) - The recipient's email address.
- **smtp_response** (string) - The SMTP server response.
- **host** (string) - The host that processed the email.
- **outbound_ip** (string) - The outbound IP address used.
- **byte_size** (integer) - The size of the email in bytes.
- **total_events** (integer) - The total number of events found.
- **continue_token** (string) - A token to retrieve the next batch of results if the limit was reached.
#### Response Example (Success)
```json
{
"request_id": "82aff18a-ca05-11ee-8a81-f23c9216ce11",
"data": {
"events": [
{
"from": "sender@example.com",
"recipient": "hello@example.com",
"subaccount_name": "Master account",
"email_id": "1rZPGW-u6wXBO-2m",
"date": "2024-02-12T05:54:07Z",
"event": "hard-bounced",
"subject": "Test bounce",
"username": "TestUser",
"sender": "sender@example.com",
"sender_full": "sender@example.com",
"to": "hello@example.com",
"smtp_response": "550-5.1.1 The email account that you tried to reach does not exist. Please try\\n550-5.1.1 double-checking the recipient's email address for typos or\\n550-5.1.1 unnecessary spaces. For more information, go to\\n550 5.1.1 https://support.google.com/mail/?p=NoSuchUser n13-20020a05622a040d00b0042bf4b5caf6si7967427qtx.480 - gsmtp",
"host": "142.xxx.xxx.xx",
"outbound_ip": "103.47.206.44",
"byte_size": 1068
}
],
"total_events": 3,
"continue_token": "eyJhbGciO***********"
}
}
```
#### Response Example (Error)
```json
{
"request_id": "ce3fc5b4-ca08-11ee-bd82-f23c93560c0e",
"data": {
"error": "An error occurred processing the json data you sent with the request. Please make sure the data conforms to the specification for this call (see the documentation here: https://developers.smtp2go.com/reference/introduction) and try again. Don\'t forget to set Content-Type to 'application/json'.",
"error_code": "E_ApiResponseCodes.NON_VALIDATING_IN_PAYLOAD",
"field_validation_errors": {
"fieldname": "event_types",
"message": "The field 'event_types' was expecting a value from the allowed list ['processed', 'soft-bounced', 'hard-bounced', 'rejected', 'spam', 'delivered', 'unsubscribed', 'resubscribed', 'opened', 'clicked'] but instead found '['example']', Please correct your JSON payload and try again."
}
}
}
```
```
--------------------------------
### Successful Search Response
Source: https://developers.smtp2go.com/docs/view-account-activity
A 200 response indicates a successful search. This example shows a hard bounce event. Note the 'continue_token' which can be used to retrieve subsequent results if the total events exceed the specified limit.
```json
{
"request_id": "82aff18a-ca05-11ee-8a81-f23c9216ce11",
"data": {
"events": [
{
"from": "sender@example.com",
"recipient": "hello@example.com",
"subaccount_name": "Master account",
"email_id": "1rZPGW-u6wXBO-2m",
"date": "2024-02-12T05:54:07Z",
"event": "hard-bounced",
"subject": "Test bounce",
"username": "TestUser",
"sender": "sender@example.com",
"sender_full": "sender@example.com",
"to": "hello@example.com",
"smtp_response": "550-5.1.1 The email account that you tried to reach does not exist. Please try\\n550-5.1.1 double-checking the recipient's email address for typos or\\n550-5.1.1 unnecessary spaces. For more information, go to\\n550 5.1.1 https://support.google.com/mail/?p=NoSuchUser n13-20020a05622a040d00b0042bf4b5caf6si7967427qtx.480 - gsmtp",
"host": "142.xxx.xxx.xx",
"outbound_ip": "103.47.206.44",
"byte_size": 1068
}
],
"total_events": 3,
"continue_token": "eyJhbGciO***********"
}
}
```
--------------------------------
### Common Error Response Example
Source: https://developers.smtp2go.com/docs/response-codes
This JSON structure represents a common error response from the API, detailing the error message and a specific error code.
```json
{
"error": "Failed to remove the single sender email - An error occurred deleting sender email asdfa@asdf.com or it doesn't exist",
"error_code": "E_ApiResponseCodes.API_EXCEPTION"
}
```
--------------------------------
### Email Send Error Response
Source: https://developers.smtp2go.com/docs/send-an-email
A 400 response signifies a request failure, providing an error code and a descriptive message. This example shows a permission denied error.
```json
{
"request_id": "22e5acba-43bf-11e6-ae42-408d5cce2644",
"data": {
"error_code": "E_ApiResponseCodes.ENDPOINT_PERMISSION_DENIED",
"error": "You do not have permission to access this API endpoint"
}
}
```
--------------------------------
### Error Response with Field Validation
Source: https://developers.smtp2go.com/docs/response-codes
This JSON example shows an error response that includes field-specific validation errors, useful for debugging payload issues.
```json
{
"error": "An error occurred processing the json data you sent with the request, please make sure the data conforms to the specification for this call (see the documentation here: https://apidoc.smtp2go.com/documentation/#/README) and try again. Don't forget to set Content-Type to 'application/json'.",
"error_code": "E_ApiResponseCodes.NON_VALIDATING_IN_PAYLOAD",
"field_validation_errors": {
"fieldname": "sender",
"message": "The field 'sender' was expecting a valid RFC-822 formatted email field but found 'robs_invalid.com', Please correct your JSON payload and try again."
}
}
```
--------------------------------
### Define Template Variables
Source: https://developers.smtp2go.com/docs/getting-started-with-templates
When editing HTML, encapsulate variables within double braces {{ variable_name }}. This example shows a username variable.
```html
Welcome {{ username }}!
```
--------------------------------
### Failed Search Response (Invalid Event Type)
Source: https://developers.smtp2go.com/docs/view-account-activity
A 400 response indicates a failed request. This example shows an error due to an incorrect value in the 'event_types' field. The response includes details about the error and field validation.
```json
{
"request_id": "ce3fc5b4-ca08-11ee-bd82-f23c93560c0e",
"data": {
"error": "An error occurred processing the json data you sent with the request. Please make sure the data conforms to the specification for this call (see the documentation here: https://developers.smtp2go.com/reference/introduction) and try again. Don't forget to set Content-Type to 'application/json'.",
"error_code": "E_ApiResponseCodes.NON_VALIDATING_IN_PAYLOAD",
"field_validation_errors": {
"fieldname": "event_types",
"message": "The field 'event_types' was expecting a value from the allowed list ['processed', 'soft-bounced', 'hard-bounced', 'rejected', 'spam', 'delivered', 'unsubscribed', 'resubscribed', 'opened', 'clicked'] but instead found '['example']', Please correct your JSON payload and try again."
}
}
}
```
--------------------------------
### URL Format and Security
Source: https://developers.smtp2go.com/docs/webhooks-overview
Details on the format of webhook URLs and how to secure them.
```APIDOC
## URL Format
Each 'URL of web service' that you enter must follow the URI standard.
E.g.
PROTOCOL "://" USER ":" PASSWORD "@" HOST "/" PATH "?" QUERY "#" FRAGMENT
with most parts of that being optional.
PROTOCOL can be either HTTP or HTTPS.
USER and PASSWORD are only required if you choose to password protect your web service.
## Secure the URL
You can optionally secure your public URL with a username/password, with formats such as the following (the URLs given below are just examples):
`https://USERNAME:PASSWORD@host.yourdomain.com/webhook/smtp2go`
`https://host.yourdomain.com/webhook/smtp2go?p=PASSWORD`
or simply make the name of the endpoint hard to guess:
`https://host.yourdomain.com/webhook/smtp2go_PASSWORD`
```
--------------------------------
### Activity Search Endpoint
Source: https://developers.smtp2go.com/docs/view-account-activity
The /activity/search endpoint allows you to search email events from your account’s “Reports > Activity” page matching the criteria in your request. Accounts on the free plan can search up to 5 days of event history and paid plans up to 30 days by default. If paid plans utilize the Activity Duration feature to extend the storage (from 60 days up to 2 years) then event history will be available for the selected timeframe. The request can return up to a maximum of 1,000 events by default and if the response exceeds that, a continue_token will be provided to retrieve the remaining results.
```APIDOC
## GET /activity/search
### Description
Searches email events based on specified criteria.
### Method
GET
### Endpoint
/activity/search
### Parameters
#### Query Parameters
- **start_date** (date) - Optional - ISO-8601 formatted datetime which defaults to the current date at midnight. The range will be inclusive of start_date and exclusive of end_date. The timezone is UTC.
- **end_date** (date) - Optional - ISO-8601 formatted datetime which defaults to now. The timezone is UTC.
- **search** (string) - Optional - If passed, will return all events for emails containing this string in the Email_id, Subject, To, Recipient or BCC fields. To return events with one or more text values, separate the text with '|' (e.g. 'text1 | text2').
- **search_subject** (string) - Optional - If passed, will return all events for emails containing this string in the email subject.
- **search_sender** (string) - Optional - If passed, will return all events for emails containing this string in the email sender.
- **search_recipient** (string) - Optional - If passed, will return all events for emails containing this string in the email recipient.
- **search_usernames** (Array of strings) - Optional - If passed, will return all events for emails sent by this/these username/s.
- **subaccounts** (Array of strings) - Optional - If passed, will return all events for emails sent by this/these subaccount/s.
- **limit** (int32) - Optional - The maximum number of events to return (Max: 1000).
- **continue_token** (string) - Optional - If passed, will continue the search beyond the current page, using the same search parameters.
- **only_latest** (boolean) - Optional - If true, will only return the most recent event for each email returned. Default: false.
- **only_latest_by_sent** (boolean) - Optional - If true, will only return the most recent event for each email returned ordered by sent date. Default: false
- **event_types** (array of strings) - Optional - If passed, will limit the returned events to the provided event types. Values: 'processed', 'soft-bounced', 'hard-bounced', 'rejected', 'spam', 'delivered', 'unsubscribed', 'resubscribed', 'opened' and 'clicked.'
- **include_headers** (boolean) - Optional - Return the full email headers with the response.
- **custom_headers** (array of strings) - Optional - A list of header keys to parse out of the raw headers.
### Response
#### Success Response (200)
- **events** (array) - List of email events matching the search criteria.
- **continue_token** (string) - Token to retrieve the next page of results if the response exceeds the limit.
#### Response Example
{
"events": [
{
"event_id": "evt_12345",
"email_id": "msg_abcde",
"subaccount_id": "sub_fghij",
"timestamp": "2023-10-27T10:00:00Z",
"msg_from": "sender@example.com",
"recipient": "recipient@example.com",
"subject": "Test Email",
"event_type": "delivered",
"smtp_response": "250 OK",
"custom_headers": {
"X-Custom-Header": "Value"
}
}
],
"continue_token": "next_page_token_xyz"
}
```
--------------------------------
### Add SMTP User
Source: https://developers.smtp2go.com/docs/api-features-guide
Create a new SMTP user with specified authentication and settings.
```APIDOC
## POST /users/smtp/add
### Description
Add a new SMTP user.
### Method
POST
### Endpoint
/users/smtp/add
### Request Body
- **username** (string) - Required - The username for the new SMTP user.
- **password** (string) - Required - The password for the new SMTP user.
- **settings** (object) - Optional - Configuration settings for the user.
- **unsubscribe_footer** (boolean) - Enable unsubscribe footer.
- **open_tracking** (boolean) - Enable open tracking.
- **click_tracking** (boolean) - Enable click tracking.
- **user_status** (string) - 'active' or 'inactive'.
- **email_archiving** (boolean) - Enable email archiving.
- **email_auditing** (boolean) - Enable email auditing.
- **rate_limit** (integer) - Maximum emails per minute.
### Request Example
```json
{
"username": "newuser@yourdomain.com",
"password": "securepassword123",
"settings": {
"user_status": "active",
"rate_limit": 50
}
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
#### Response Example
```json
{
"status": "ok"
}
```
```
--------------------------------
### Webhooks API
Source: https://developers.smtp2go.com/docs/api-features-guide
Set up and manage webhooks to receive instant notifications from SMTP2GO about account events.
```APIDOC
## Webhooks API
### Add Webhook
**Method:** POST
**Endpoint:** /webhook/add
### View Webhooks
**Method:** GET
**Endpoint:** /webhook/view
### Edit Webhook
**Method:** POST
**Endpoint:** /webhook/edit
### Remove Webhook
**Method:** POST
**Endpoint:** /webhook/remove
```
--------------------------------
### Attachment via URL
Source: https://developers.smtp2go.com/docs/adding-attachments
Use the 'url' parameter to specify a web address from which SMTP2GO will fetch the attachment. This method speeds up sending and caches the attachment for 24 hours, reducing repeated data transfers.
```json
"attachments": [
{
"filename": "test.jpg",
"url": "https://mydomain.com/myimage.jpg,
"mimetype": "image/jpeg"
}
]
```
--------------------------------
### Add a Webhook using cURL
Source: https://developers.smtp2go.com/docs/setup-a-webhook
Use this cURL command to add a new webhook programmatically via the API. It specifies the events that trigger the webhook, the associated usernames, and the URL to send the data to. Ensure you replace placeholder API keys and usernames with your actual credentials.
```curl
curl --request POST \
--url https://api.smtp2go.com/v3/webhook/add \
--header 'Content-Type: application/json' \
--header 'X-Smtp2go-Api-Key: api-*********APIKey**************' \
--header 'accept: application/json' \
--data '
{
"events": [
"open",
"click",
"bounce"
],
"usernames": [
"api-*********APIKey**************",
"Usernametest123"
],
"url": "https//webhook.example.com/webhook12345"
}
'
```
--------------------------------
### Send Email
Source: https://developers.smtp2go.com/docs/send-an-email
This endpoint allows you to send an email. It requires your API key, sender address, recipient address, subject, and text body.
```APIDOC
## POST /email/send
### Description
Sends an email using the SMTP2GO API.
### Method
POST
### Endpoint
https://api.smtp2go.com/v3/email/send
### Headers
- **Content-Type**: application/json
- **X-Smtp2go-Api-Key**: Your unique API Key
- **accept**: application/json
### Request Body
- **sender** (string) - Required - The email address from which to send the email. Must be a verified sender.
- **to** (array of strings) - Required - A list of recipient email addresses.
- **subject** (string) - Required - The subject line of the email.
- **text_body** (string) - Required - The plain text content of the email.
### Request Example
```json
{
"sender": "email@example.com",
"to": [
"friend@example.com"
],
"subject": "My First Email",
"text_body": "Hello from the other side."
}
```
### Response
#### Success Response (200 OK)
- **request_id** (string) - Unique identifier for the request.
- **data** (object) - Contains details about the email sending status.
- **succeeded** (integer) - Number of emails successfully sent.
- **failed** (integer) - Number of emails that failed to send.
- **failures** (array) - List of failures, if any.
- **email_id** (string) - The ID of the sent email.
#### Success Response Example
```json
{
"request_id": "aa253464-0bd0-467a-b24b-6159dcd7be60",
"data": {
"succeeded": 1,
"failed": 0,
"failures": [],
"email_id": "1er8bV-6Tw0Mi-7h"
}
}
```
#### Error Response (400 Bad Request)
- **request_id** (string) - Unique identifier for the request.
- **data** (object) - Contains error details.
- **error_code** (string) - The error code.
- **error** (string) - A description of the error.
#### Error Response Example
```json
{
"request_id": "22e5acba-43bf-11e6-ae42-408d5cce2644",
"data": {
"error_code": "E_ApiResponseCodes.ENDPOINT_PERMISSION_DENIED",
"error": "You do not have permission to access this API endpoint"
}
}
```
```
--------------------------------
### Send Standard Email Request Headers
Source: https://developers.smtp2go.com/docs/send-an-email
This snippet shows the necessary headers for making a POST request to the /email/send endpoint. Ensure your API key is included in the X-Smtp2go-Api-Key header.
```curl
curl --request POST \
--url https://api.smtp2go.com/v3/email/send \
--header 'Content-Type: application/json' \
--header 'X-Smtp2go-Api-Key: api-xxxx YOUR API KEY xxxx' \
--header 'accept: application/json' \
```
--------------------------------
### Webhook Request Method
Source: https://developers.smtp2go.com/docs/webhooks-overview
SMTP2GO sends a POST request to your webhook URL.
```APIDOC
## Webhook Request
SMTP2GO sends a POST (not a GET) request to your URL with the data output type of "JSON" or "Form encoded" depending on what type is defined in the webhook's settings.
```
--------------------------------
### Verify Sender Domain
Source: https://developers.smtp2go.com/docs/api-features-guide
Initiate the verification process for a sender domain to enable SPF and DKIM.
```APIDOC
## POST /domain/verify
### Description
Verify a sender domain.
### Method
POST
### Endpoint
/domain/verify
### Request Body
- **domain** (string) - Required - The domain name to verify.
### Request Example
```json
{
"domain": "example.com"
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
- **verification_details** (object) - DNS records required for verification.
- **spf** (string) - SPF record value.
- **dkim** (string) - DKIM record value.
#### Response Example
```json
{
"status": "ok",
"verification_details": {
"spf": "v=spf1 include:_spf.smtp2go.com ~all",
"dkim": "k=rsa; p=MIGf..."
}
}
```
```
--------------------------------
### Send MIME Email
Source: https://developers.smtp2go.com/docs/api-features-guide
Send an email using a pre-composed MIME string. SMTP2GO will use this exact string to send the email.
```APIDOC
## POST /email/mime
### Description
Send an email using a pre-composed MIME string.
### Method
POST
### Endpoint
/email/mime
### Request Body
- **to** (string) - Required - The recipient's email address.
- **mime_message** (string) - Required - The complete MIME message as a string.
### Request Example
```json
{
"to": "recipient@example.com",
"mime_message": "From: sender@example.com\r\nTo: recipient@example.com\r\nSubject: Test MIME Email\r\nContent-Type: text/plain; charset=\"utf-8\"\r\n\r\nThis is the body of the MIME email."
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
- **message_id** (string) - The unique identifier for the sent email.
#### Response Example
```json
{
"status": "ok",
"message_id": "abcdef1234567890"
}
```
```
--------------------------------
### View Sender Domains
Source: https://developers.smtp2go.com/docs/api-features-guide
Retrieve a list of all sender domains configured for your account.
```APIDOC
## GET /domain/view
### Description
View all configured sender domains.
### Method
GET
### Endpoint
/domain/view
### Response
#### Success Response (200)
- **sender_domains** (array) - A list of sender domain objects.
- Each object contains details like `domain`, `is_verified`, `tracking_domain`, `return_path_domain`.
#### Response Example
```json
{
"sender_domains": [
{
"domain": "example.com",
"is_verified": true,
"tracking_domain": "track.example.com",
"return_path_domain": "bounces.example.com"
}
]
}
```
```
--------------------------------
### Send Standard Email
Source: https://developers.smtp2go.com/docs/api-features-guide
Send an email by providing all its components, such as sender, subject, body, and recipient, as a JSON object.
```APIDOC
## POST /email/send
### Description
Send an email by passing all email components as a JSON object.
### Method
POST
### Endpoint
/email/send
### Request Body
- **to** (string) - Required - The recipient's email address.
- **sender** (string) - Required - The sender's email address.
- **subject** (string) - Required - The subject of the email.
- **text_body** (string) - Optional - The plain text content of the email.
- **html_body** (string) - Optional - The HTML content of the email.
### Request Example
```json
{
"to": "recipient@example.com",
"sender": "sender@example.com",
"subject": "Test Email",
"text_body": "This is a plain text email.",
"html_body": "This is an HTML email.
"
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
- **message_id** (string) - The unique identifier for the sent email.
#### Response Example
```json
{
"status": "ok",
"message_id": "abcdef1234567890"
}
```
```
--------------------------------
### Full cURL Request with Fileblob Attachment
Source: https://developers.smtp2go.com/docs/adding-attachments
A complete cURL command demonstrating how to send an email with a PDF attachment using the fileblob method. Ensure your API key and email addresses are correctly substituted.
```curl
curl --request POST \
--url https://api.smtp2go.com/v3/email/send \
--header 'Content-Type: application/json' \
--header 'X-Smtp2go-Api-Key: api-xxxxxxxxxxxxxxxxxx' \
--header 'accept: application/json' \
--data '
{
"sender": "email@example.com",
"to": [
"friend@example.com"
],
"subject": "SMTP2GO attachment",
"text_body": "Hello - find the email attached",
"attachments": [
{
"filename": "testfile.pdf",
"fileblob": "--base64-data--",
"mimetype": "application/pdf"
}
]
}'
```
--------------------------------
### Edit Return Path Domain
Source: https://developers.smtp2go.com/docs/api-features-guide
Configure or update the return path (bounce) domain for a sender domain.
```APIDOC
## POST /domain/returnpath
### Description
Edit the return path domain for a sender domain.
### Method
POST
### Endpoint
/domain/returnpath
### Request Body
- **domain** (string) - Required - The sender domain.
- **return_path_domain** (string) - Required - The new return path domain.
### Request Example
```json
{
"domain": "example.com",
"return_path_domain": "bounces.example.com"
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
#### Response Example
```json
{
"status": "ok"
}
```
```
--------------------------------
### Add Sender Domain
Source: https://developers.smtp2go.com/docs/api-features-guide
Add a new sender domain to your account for verification.
```APIDOC
## POST /domain/add
### Description
Add a new sender domain.
### Method
POST
### Endpoint
/domain/add
### Request Body
- **domain** (string) - Required - The domain name to add.
### Request Example
```json
{
"domain": "newdomain.com"
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
#### Response Example
```json
{
"status": "ok"
}
```
```
--------------------------------
### Search Account Activity
Source: https://developers.smtp2go.com/docs/api-features-guide
Search for email events such as bounces, opens, and unsubscribes within your account.
```APIDOC
## GET /activity/search
### Description
Search account activity logs, including bounces, opens, and unsubscribes.
### Method
GET
### Endpoint
/activity/search
### Query Parameters
- **search_sender** (string) - Optional - Filter activity by sender email address.
- **search_recipient** (string) - Optional - Filter activity by recipient email address.
- **event_type** (string) - Optional - Filter by event type (e.g., 'bounce', 'open', 'unsubscribe').
- **date_from** (string) - Optional - Filter activity from this date (YYYY-MM-DD).
- **date_to** (string) - Optional - Filter activity up to this date (YYYY-MM-DD).
### Response
#### Success Response (200)
- **activity** (array) - A list of account activity events.
- Each object contains details like `event_type`, `timestamp`, `sender`, `recipient`.
#### Response Example
```json
{
"activity": [
{
"event_type": "open",
"timestamp": "2023-10-27T12:00:00Z",
"sender": "sender@example.com",
"recipient": "recipient@example.com"
}
]
}
```
```
--------------------------------
### View SMTP Users
Source: https://developers.smtp2go.com/docs/api-features-guide
Retrieve a list of all configured SMTP users for your account.
```APIDOC
## GET /users/smtp/view
### Description
View all configured SMTP users.
### Method
GET
### Endpoint
/users/smtp/view
### Response
#### Success Response (200)
- **smtp_users** (array) - A list of SMTP user objects.
- Each object contains details like `username`, `status`, `rate_limit`.
#### Response Example
```json
{
"smtp_users": [
{
"username": "user1@yourdomain.com",
"status": "active",
"rate_limit": 100
}
]
}
```
```
--------------------------------
### View Allowed Senders
Source: https://developers.smtp2go.com/docs/api-features-guide
Retrieve the list of allowed sender email addresses or domains.
```APIDOC
## GET /allowed_senders/view
### Description
View the list of allowed sender email addresses or domains.
### Method
GET
### Endpoint
/allowed_senders/view
### Response
#### Success Response (200)
- **allowed_senders** (array) - A list of allowed sender entries.
- Each entry specifies whether it's an 'allowlist' or 'blocklist' and the sender/domain.
#### Response Example
```json
{
"allowed_senders": [
{
"type": "allowlist",
"value": "example.com"
},
{
"type": "allowlist",
"value": "specific@example.net"
}
]
}
```
```
--------------------------------
### IP Allowlist API
Source: https://developers.smtp2go.com/docs/api-features-guide
Configure and manage your IP allowlist to restrict sending to specific IP addresses for enhanced security.
```APIDOC
## IP Allowlist API
### IP Allowlist Management
**Method:** GET
**Endpoint:** /ip_allow_list
### Add IP to Allowlist
**Method:** POST
**Endpoint:** /ip_allow_list/add
### Edit IP Allowlist Entry
**Method:** POST
**Endpoint:** /ip_allow_list/edit
### Remove IP from Allowlist
**Method:** POST
**Endpoint:** /ip_allow_list/remove
### View IP Allowlist
**Method:** GET
**Endpoint:** /ip_allow_list/view
```
--------------------------------
### Send Standard Email
Source: https://developers.smtp2go.com/docs/send-an-email
Send a standard email by providing email components like sender, recipient, and subject as a JSON object. This endpoint supports various parameters for customizing the email.
```APIDOC
## POST /email/send
### Description
Send a standard email using the API by passing email components as a JSON object. This endpoint allows for customization with various parameters.
### Method
POST
### Endpoint
https://api.smtp2go.com/v3/email/send
### Parameters
#### Request Body
- **sender** (string) - Required - The email address to send from.
- **to** (array of strings) - Required - An array of email addresses (up to 100) to send to.
- **cc** (array of strings) - Optional - An array of email addresses (up to 100) to cc.
- **bcc** (array of strings) - Optional - An array of email addresses (up to 100) to bcc.
- **subject** (string) - Required - The subject of the email to be sent.
- **html_body** (string) - Optional - An HTML encoded email body.
- **text_body** (string) - Optional - A plain text email body.
- **custom_headers** (array of objects) - Optional - An array of custom header objects to be applied to the email.
- **attachments** (array of objects) - Optional - An array of attachment objects to be attached to the email.
- **inlines** (array of objects) - Optional - An array of images to be inlined into the email.
- **template_id** (string) - Optional - The ID of the template you wish to use.
- **template_data** (json) - Optional - When a template_id is provided, include the pass-through values in the format {"variable1": "value1", "variable2": "value2"}.
### Request Example
```json
{
"sender": "email@example.com",
"to": [
"friend@example.com"
],
"subject": "My First Email",
"text_body": "Hello from the other side."
}
```
### Response
#### Success Response (200)
- **message_id** (string) - The unique identifier for the sent message.
- **status** (string) - The status of the email sending operation (e.g., "sent").
#### Response Example
```json
{
"message_id": "<20230101000000.abcdef@example.com>",
"status": "sent"
}
```
```
--------------------------------
### Successful Email Send Response
Source: https://developers.smtp2go.com/docs/send-an-email
A 200 OK response indicates the email was successfully queued for sending. The response includes a request ID and data on succeeded and failed deliveries.
```json
{
"request_id": "aa253464-0bd0-467a-b24b-6159dcd7be60",
"data": {
"succeeded": 1,
"failed": 0,
"failures": [],
"email_id": "1er8bV-6Tw0Mi-7h"
}
}
```
--------------------------------
### Add Allowed Sender
Source: https://developers.smtp2go.com/docs/api-features-guide
Add a new email address or domain to the allowed senders list.
```APIDOC
## POST /allowed_senders/add
### Description
Add an email address or domain to the allowed senders list.
### Method
POST
### Endpoint
/allowed_senders/add
### Request Body
- **type** (string) - Required - Either 'allowlist' or 'blocklist'.
- **value** (string) - Required - The email address or domain to add.
### Request Example
```json
{
"type": "allowlist",
"value": "newdomain.com"
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
#### Response Example
```json
{
"status": "ok"
}
```
```
--------------------------------
### Send Templated Email
Source: https://developers.smtp2go.com/docs/getting-started-with-templates
This endpoint allows you to send an email using a specified template and provides data to populate the template.
```APIDOC
## POST /v3/email/send
### Description
Sends an email using a specified template and populates it with provided data.
### Method
POST
### Endpoint
https://api.smtp2go.com/v3/email/send
### Request Body
- **sender** (string) - Required - The email address of the sender.
- **to** (array of strings) - Required - A list of recipient email addresses.
- **subject** (string) - Required - The subject line of the email.
- **html_body** (string) - Optional - The HTML content of the email.
- **text_body** (string) - Optional - The plain text content of the email.
- **version** (integer) - Required - The version of the email template to use.
- **template_id** (string) - Required - The ID of the template to use.
- **template_data** (object) - Optional - Key-value pairs to populate the template.
- **username** (string) - Example field for template data.
- **plan** (string) - Example field for template data.
### Request Example
```json
{
"sender": "john@example.com",
"to": [
"jane@example.com"
],
"subject": "My Test Email",
"html_body": "Test
",
"text_body": "Test",
"version": 1,
"template_id": "userwelcome",
"template_data": {
"username": "mikejasonsmith",
"plan": "deluxe"
}
}
```
### Response
#### Success Response (200)
- **request_id** (string) - Unique identifier for the request.
- **data** (object) - Contains the status of the email sending operation.
- **succeeded** (integer) - Number of emails successfully sent.
- **failed** (integer) - Number of emails that failed to send.
- **failures** (array) - List of failures, if any.
- **email_id** (string) - The ID of the email sent.
#### Response Example
```json
{
"request_id": "44f1d836-d299-11ed-86ad-f23c9216bfec",
"data": {
"succeeded": 1,
"failed": 0,
"failures": [],
"email_id": "1pjXOz-9EGeSN-09"
}
}
```
```
--------------------------------
### Email Webhook Parameters
Source: https://developers.smtp2go.com/docs/webhooks-overview
The Webhook URL will receive an HTTP or HTTPS POST request with the following parameters. These parameters provide details about various email events.
```APIDOC
## Webhook Parameters - Email
The Webhook URL will receive an HTTP or HTTPS POST request with the following parameters:
| Parameter | Description |
| :-------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ |
| event | What happened: "processed", "delivered", "open", "click", "bounce", "spam", "unsubscribe", "resubscribe", or "reject". |
| time | UTC timestamp of when the event happened. |
| sendtime | UTC timestamp of when the email was sent to our server. |
| sender | The 'envelope-from' email address. |
| from | The display name (where available) and email address the email was sent from. |
| from_address | The email address the email was sent from. |
| from_name | The display name set to accompany the email address (where available). |
| rcpt | The email address the email was addressed to. |
| recipients | The email addresses the email was sent to. |
| auth | The SMTP Username, API Key or IP Address used to send the email. |
| host | The recipient server that bounced the message (bounce only). |
| message | The error message we got (where available). |
| context | Contains additional information on the event (where available). |
| email_id | An identifier that uniquely identifies the email, which can be used to retrieve further details of the email delivery. |
| id | The unique id for the webhook. |
| message-id | The unique id from the sender. |
| bounce | This parameter will be included for a bounce event, and will be either hard or soft, depending on how we classify the bounce type. |
| subject | The subject of the email. |
| user-agent | The "User-Agent" header of the device that opened the email (where applicable) |
| read-secs | The number of seconds an email was open - in five second increments up to a maximum of 30 (where applicable). |
| client | The reported client that clicked/opened the link (based on the User-Agent). |
| client-device | The reported device type of the User-Agent associated with the open/click event (where available). |
| client-os | The reported device operating system of the User-Agent associated with the open/click event (where available). |
| geoip-continent | A 2 character continent code based on a geoip lookup of the IP address associated with the open/click event (where available). |
| geoip-country | A 2 character country code based on a geoip lookup of the IP address associated with the open/click event (where available). |
| geoip-city | The name of the city based on a geoip lookup of the IP address associated with the open/click event (where available). |
```
--------------------------------
### API Key Authentication in HTTP Header
Source: https://developers.smtp2go.com/docs/getting-started
Authenticate API requests by including your API key in the 'X-Smtp2go-Api-Key' header. This method is an alternative to including the key in the JSON payload.
```json
{
'Content-Type': 'application/json',
'X-Smtp2go-Api-Key': 'YourAPIKeyHere'
}
```
--------------------------------
### Template Management API Endpoints
Source: https://developers.smtp2go.com/docs/getting-started-with-templates
These endpoints allow you to programmatically manage your email templates.
```APIDOC
## POST /template/add
### Description
Adds a new email template that you can use to format your emails.
### Endpoint
/template/add
```
```APIDOC
## POST /template/edit
### Description
Changes details of an existing email template.
### Endpoint
/template/edit
```
```APIDOC
## POST /template/delete
### Description
Deletes the specified email template.
### Endpoint
/template/delete
```
```APIDOC
## POST /template/search
### Description
Searches your collection of email templates. Returns any templates that match your search criteria.
### Endpoint
/template/search
```
```APIDOC
## POST /template/view
### Description
Returns details of the email template with the specified ID.
### Endpoint
/template/view
```
--------------------------------
### Templates API
Source: https://developers.smtp2go.com/docs/api-features-guide
Manage email templates within your account for integration and personalization when sending emails via the API.
```APIDOC
## Templates API
### Add Email Template
**Method:** POST
**Endpoint:** /template/add
### Edit Email Template
**Method:** POST
**Endpoint:** /template/edit
### Delete Email Template
**Method:** POST
**Endpoint:** /template/delete
### Search Email Templates
**Method:** GET
**Endpoint:** /template/search
### View Template Details
**Method:** GET
**Endpoint:** /template/view
```