API Senders

An API sender delivers emails through an HTTP API instead of SMTP. For each recipient Phishing Club sends one HTTP request built from your URL, headers and body, so any service with an HTTP API can deliver the lure: a mail API, a chat platform, an SMS gateway and so on. For APIs that need an access token, attach an OAuth provider.

API Senders

Where: Emails > API Senders

To deliver a campaign through an API sender, set Delivery Type to External API in the template and pick the sender under API Sender. The template's email supplies the content.

Deleting an API sender makes the templates that use it unusable and closes scheduled or active campaigns that use it right away, also when they have a later close time.

Create API sender

Click New API sender. The form has these sections.

API sender fields
Field Description
Name Name of the sender, up to 64 characters
Request URL The API endpoint, up to 255 characters. Supports template variables.
Request Method GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD, TRACE or CONNECT
API Key Optional key, available as {{.APIKey}}
OAuth Provider Optional. An authorized OAuth provider whose access token is available as {{.OAuthAccessToken}}. The token is refreshed automatically before it expires.
Request Headers Optional. One header per line in the form Key: value. Supports template variables.
Request Body Optional. The request body, for example JSON. Supports template variables.
Expected response code Required. The HTTP status code that means the request worked, for example 200 or 202. Any other code marks the send as failed.
Header matches Optional. One Key: value per line. Each response header must contain its value, or the send is marked as failed.
Response contains Optional. Text that must appear in the response body, or the send is marked as failed.
Custom field 1 to Custom field 4 Optional values, up to 255 characters each, available as {{.CustomField1}} to {{.CustomField4}}

Each request times out after 10 seconds.

Send test

Choose Send test in the row menu. Fill in the test values (From Email, From Name, Email, First Name, Last Name, Subject and Content), and use Add variable for other recipient fields such as Phone or Department. Click Run test to send a real request. The modal then shows the request that was sent and the response status, headers and body, or the error.

Template Variables

The Request URL, Request Headers and Request Body support all email template variables and template functions, such as {{.Email}}, {{.FirstName}}, {{.URL}} and {{.Subject}}. API senders add these:

API sender variables
Variable Description
{{.Content}} The email content with all variables filled in, escaped for use inside a JSON string. Put it between quotes: "html": "{{.Content}}". Request Body only.
{{.ContentRaw}} The email content with all variables filled in, not escaped. Request Body only.
{{.APIKey}} The API Key field
{{.OAuthAccessToken}} Access token of the attached OAuth provider
{{.CustomField1}} to {{.CustomField4}} The custom field values

Examples

Header with an OAuth token:

Authorization: Bearer {{.OAuthAccessToken}}

JSON body:

{
  "to": "{{.Email}}",
  "from": "{{.FromEmail}}",
  "subject": "{{.Subject}}",
  "html": "{{.Content}}",
  "name": "{{.FirstName}} {{.LastName}}"
}

URL with escaped parameters:

https://api.example.com/send?email={{urlEscape .Email}}&id={{.rID}}

Header with a base64 encoded key:

X-Custom-Auth: {{base64 .APIKey}}

SMS text with a look alike domain:

Your parcel is waiting: {{.URL | hostUpper "i" 1}}

With the domain mizzil.tld this sends https://mIzzil.tld/.... Only the case of the host changes, so the link still works.