The official Bash command-line client for the Elastic Email REST API v4.
Installation β’ Quick start β’ Examples β’ API reference β’ Models β’ Contributing
- Transactional and bulk email. Send single messages, bulk campaigns or CSV merge-file sends.
- Contacts, lists and segments. Add, update, import, export and bulk-delete contacts.
- Campaigns and automations. Create, update, pause and trigger automations for a contact.
- Templates, files and attachments. Manage templates and uploaded files.
- Domains. Verify sending domains and check SPF, DKIM, tracking and certificate status.
- Webhooks and inbound routes. Receive delivery events and route incoming mail.
- Statistics, events and suppressions. Track delivery, bounces, complaints and unsubscribes.
- Subaccounts and security. Manage subaccounts and API keys.
- One script, no build step. A single
ElasticEmailscript built on cURL, with built-in help for every operation, a--dry-runmode and Bash/Zsh completion.
| Tool | Version |
|---|---|
| Bash | 4.3 or later |
| cURL | Any recent version |
column |
From util-linux or bsdmainutils (preinstalled on macOS and most Linux distributions) |
| OS | Linux, macOS (with a newer Bash, see below), WSL, or the bundled Docker image |
You'll also need an Elastic Email API key. You can create one in your API settings. Each endpoint's documentation lists the access level it needs.
Note
macOS ships with Bash 3.2, which is too old. Install a current Bash with brew install bash and run the script with it (/opt/homebrew/bin/bash ElasticEmail β¦, or put Homebrew's bin first in your PATH).
Download the script from the latest GitHub release and make it executable:
curl -fsSLO https://raw.githubusercontent.com/ElasticEmail/elasticemail-bash/master/ElasticEmail
chmod u+x ElasticEmail
./ElasticEmail --versionOr clone the repository:
git clone https://github.com/ElasticEmail/elasticemail-bash.git
cd elasticemail-bash
chmod u+x ElasticEmailTo run it from anywhere, copy it onto your PATH, e.g. sudo cp ElasticEmail /usr/local/bin/.
The repository includes a Dockerfile with a preconfigured environment (Bash, Zsh and working completion):
docker build -t elasticemail-cli .
docker run -it elasticemail-cliYou start in Zsh, which has richer completion. You can switch to Bash, where basic completion is also available.
Bash
Load the completion script into the current session:
source ElasticEmail.bash-completionOr install it system-wide (on macOS with Homebrew, use $(brew --prefix)/etc/bash_completion.d):
sudo cp ElasticEmail.bash-completion /etc/bash_completion.d/ElasticEmailOn macOS you might need to install bash-completion first:
brew install bash-completionand add this to ~/.bashrc:
if [ -f "$(brew --prefix)/etc/bash_completion" ]; then
. "$(brew --prefix)/etc/bash_completion"
fiZsh
Copy the _ElasticEmail completion file to one of the directories in your $fpath, e.g.:
sudo cp _ElasticEmail /usr/local/share/zsh/site-functions/Important
Elastic Email only sends from verified domains. Before your first send, verify your sending domain and use an address on that domain as the sender.
Pass the API host with --host (without the /v4 base path) and the API key as an X-ElasticEmail-ApiKey header after the operation name:
export ELASTICEMAIL_API_KEY="your-api-key"
EE_HOST="https://api.elasticemail.com"
# List available operations, then show help for one
./ElasticEmail -h
./ElasticEmail emailsTransactionalPost -h
# Load the first 10 contacts
./ElasticEmail --host "$EE_HOST" contactsGet limit=10 \
"X-ElasticEmail-ApiKey:$ELASTICEMAIL_API_KEY"Tip
Keep your API key out of scripts and shell history. Load it from an environment variable, a .env file that isn't committed, or a secrets manager.
Pipe a JSON body to the operation and pass - to read it from stdin:
cat <<'JSON' | ./ElasticEmail --host "$EE_HOST" --content-type json \
emailsTransactionalPost - "X-ElasticEmail-ApiKey:$ELASTICEMAIL_API_KEY"
{
"Recipients": { "To": ["john.doe@example.com"] },
"Content": {
"From": "My App <no-reply@yourdomain.com>",
"Subject": "Welcome aboard!",
"Body": [
{ "ContentType": "HTML", "Content": "<h1>Hello!</h1><p>Thanks for signing up.</p>" },
{ "ContentType": "PlainText", "Content": "Hello! Thanks for signing up." }
]
}
}
JSONThe From address must use a domain you've verified in your Elastic Email account.
cat <<'JSON' | ./ElasticEmail --host "$EE_HOST" --content-type json \
emailsTransactionalPost - "X-ElasticEmail-ApiKey:$ELASTICEMAIL_API_KEY"
{
"Recipients": { "To": ["john.doe@example.com"] },
"Content": {
"From": "My App <no-reply@yourdomain.com>",
"TemplateName": "welcome-template",
"Merge": { "firstname": "John" }
}
}
JSONAny cURL option placed before the operation name is passed straight to cURL. Add --dry-run to print the cURL command instead of running it:
# Print the request without sending it
./ElasticEmail --host "$EE_HOST" --dry-run contactsGet limit=10 \
"X-ElasticEmail-ApiKey:$ELASTICEMAIL_API_KEY"
# Go through a proxy, with a 30-second timeout
./ElasticEmail -x http://myProxyUrl:80 --max-time 30 --host "$EE_HOST" \
contactsGet "X-ElasticEmail-ApiKey:$ELASTICEMAIL_API_KEY"Add -sS before the operation name to hide cURL's progress meter but keep error messages.
Argument syntax
After the operation name:
| Form | Meaning |
|---|---|
KEY=VALUE |
Path or query parameter, e.g. limit=10, email=john.doe@example.com |
HEADER:VALUE |
HTTP header, e.g. X-ElasticEmail-ApiKey:β¦ |
KEY==VALUE |
Top-level JSON body field (string) |
KEY:=VALUE |
Top-level JSON body field (number or boolean) |
- |
Read the request body from stdin |
Before the operation name: --host <url>, -ct|--content-type <mime>, -ac|--accept <mime>, --dry-run, --force, -nc|--no-colors, and any cURL option.
Step-by-step scripts for common tasks are in the examples/ folder. Each one has a runnable .sh file and a walkthrough.
Show all 19 examples
More complete samples in other languages are in the Elastic Email examples repository. It covers transactional email, SMTP, webhooks, inbound email, contacts and serverless platforms across 20+ languages and frameworks.
- βοΈ SMTP quickstart with
curl - π All examples
| Scheme | Header | Used for |
|---|---|---|
apikey |
X-ElasticEmail-ApiKey |
All standard API calls |
ApiKeyAuthCustomBranding |
X-Auth-Token |
Custom-branding (white-label) accounts |
Pass the header after the operation name, e.g. "X-ElasticEmail-ApiKey:$ELASTICEMAIL_API_KEY".
- Up to 20 concurrent connections per account
- A hard timeout of 600 seconds per request
All URIs are relative to https://api.elasticemail.com/v4. The client covers 114 operations across 16 API groups: CampaignsApi, ContactsApi, DomainsApi, EmailsApi, EventsApi, FilesApi, InboundRouteApi, ListsApi, SecurityApi, SegmentsApi, StatisticsApi, SubAccountsApi, SuppressionsApi, TemplatesApi, VerificationsApi and WebhookApi. Run ./ElasticEmail <operation> -h for the parameters of any operation.
Show all endpoints
| Class | Method | HTTP request | Description |
|---|---|---|---|
| CampaignsApi | campaignsAutomationByNameTriggerPost | POST /campaigns/automation/{name}/trigger | Trigger Automation for Contact |
| CampaignsApi | campaignsByNameDelete | DELETE /campaigns/{name} | Delete Campaign |
| CampaignsApi | campaignsByNameGet | GET /campaigns/{name} | Load Campaign |
| CampaignsApi | campaignsByNamePausePut | PUT /campaigns/{name}/pause | Pause Campaign |
| CampaignsApi | campaignsByNamePut | PUT /campaigns/{name} | Update Campaign |
| CampaignsApi | campaignsGet | GET /campaigns | Load Campaigns |
| CampaignsApi | campaignsPost | POST /campaigns | Add Campaign |
| ContactsApi | contactsByEmailDelete | DELETE /contacts/{email} | Delete Contact |
| ContactsApi | contactsByEmailGet | GET /contacts/{email} | Load Contact |
| ContactsApi | contactsByEmailPut | PUT /contacts/{email} | Update Contact |
| ContactsApi | contactsDeletePost | POST /contacts/delete | Delete Contacts Bulk |
| ContactsApi | contactsExportByIdStatusGet | GET /contacts/export/{id}/status | Check Export Status |
| ContactsApi | contactsExportPost | POST /contacts/export | Export Contacts |
| ContactsApi | contactsGet | GET /contacts | Load Contacts |
| ContactsApi | contactsImportPost | POST /contacts/import | Upload Contacts |
| ContactsApi | contactsPost | POST /contacts | Add Contact |
| DomainsApi | domainsByDomainDelete | DELETE /domains/{domain} | Delete Domain |
| DomainsApi | domainsByDomainGet | GET /domains/{domain} | Load Domain |
| DomainsApi | domainsByDomainPut | PUT /domains/{domain} | Update Domain |
| DomainsApi | domainsByDomainRestrictedGet | GET /domains/{domain}/restricted | Check for domain restriction |
| DomainsApi | domainsByDomainVerificationPut | PUT /domains/{domain}/verification | Verify Domain |
| DomainsApi | domainsByEmailDefaultPatch | PATCH /domains/{email}/default | Set Default |
| DomainsApi | domainsGet | GET /domains | Load Domains |
| DomainsApi | domainsPost | POST /domains | Add Domain |
| EmailsApi | emailsByMsgidViewGet | GET /emails/{msgid}/view | View Email |
| EmailsApi | emailsByTransactionidStatusGet | GET /emails/{transactionid}/status | Get Status |
| EmailsApi | emailsMergefilePost | POST /emails/mergefile | Send Bulk Emails CSV |
| EmailsApi | emailsPost | POST /emails | Send Bulk Emails |
| EmailsApi | emailsTransactionalPost | POST /emails/transactional | Send Transactional Email |
| EventsApi | eventsByTransactionidGet | GET /events/{transactionid} | Load Email Events |
| EventsApi | eventsChannelsByNameExportPost | POST /events/channels/{name}/export | Export Channel Events |
| EventsApi | eventsChannelsByNameGet | GET /events/channels/{name} | Load Channel Events |
| EventsApi | eventsChannelsExportByIdStatusGet | GET /events/channels/export/{id}/status | Check Channel Export Status |
| EventsApi | eventsExportByIdStatusGet | GET /events/export/{id}/status | Check Export Status |
| EventsApi | eventsExportPost | POST /events/export | Export Events |
| EventsApi | eventsGet | GET /events | Load Events |
| FilesApi | filesByNameDelete | DELETE /files/{name} | Delete File |
| FilesApi | filesByNameGet | GET /files/{name} | Download File |
| FilesApi | filesByNameInfoGet | GET /files/{name}/info | Load File Details |
| FilesApi | filesGet | GET /files | List Files |
| FilesApi | filesPost | POST /files | Upload File |
| InboundRouteApi | inboundrouteByIdDelete | DELETE /inboundroute/{id} | Delete Route |
| InboundRouteApi | inboundrouteByIdGet | GET /inboundroute/{id} | Get Route |
| InboundRouteApi | inboundrouteByIdPut | PUT /inboundroute/{id} | Update Route |
| InboundRouteApi | inboundrouteGet | GET /inboundroute | Get Routes |
| InboundRouteApi | inboundrouteOrderPut | PUT /inboundroute/order | Update Sorting |
| InboundRouteApi | inboundroutePost | POST /inboundroute | Create Route |
| ListsApi | listsByListnameContactsGet | GET /lists/{listname}/contacts | Load Contacts in List |
| ListsApi | listsByNameContactsPost | POST /lists/{name}/contacts | Add Contacts to List |
| ListsApi | listsByNameContactsRemovePost | POST /lists/{name}/contacts/remove | Remove Contacts from List |
| ListsApi | listsByNameDelete | DELETE /lists/{name} | Delete List |
| ListsApi | listsByNameGet | GET /lists/{name} | Load List |
| ListsApi | listsByNamePut | PUT /lists/{name} | Update List |
| ListsApi | listsGet | GET /lists | Load Lists |
| ListsApi | listsPost | POST /lists | Add List |
| SecurityApi | securityApikeysByNameDelete | DELETE /security/apikeys/{name} | Delete ApiKey |
| SecurityApi | securityApikeysByNameGet | GET /security/apikeys/{name} | Load ApiKey |
| SecurityApi | securityApikeysByNamePut | PUT /security/apikeys/{name} | Update ApiKey |
| SecurityApi | securityApikeysGet | GET /security/apikeys | List ApiKeys |
| SecurityApi | securityApikeysPost | POST /security/apikeys | Add ApiKey |
| SecurityApi | securitySmtpByNameDelete | DELETE /security/smtp/{name} | Delete SMTP Credential |
| SecurityApi | securitySmtpByNameGet | GET /security/smtp/{name} | Load SMTP Credential |
| SecurityApi | securitySmtpByNamePut | PUT /security/smtp/{name} | Update SMTP Credential |
| SecurityApi | securitySmtpGet | GET /security/smtp | List SMTP Credentials |
| SecurityApi | securitySmtpPost | POST /security/smtp | Add SMTP Credential |
| SegmentsApi | segmentsByNameDelete | DELETE /segments/{name} | Delete Segment |
| SegmentsApi | segmentsByNameGet | GET /segments/{name} | Load Segment |
| SegmentsApi | segmentsByNamePut | PUT /segments/{name} | Update Segment |
| SegmentsApi | segmentsGet | GET /segments | Load Segments |
| SegmentsApi | segmentsPost | POST /segments | Add Segment |
| StatisticsApi | statisticsCampaignsByNameGet | GET /statistics/campaigns/{name} | Load Campaign Stats |
| StatisticsApi | statisticsCampaignsGet | GET /statistics/campaigns | Load Campaigns Stats |
| StatisticsApi | statisticsChannelsByNameGet | GET /statistics/channels/{name} | Load Channel Stats |
| StatisticsApi | statisticsChannelsGet | GET /statistics/channels | Load Channels Stats |
| StatisticsApi | statisticsGet | GET /statistics | Load Statistics |
| SubAccountsApi | subaccountsByEmailApikeyGet | GET /subaccounts/{email}/apikey | Get SubAccount ApiKey |
| SubAccountsApi | subaccountsByEmailCreditsPatch | PATCH /subaccounts/{email}/credits | Add, Subtract Email Credits |
| SubAccountsApi | subaccountsByEmailDelete | DELETE /subaccounts/{email} | Delete SubAccount |
| SubAccountsApi | subaccountsByEmailGet | GET /subaccounts/{email} | Load SubAccount |
| SubAccountsApi | subaccountsByEmailSettingsEmailPut | PUT /subaccounts/{email}/settings/email | Update SubAccount Email Settings |
| SubAccountsApi | subaccountsGet | GET /subaccounts | Load SubAccounts |
| SubAccountsApi | subaccountsPost | POST /subaccounts | Add SubAccount |
| SuppressionsApi | suppressionsBouncesGet | GET /suppressions/bounces | Get Bounce List |
| SuppressionsApi | suppressionsBouncesImportPost | POST /suppressions/bounces/import | Add Bounces Async |
| SuppressionsApi | suppressionsBouncesPost | POST /suppressions/bounces | Add Bounces |
| SuppressionsApi | suppressionsByEmailDelete | DELETE /suppressions/{email} | Delete Suppression |
| SuppressionsApi | suppressionsByEmailGet | GET /suppressions/{email} | Get Suppression |
| SuppressionsApi | suppressionsComplaintsGet | GET /suppressions/complaints | Get Complaints List |
| SuppressionsApi | suppressionsComplaintsImportPost | POST /suppressions/complaints/import | Add Complaints Async |
| SuppressionsApi | suppressionsComplaintsPost | POST /suppressions/complaints | Add Complaints |
| SuppressionsApi | suppressionsGet | GET /suppressions | Get Suppressions |
| SuppressionsApi | suppressionsUnsubscribesGet | GET /suppressions/unsubscribes | Get Unsubscribes List |
| SuppressionsApi | suppressionsUnsubscribesImportPost | POST /suppressions/unsubscribes/import | Add Unsubscribes Async |
| SuppressionsApi | suppressionsUnsubscribesPost | POST /suppressions/unsubscribes | Add Unsubscribes |
| TemplatesApi | templatesByNameDelete | DELETE /templates/{name} | Delete Template |
| TemplatesApi | templatesByNameGet | GET /templates/{name} | Load Template |
| TemplatesApi | templatesByNamePut | PUT /templates/{name} | Update Template |
| TemplatesApi | templatesGet | GET /templates | Load Templates |
| TemplatesApi | templatesPost | POST /templates | Add Template |
| VerificationsApi | verificationsByEmailDelete | DELETE /verifications/{email} | Delete Email Verification Result |
| VerificationsApi | verificationsByEmailGet | GET /verifications/{email} | Get Email Verification Result |
| VerificationsApi | verificationsByEmailPost | POST /verifications/{email} | Verify Email |
| VerificationsApi | verificationsFilesByIdDelete | DELETE /verifications/files/{id} | Delete File Verification Result |
| VerificationsApi | verificationsFilesByIdResultDownloadGet | GET /verifications/files/{id}/result/download | Download File Verification Result |
| VerificationsApi | verificationsFilesByIdResultGet | GET /verifications/files/{id}/result | Get Detailed File Verification Result |
| VerificationsApi | verificationsFilesByIdVerificationPost | POST /verifications/files/{id}/verification | Start verification |
| VerificationsApi | verificationsFilesPost | POST /verifications/files | Upload File with Emails |
| VerificationsApi | verificationsFilesResultGet | GET /verifications/files/result | Get Files Verification Results |
| VerificationsApi | verificationsGet | GET /verifications | Get Emails Verification Results |
| WebhookApi | webhookByPublicidDelete | DELETE /webhook/{publicid} | Delete Webhook |
| WebhookApi | webhookByPublicidGet | GET /webhook/{publicid} | Load Webhook |
| WebhookApi | webhookByPublicidPut | PUT /webhook/{publicid} | Update Webhook |
| WebhookApi | webhookGet | GET /webhook | Load Webhooks |
| WebhookApi | webhookPost | POST /webhook | Add Webhook |
Show all 98 models
- AccessLevel
- AccountStatusEnum
- ApiKey
- ApiKeyPayload
- BodyContentType
- BodyPart
- Campaign
- CampaignOptions
- CampaignRecipient
- CampaignStatus
- CampaignTemplate
- CertificateValidationStatus
- ChannelLogStatusSummary
- CompressionFormat
- ConsentData
- ConsentTracking
- Contact
- ContactActivity
- ContactPayload
- ContactSource
- ContactStatus
- ContactUpdatePayload
- ContactsList
- DKIMRecord
- DeliveryOptimizationType
- DomainData
- DomainDetail
- DomainOwner
- DomainPayload
- DomainUpdatePayload
- EmailContent
- EmailData
- EmailJobFailedStatus
- EmailJobStatus
- EmailMessageData
- EmailPredictedValidationStatus
- EmailRecipient
- EmailSend
- EmailStatus
- EmailTransactionalMessageData
- EmailValidationResult
- EmailValidationStatus
- EmailView
- EmailsPayload
- EncodingType
- EventType
- EventsOrderBy
- ExportFileFormats
- ExportLink
- ExportStatus
- FileInfo
- FilePayload
- FileUploadResult
- InboundPayload
- InboundRoute
- InboundRouteActionType
- InboundRouteFilterType
- ListPayload
- ListUpdatePayload
- LogJobStatus
- LogStatusSummary
- MergeEmailPayload
- MessageAttachment
- MessageCategory
- MessageCategoryEnum
- NewApiKey
- NewSmtpCredentials
- Options
- RecipientEvent
- Segment
- SegmentPayload
- SmtpCredentials
- SmtpCredentialsPayload
- SortOrderItem
- SplitOptimizationType
- SplitOptions
- SubAccountInfo
- SubaccountEmailCreditsPayload
- SubaccountEmailSettings
- SubaccountEmailSettingsPayload
- SubaccountPayload
- SubaccountSettingsInfo
- SubaccountSettingsInfoPayload
- Suppression
- Template
- TemplatePayload
- TemplateScope
- TemplateType
- TrackingType
- TrackingValidationStatus
- TransactionalRecipient
- Utm
- VerificationFileResult
- VerificationFileResultDetails
- VerificationStatus
- Webhook
- WebhookCreatePayload
- WebhookUpdatePayload
- The generated script also sends your API key as an
X-Auth-Tokenheader, and the malformed extra header makes cURL printcurl: (3) URL rejected: Malformed input to a URL function. The request itself is still sent and the API response is returned. Use--dry-runto see the exact command.
The client follows the Elastic Email API v4. Versions and release notes are listed in GitHub Releases. The current version is in the VERSION file.
Build details
- API version: 4.0.0
- SDK version: 4.2.0
- Generator version: 7.11.0
- Build package:
org.openapitools.codegen.languages.BashClientCodegen
Contributions are welcome! Most of this client is generated from the Elastic Email OpenAPI specification, so please read CONTRIBUTING.md before opening a pull request.
- π Report a bug
- π‘ Request a feature
- π Report a security issue
This project follows the Contributor Covenant Code of Conduct.
Important
The fastest way to get help is the chat widget on elasticemail.com. Our support team can help with your account, sending, deliverability and API questions.
- π¬ Chat with support on elasticemail.com (preferred)
- π API documentation
- π§ͺ Examples repository
- π GitHub issues, for bugs in this SDK only
Released under the MIT License. Copyright Β© 2021β2026 Elastic Email.