# Create API Key Source: https://docs.amisend.com/api-reference/apikey/create-api-key /api-reference/openapi.json post /api-keys # Delete API Key Source: https://docs.amisend.com/api-reference/apikey/delete-api-key /api-reference/openapi.json delete /api-keys/{id} # List API Keys Source: https://docs.amisend.com/api-reference/apikey/list-api-keys /api-reference/openapi.json get /api-keys # Create Audience Source: https://docs.amisend.com/api-reference/audience/create-audience /api-reference/openapi.json post /audiences # Delete Audience Source: https://docs.amisend.com/api-reference/audience/delete-audience /api-reference/openapi.json delete /audiences/{id} # List Audiences Source: https://docs.amisend.com/api-reference/audience/list-audiences /api-reference/openapi.json get /audiences # Retrieve Audience Source: https://docs.amisend.com/api-reference/audience/retrieve-audience /api-reference/openapi.json get /audiences/{id} # Create Broadcast Source: https://docs.amisend.com/api-reference/broadcast/create-broadcast /api-reference/openapi.json post /broadcasts # Delete Broadcast Source: https://docs.amisend.com/api-reference/broadcast/delete-broadcast /api-reference/openapi.json delete /broadcasts/{id} # List Broadcasts Source: https://docs.amisend.com/api-reference/broadcast/list-broadcasts /api-reference/openapi.json get /broadcasts # Retrieve Broadcast Source: https://docs.amisend.com/api-reference/broadcast/retrieve-broadcast /api-reference/openapi.json get /broadcasts/{id} # Send Broadcast Source: https://docs.amisend.com/api-reference/broadcast/send-broadcast /api-reference/openapi.json post /broadcasts/{id}/send # Unsubscribe contact from broadcast Source: https://docs.amisend.com/api-reference/broadcast/unsubscribe-contact-from-broadcast /api-reference/openapi.json patch /broadcasts/unsubscribe/{broadcastId}/{contactId} # Update Broadcast Source: https://docs.amisend.com/api-reference/broadcast/update-broadcast /api-reference/openapi.json patch /broadcasts/{id} # Create Contact Source: https://docs.amisend.com/api-reference/contact/create-contact /api-reference/openapi.json post /audiences/{id}/contacts # Delete Contact Source: https://docs.amisend.com/api-reference/contact/delete-contact /api-reference/openapi.json delete /audiences/{id}/contacts/{contactId} # Edit Contact Source: https://docs.amisend.com/api-reference/contact/edit-contact /api-reference/openapi.json put /audiences/{id}/contacts/{contactId} # List Contacts Source: https://docs.amisend.com/api-reference/contact/list-contacts /api-reference/openapi.json get /audiences/{id}/contacts # Check Domain Source: https://docs.amisend.com/api-reference/domain/check-domain /api-reference/openapi.json get /domains/{id}/check # Create Domain Source: https://docs.amisend.com/api-reference/domain/create-domain /api-reference/openapi.json post /domains # Delete Domain Source: https://docs.amisend.com/api-reference/domain/delete-domain /api-reference/openapi.json delete /domains/{id} # List Domains Source: https://docs.amisend.com/api-reference/domain/list-domains /api-reference/openapi.json get /domains # Retrieve Domain Source: https://docs.amisend.com/api-reference/domain/retrieve-domain /api-reference/openapi.json get /domains/{id} # List Emails Source: https://docs.amisend.com/api-reference/email/list-emails /api-reference/openapi.json get /emails # Send Email Source: https://docs.amisend.com/api-reference/email/send-email /api-reference/openapi.json post /emails # Introduction Source: https://docs.amisend.com/api-reference/introduction Base URL and Authentication ## Base URL All requests contain the following base URL: ```cli theme={null} https://api.amisend.com ``` ## API Key Amisend API keys are used to authenticate API requests. You can find your API keys in the [Amisend dashboard](https://amisend.com/api-keys). ## Authentication To authenticate you need to add an Authorization header with the contents of the header being Bearer ami\_xxxxxxxxx where ami\_xxxxxxxxx is your [API Key](https://amisend.com/api-keys). ```cli theme={null} Authorization: Bearer ami_xxxxxxxxx ``` # Introduction Source: https://docs.amisend.com/index The internal email API for the company's teams. ## Quickstart # Node.js SDK Source: https://docs.amisend.com/quickstart/nodejs Node.js library documentation for the Amisend API. ## Installation ```bash npm theme={null} npm install --save amisend ``` ```bash yarn theme={null} yarn add amisend ``` ### Authentication Amisend is internal: access is granted by the team, there is no public sign-up. Sign in at [amisend](https://www.amisend.com/login) and create an **API Key** from the dashboard. The key is scoped to the team it was created in. ```js theme={null} // CommonJS const Amisend = require("amisend"); // ES6 / Typescript import Amisend from "amisend"; const amisend = new Amisend({ apiKey: "YOUR_API_KEY", }); ``` ## Emails ### Send an email ```js theme={null} amisend.emails .send({ from: "Example ", to: ["example@hotmail.com"], subject: "hello world", html: "

It works!

", }) .then((response) => { // Handle response }) .catch((error) => console.log(error)); ``` ## Contacts ### Create a contact ```js theme={null} amisend.contacts .create({ audienceId: "audience-id", name: "Sebastián", email: "example@hotmail.com", }) .then((response) => { // Handle response }) .catch((error) => console.log(error)); ``` ### List contacts in an audience ```js theme={null} amisend.contacts .list({ audienceId: "audience-id", page: 1, limit: 10 }) .then((contacts) => { // Handle contacts }) .catch((error) => console.log(error)); ``` ### Update a contact ```js theme={null} amisend.contacts .update({ audienceId: "audience-id", contactId: "contact-id", name: "Sebastián Updated", }) .then((response) => { // Handle response }) .catch((error) => console.log(error)); ``` ### Delete a contact ```js theme={null} amisend.contacts .delete({ audienceId: "audience-id", contactId: "contact-id" }) .then((response) => { // Handle response }) .catch((error) => console.log(error)); ``` ## Domains ### List domains ```js theme={null} amisend.domains .list({}) .then((domains) => { // Handle domains }) .catch((error) => console.log(error)); ``` ### Create a domain ```js theme={null} amisend.domains .create({ name: "example.com" }) .then((domain) => { // Handle domain }) .catch((error) => console.log(error)); ``` ### Retrieve a domain ```js theme={null} amisend.domains .retrieve({ domainId: "domain-id" }) .then((domain) => { // Handle domain }) .catch((error) => console.log(error)); ``` ### Delete a domain ```js theme={null} amisend.domains .delete({ domainId: "domain-id" }) .then((response) => { // Handle response }) .catch((error) => console.log(error)); ``` ### Check a domain ```js theme={null} amisend.domains .check({ domainId: "domain-id" }) .then((result) => { // Handle result }) .catch((error) => console.log(error)); ``` ## Audiences ### List audiences ```js theme={null} amisend.audiences .list({ page: 1, limit: 10 }) .then((audiences) => { // Handle audiences }) .catch((error) => console.log(error)); ``` ### Create an audience ```js theme={null} amisend.audiences .create({ name: "Newsletter" }) .then((audience) => { // Handle audience }) .catch((error) => console.log(error)); ``` ### Retrieve an audience ```js theme={null} amisend.audiences .retrieve({ audienceId: "audience-id" }) .then((audience) => { // Handle audience }) .catch((error) => console.log(error)); ``` ### Delete an audience ```js theme={null} amisend.audiences .delete({ audienceId: "audience-id" }) .then((response) => { // Handle response }) .catch((error) => console.log(error)); ``` ## API Keys ### List API keys ```js theme={null} amisend.apiKeys .list({}) .then((apiKeys) => { // Handle API keys }) .catch((error) => console.log(error)); ``` ### Create an API key ```js theme={null} amisend.apiKeys .create({ name: "My Key" }) .then((apiKey) => { // Handle API key }) .catch((error) => console.log(error)); ``` ### Delete an API key ```js theme={null} amisend.apiKeys .delete({ apiKeyId: "api-key-id" }) .then((response) => { // Handle response }) .catch((error) => console.log(error)); ``` ## Broadcasts ### List broadcasts ```js theme={null} amisend.broadcasts .list({ page: 1, limit: 10 }) .then((broadcasts) => { // Handle broadcasts }) .catch((error) => console.log(error)); ``` ### Create a broadcast ```js theme={null} amisend.broadcasts .create({ name: "Promo", from: "Example ", audience: "audience-id", subject: "Promo subject", html: "

Promo content

", }) .then((broadcast) => { // Handle broadcast }) .catch((error) => console.log(error)); ``` ### Retrieve a broadcast ```js theme={null} amisend.broadcasts .retrieve({ broadcastId: "broadcast-id" }) .then((broadcast) => { // Handle broadcast }) .catch((error) => console.log(error)); ``` ### Update a broadcast ```js theme={null} amisend.broadcasts .update({ broadcastId: "broadcast-id", subject: "New subject" }) .then((broadcast) => { // Handle broadcast }) .catch((error) => console.log(error)); ``` ### Delete a broadcast ```js theme={null} amisend.broadcasts .delete({ broadcastId: "broadcast-id" }) .then((response) => { // Handle response }) .catch((error) => console.log(error)); ``` ### Send a broadcast ```js theme={null} amisend.broadcasts .send({ broadcastId: "broadcast-id" }) .then((result) => { // Handle result }) .catch((error) => console.log(error)); ``` ### Unsubscribe a contact from a broadcast ```js theme={null} amisend.broadcasts .unsubscribe({ broadcastId: "broadcast-id", contactId: "contact-id" }) .then((result) => { // Handle result }) .catch((error) => console.log(error)); ```