### Install AutoSend Convex Component with AI Assistant Source: https://docs.autosend.com/guides/convex Use this prompt with your AI coding assistant to generate a setup checklist for the AutoSend Convex component. It includes installation commands, documentation links, environment variable requirements, and verification steps. ```text Help me install the AutoSend component. Package: @autosend/convex Install: npm install @autosend/convex Documentation: - https://www.convex.dev/components/autosend/convex/convex.md - https://www.convex.dev/components/autosend/convex/llms.txt Please: 1. Retrieve the install command and documentation 2. Generate an exact setup checklist for this component 3. List any required environment variables 4. Provide verification steps ``` -------------------------------- ### Install QStash SDK Source: https://docs.autosend.com/guides/QStash Install the QStash JavaScript SDK using npm. ```bash npm install @upstash/qstash ``` -------------------------------- ### Install AutoSend and Convex SDK Source: https://docs.autosend.com/guides/convex Install the necessary packages using npm, pnpm, or yarn. ```bash npm install @autosend/convex convex ``` ```bash pnpm add @autosend/convex convex ``` ```bash yarn add @autosend/convex convex ``` -------------------------------- ### Install AutoSend SDK with npm Source: https://docs.autosend.com/sdk/nodejs Install the AutoSend SDK using npm. ```bash npm install autosendjs ``` -------------------------------- ### Install AutoSend SDK with yarn Source: https://docs.autosend.com/sdk/nodejs Install the AutoSend SDK using yarn. ```bash yarn add autosendjs ``` -------------------------------- ### Install AutoSend SDK with pnpm Source: https://docs.autosend.com/sdk/nodejs Install the AutoSend SDK using pnpm. ```bash pnpm add autosendjs ``` -------------------------------- ### Install Better Auth with npm Source: https://docs.autosend.com/guides/better-auth Install the Better Auth package using npm. Ensure you have Node.js and npm installed on your system. ```bash npm install better-auth ``` -------------------------------- ### Get Domain Details (JavaScript) Source: https://docs.autosend.com/api-reference/domains/get This JavaScript example demonstrates how to retrieve domain information using the `fetch` API. It sets the Authorization header and logs the JSON response to the console. ```javascript const response = await fetch( "https://api.autosend.com/v1/domains/60d5ec49f1b2c72d9c8b1111", { method: "GET", headers: { Authorization: "Bearer ", }, } ); const data = await response.json(); console.log(data); ``` -------------------------------- ### Retrieve Custom Field by Name (Go) Source: https://docs.autosend.com/api-reference/custom-fields/get-by-name Employ Go's standard `net/http` package to construct and execute a GET request. Set the Authorization header with your token. This example demonstrates basic HTTP client usage in Go. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { req, _ := http.NewRequest("GET", "https://api.autosend.com/v1/custom-fields/fieldName/planTier", nil) req.Header.Set("Authorization", "Bearer ") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Install AutoSend Skill Source: https://docs.autosend.com/ai/skills Run this command in your project root to install the AutoSend skill. It automatically detects your AI agent and installs the skill file. ```bash npx skills add https://github.com/autosendhq/skills --skill AutoSend ``` -------------------------------- ### Install Swaks on Windows Source: https://docs.autosend.com/quickstart/smtp Install Swaks on Windows using Chocolatey, a package manager. ```bash # Using Chocolatey choco install swaks ``` -------------------------------- ### Install Swaks on Ubuntu/Debian Source: https://docs.autosend.com/quickstart/smtp Use apt-get to install Swaks on Ubuntu or Debian-based Linux distributions. ```bash sudo apt-get install swaks ``` -------------------------------- ### Response Example for Get Contact Property Source: https://docs.autosend.com/api-reference/contact-properties/get-by-name This is an example of a successful response when retrieving a contact property by name. It includes success status, a message, and the data for the requested property. ```json { "success": true, "message": "Contact property retrieved successfully", "data": { "id": "69c258bae3e715c0521153fb", "name": "isVerified", "type": "boolean", "fieldName": "isVerified", "fieldType": "boolean", "createdAt": "2026-03-24T09:26:18.826Z", "updatedAt": "2026-03-24T09:26:18.826Z" } } ``` -------------------------------- ### Get Suppression Group by ID Source: https://docs.autosend.com/api-reference/suppression-groups/get This example demonstrates how to retrieve a suppression group using its ID. ```APIDOC ## GET /v1/suppression-groups/{groupId} ### Description Retrieves the details of a specific suppression group by its unique identifier. ### Method GET ### Endpoint /v1/suppression-groups/{groupId} ### Parameters #### Path Parameters - **groupId** (string) - Required - The unique identifier of the suppression group to retrieve. #### Request Example ```bash curl --request GET \ --url 'https://api.autosend.com/v1/suppression-groups/AB12C3' \ --header 'Authorization: Bearer ' ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the suppression group details. - **data.id** (string) - Unique identifier for the suppression group. - **data.groupId** (string) - Short identifier used in path parameters. - **data.name** (string) - Display name of the suppression group. - **data.description** (string) - Optional description of the suppression group. - **data.isActive** (boolean) - Whether the suppression group is active. - **data.isGlobal** (boolean) - Whether this is a global suppression group. - **data.suppressionCount** (integer) - Number of email addresses suppressed in this group. - **data.createdAt** (string) - ISO 8601 timestamp when the group was created. - **data.updatedAt** (string) - ISO 8601 timestamp when the group was last updated. #### Response Example ```json { "success": true, "data": { "id": "60d5ec49f1b2c72d9c8b4567", "groupId": "AB12C3", "name": "Marketing Unsubscribes", "description": "Users who opted out of marketing", "isActive": true, "isGlobal": false, "suppressionCount": 42, "createdAt": "2026-01-10T08:00:00.000Z", "updatedAt": "2026-04-15T12:30:00.000Z" } } ``` ``` -------------------------------- ### Create Project using Go Source: https://docs.autosend.com/api-reference/projects/create-project A Go program demonstrating how to create a project via the API. It constructs a JSON payload, sets up an HTTP POST request with necessary headers, and prints the response. ```go package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { url := "https://api.autosend.com/v1/account/projects" payload := map[string]interface{}{ "name": "My New Project", "domain": "example.com", "regionKey": "us-east-1", } jsonData, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("Authorization", "Bearer ASA_your-admin-api-key") req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error:", err) return } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Create Campaign using Go Source: https://docs.autosend.com/api-reference/campaigns/create This Go program demonstrates creating a campaign by making an HTTP POST request. It marshals the campaign data into JSON and sets the required headers. ```go package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "name": "Spring Sale Newsletter", "subject": "Don't miss our Spring Sale!", "previewText": "Up to 50% off this weekend only", "from": map[string]string{ "email": "hello@example.com", "name": "Example Team", }, "replyTo": "support@example.com", "templateId": "60d5ec49f1b2c72d9c8b1234", "toLists": []string{"60d5ec49f1b2c72d9c8b0001"}, "sendMode": "immediate", "publish": true, "sendNow": true, "trackingClick": true, "trackingOpen": true, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.autosend.com/v1/campaigns", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` -------------------------------- ### Get Event - Successful Response Example Source: https://docs.autosend.com/api-reference/events/get-event Represents a successful retrieval of an event definition. Includes a success flag and the event data. ```json { "success": true, "data": { "id": "evt_a1b2c3d4e5f6", "eventName": "order_completed", "description": "Customer completed an order", "properties": [ { "propertyName": "order_id", "type": "string", "description": "ID of the order", "suggestedValues": [] } ], "createdAt": "2023-01-01T12:00:00Z", "updatedAt": "2023-01-01T12:00:00Z" } } ``` -------------------------------- ### List Campaigns with Filters (Go) Source: https://docs.autosend.com/api-reference/campaigns/list This Go program demonstrates how to send an HTTP GET request to list campaigns. It shows how to create a request, set headers, and read the response body. ```go package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.autosend.com/v1/campaigns?status=draft&page=1&limit=20", nil) req.Header.Set("Authorization", "Bearer ") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Get Webhook by ID (Ruby) Source: https://docs.autosend.com/api-reference/webhooks/get-webhook Retrieve a webhook by its ID using Ruby. This example uses the `net/http` library and requires your project API key for authorization. ```ruby require 'net/http' require 'uri' webhook_id = '60d5ec49f1b2c72d9c8b1234' uri = URI("https://api.autosend.com/v1/webhooks/#{webhook_id}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri.request_uri) request['Authorization'] = 'Bearer AS_your-api-key' response = http.request(request) puts response.body ``` -------------------------------- ### Create Campaign using JavaScript Source: https://docs.autosend.com/api-reference/campaigns/create This JavaScript example shows how to create a campaign using the `fetch` API. It sends a POST request with the campaign details in the request body. ```javascript const response = await fetch('https://api.autosend.com/v1/campaigns', { method: 'POST', headers: { Authorization: 'Bearer ', 'Content-Type': 'application/json', }, body: JSON.stringify({ name: 'Spring Sale Newsletter', subject: "Don't miss our Spring Sale!", previewText: 'Up to 50% off this weekend only', from: { email: 'hello@example.com', name: 'Example Team', }, replyTo: 'support@example.com', templateId: '60d5ec49f1b2c72d9c8b1234', toLists: ['60d5ec49f1b2c72d9c8b0001'], sendMode: 'immediate', publish: true, sendNow: true, trackingClick: true, trackingOpen: true, }), }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Webhook by ID (Go) Source: https://docs.autosend.com/api-reference/webhooks/get-webhook A Go program to retrieve a webhook by its ID. This example uses the standard `net/http` package and requires your project API key. ```go package main import ( "fmt" "io" "net/http" ) func main() { webhookID := "60d5ec49f1b2c72d9c8b1234" url := "https://api.autosend.com/v1/webhooks/" + webhookID req, _ := http.NewRequest("GET", url, nil) req.Header.Set("Authorization", "Bearer AS_your-api-key") client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error:", err) return } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Get Webhook by ID (JavaScript) Source: https://docs.autosend.com/api-reference/webhooks/get-webhook Example of retrieving a webhook using its ID in JavaScript. This code uses the `fetch` API and requires your project API key. ```javascript const webhookId = '60d5ec49f1b2c72d9c8b1234'; fetch(`https://api.autosend.com/v1/webhooks/${webhookId}`, { method: 'GET', headers: { 'Authorization': 'Bearer AS_your-api-key' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### List Projects using Go Source: https://docs.autosend.com/api-reference/projects/list-projects This Go program fetches all projects for your organization. It demonstrates making an HTTP GET request with the necessary authorization header. ```go package main import ( "fmt" "io" "net/http" ) func main() { url := "https://api.autosend.com/v1/account/projects" req, _ := http.NewRequest("GET", url, nil) req.Header.Set("Authorization", "Bearer ASA_your-admin-api-key") client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error:", err) return } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Create a Contact List Source: https://docs.autosend.com/api-reference/contact-lists/create This example demonstrates how to create a new contact list by sending a POST request to the /contact-lists endpoint. ```APIDOC ## POST /v1/contact-lists ### Description Creates a new contact list or segment within your project. ### Method POST ### Endpoint /v1/contact-lists ### Parameters #### Request Body - **name** (string) - Required - Name of the contact list (max 200 characters). Must be unique within the project. - **description** (string) - Optional - Description of the contact list (max 500 characters). - **type** (string) - Optional - Type of contact list. Allowed values: `list`, `segment`. Default: `list`. - **filterCriteria** (object) - Optional - Filter criteria for segments. Required when `type` is `segment`. - **logicalOperator** (string) - Required - Logical operator for combining groups. Allowed values: `AND`, `OR`. - **groups** (object[]) - Required - Array of filter conditions. - **field** (string) - Required - Contact field to filter on. - **fieldType** (string) - Required - Data type of the field. Allowed values: `string`, `number`, `boolean`, `date`. - **operator** (string) - Required - Filter operator. Available operators depend on the field type. - **value** (any) - Optional - Value to compare against. Not required for unary operators like `is_empty` and `is_not_empty`. - **parentId** (string) - Optional - ID of the parent contact list (for creating sub-segments). ### Request Example ```json { "name": "Newsletter Subscribers", "description": "Users who signed up for the weekly newsletter", "type": "list" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (object) - Contains the details of the created contact list. - **id** (string) - Unique identifier for the contact list. - **name** (string) - Name of the contact list. - **description** (string) - Description of the contact list. - **type** (string) - Type of the contact list (`list` or `segment`). - **contactCount** (number) - The number of contacts in the list. - **createdAt** (string) - Timestamp when the contact list was created. - **updatedAt** (string) - Timestamp when the contact list was last updated. #### Response Example ```json { "success": true, "data": { "id": "60d5ec49f1b2c72d9c8b4567", "name": "Newsletter Subscribers", "description": "Users who signed up for the weekly newsletter", "type": "list", "contactCount": 0, "createdAt": "2026-03-17T10:30:00.000Z", "updatedAt": "2026-03-17T10:30:00.000Z" } } ``` ### Authorizations - **Authorization** (string | header) - Required - Bearer authentication header of the form Bearer ``, where `` is your auth token. ``` -------------------------------- ### List Custom Fields Source: https://docs.autosend.com/api-reference/custom-fields/list This example demonstrates how to retrieve a list of custom fields using a GET request to the /v1/custom-fields endpoint. It includes the necessary Authorization header. ```APIDOC ## GET /v1/custom-fields ### Description Retrieves a list of all custom fields associated with your account. You can optionally exclude reserved fields. ### Method GET ### Endpoint https://api.autosend.com/v1/custom-fields ### Parameters #### Query Parameters - **includeReservedFields** (boolean) - Optional - Whether to include built-in reserved fields (email, firstName, lastName, createdAt, userId) in the response. Defaults to `true`. ### Request Example ```http GET /v1/custom-fields HTTP/1.1 Host: api.autosend.com Authorization: Bearer ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates whether the request was successful. - **message** (string) - Confirmation message. - **data** (object) - Contains the custom fields data. - **data.customFields** (array) - Array of custom field objects. - **id** (string) - Unique identifier of the custom field. - **fieldName** (string) - The programmatic name of the custom field. - **fieldType** (string) - The data type: `string`, `number`, `boolean`, or `date`. - **createdAt** (string) - ISO 8601 timestamp when the field was created. - **updatedAt** (string) - ISO 8601 timestamp when the field was last updated. #### Response Example ```json { "success": true, "message": "Custom fields retrieved successfully", "data": { "customFields": [ { "id": "69c258bae3e715c0521153fb", "fieldName": "isVerified", "fieldType": "boolean", "createdAt": "2026-03-24T09:26:18.826Z", "updatedAt": "2026-03-24T09:26:18.826Z" } ] } } ``` ### Authorizations - **Authorization** (header) - Bearer authentication header of the form Bearer ``, where `` is your auth token. ``` -------------------------------- ### Create a Contact List - Ruby Source: https://docs.autosend.com/api-reference/contact-lists/create Use this Ruby example to make a POST request to create a new contact list. Ensure you replace `` with your actual authorization token. ```ruby require 'net/http' require 'json' require 'uri' uri = URI('https://api.autosend.com/v1/contact-lists') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.path) request['Authorization'] = 'Bearer ' request['Content-Type'] = 'application/json' request.body = { name: 'Newsletter Subscribers', description: 'Users who signed up for the weekly newsletter', type: 'list' }.to_json response = http.request(request) puts response.body ``` -------------------------------- ### List Custom Fields in Java Source: https://docs.autosend.com/api-reference/custom-fields/list A Java example using HttpClient to retrieve custom fields. This code sends a GET request with the required Authorization header. ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class Main { public static void main(String[] args) throws Exception { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.autosend.com/v1/custom-fields")) .header("Authorization", "Bearer ") .GET() .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ``` -------------------------------- ### API Response Structure for Get Template Source: https://docs.autosend.com/api-reference/templates/get This is an example of the JSON response structure you can expect when successfully retrieving email template details. It includes metadata and the template content. ```json { "success": true, "data": { "templateId": "A-abc123def456ghi789jk", "projectId": "691adaeef6892e15944d4d96", "templateName": "Welcome Email", "description": "Welcome email for new users", "subject": "Welcome to {{companyName}}, {{firstName}}!", "previewText": "We are glad to have you on board", "emailTemplate": "

Welcome, {{firstName}}!

Thanks for joining {{companyName}}.

", "plainTextTemplate": "Welcome, {{firstName}}! Thanks for joining {{companyName霁}}.", "templateType": "transactional", "builderType": "code", "dynamicVariables": { "firstName": "string", "companyName": "string" }, "createdAt": "2026-01-15T10:30:00.000Z", "updatedAt": "2026-02-20T14:45:00.000Z" } } ``` -------------------------------- ### Queue Welcome Email on Signup (Next.js) Source: https://docs.autosend.com/guides/QStash Use this Next.js API route to queue a welcome email via QStash when a new user signs up. Ensure QStash and AutoSend API keys are set in environment variables. ```javascript // app/api/signup/route.js import { Client } from "@upstash/qstash"; const qstash = new Client({ token: process.env.QSTASH_TOKEN, }); export async function POST(req) { const { email, name } = await req.json(); // 1. Save user to your database // await db.users.create({ email, name }); // 2. Queue welcome email via QStash -> AutoSend try { const res = await qstash.publishJSON({ url: "https://api.autosend.com/v1/mails/send", headers: { "Upstash-Forward-Authorization": `Bearer ${process.env.AUTOSEND_API_KEY}`, }, deduplicationId: `welcome-${email}`, retries: 3, body: { from: { email: "hello@yourdomain.com", name: "Your Company", }, to: { email, name, }, subject: `Welcome, ${name}!`, html: `

Welcome aboard, ${name}!

We're excited to have you.

If you have any questions, just reply to this email.

`, }, }); console.log("Email queued:", res.messageId); } catch (err) { // QStash publish failed - log and continue, don't block signup console.error("Failed to queue welcome email:", err); } return Response.json({ success: true }); } ``` -------------------------------- ### Get Template Details (JavaScript) Source: https://docs.autosend.com/api-reference/templates/get This JavaScript example demonstrates how to fetch email template details using the fetch API in a browser or Node.js environment. It requires an Authorization header. ```javascript fetch('https://api.autosend.com/v1/templates/A-abc123def456ghi789jk', { method: 'GET', headers: { 'Authorization': 'Bearer ' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Get Event - Path Parameter Example Source: https://docs.autosend.com/api-reference/events/get-event Specifies the name of the event to fetch. The name must consist of ASCII letters, digits, and underscores, with a maximum length of 64 characters. ```json "order_completed" ``` -------------------------------- ### List Automations with Filters (cURL) Source: https://docs.autosend.com/api-reference/automations/list-automations Use this cURL command to fetch a paginated list of active automations tagged 'onboarding'. Adjust parameters as needed. ```bash curl --request GET \ --url 'https://api.autosend.com/v1/automations?status=active&tags=onboarding&page=1&limit=20' \ --header 'Authorization: Bearer AS_your-project-api-key' ``` -------------------------------- ### Project Response Example Source: https://docs.autosend.com/api-reference/projects/get-project This is an example of the JSON response you can expect when successfully retrieving project details. It includes information such as the project ID, name, domain, and tracking settings. ```json { "success": true, "data": { "id": "60d5ec49f1b2c72d9c8b1234", "name": "Production App", "domain": "example.com", "domains": [ { "id": "60d5ec49f1b2c72d9c8b5678", "domainName": "example.com", "verificationStatus": "VERIFIED", "regionKey": "us-east-1" } ], "createdAt": "2024-01-15T10:30:00.000Z", "trackingOpen": true, "trackingClick": true, "inboundEmailDomain": "token.autosend.email" } } ``` -------------------------------- ### Get Contact List using JavaScript Source: https://docs.autosend.com/api-reference/contact-lists/get This JavaScript example shows how to retrieve a contact list using the Fetch API. Remember to substitute `` with your valid authorization token. ```javascript fetch('https://api.autosend.com/v1/contact-lists/60d5ec49f1b2c72d9c8b4567', { method: 'GET', headers: { 'Authorization': 'Bearer ' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Get Campaign Details with Python Source: https://docs.autosend.com/api-reference/campaigns/get This Python script uses the requests library to fetch campaign details. Replace with your API token and ensure the requests library is installed. ```python import requests url = "https://api.autosend.com/v1/campaigns/60d5ec49f1b2c72d9c8b4567" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Get Domain Details (Go) Source: https://docs.autosend.com/api-reference/domains/get This Go program demonstrates how to fetch domain details using the `net/http` package. It constructs an HTTP GET request with the required Authorization header and prints the response body. ```go package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.autosend.com/v1/domains/60d5ec49f1b2c72d9c8b1111", nil) req.Header.Set("Authorization", "Bearer ") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Get Sender Details with JavaScript Source: https://docs.autosend.com/api-reference/senders/get This JavaScript example demonstrates how to fetch sender details using the Fetch API in a browser or Node.js environment. It handles JSON parsing and potential errors. ```javascript fetch('https://api.autosend.com/v1/senders/60d5ec49f1b2c72d9c8b4567', { method: 'GET', headers: { 'Authorization': 'Bearer ' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### List Events using Go Source: https://docs.autosend.com/api-reference/events/list-events This Go program demonstrates how to fetch event definitions using the net/http package. It includes setting the Authorization header. ```go package main import ( "fmt" "io" "net/http" ) func main() { url := "https://api.autosend.com/v1/events" req, _ := http.NewRequest("GET", url, nil) req.Header.Set("Authorization", "Bearer AS_your-project-api-key") client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error:", err) return } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Send Email with Nodemailer (TypeScript) Source: https://docs.autosend.com/guides/smtp/nodemailer Utilize this TypeScript example for sending emails via Nodemailer and AutoSend SMTP. It includes type definitions for better code safety. Ensure Nodemailer is installed. ```typescript import nodemailer from 'nodemailer'; import type { Transporter } from 'nodemailer'; const transporter: Transporter = nodemailer.createTransport({ host: 'smtp.autosend.com', port: 465, secure: true, auth: { user: 'autosend', pass: 'AS_xxx', }, }); async function sendEmail(): Promise { const info = await transporter.sendMail({ from: 'sender@yourdomain.com', to: 'recipient@example.com', subject: 'Hello from AutoSend', html: '

Welcome!

This email was sent via Nodemailer and AutoSend SMTP.

', }); console.log('Message sent:', info.messageId); } sendEmail().catch(console.error); ``` -------------------------------- ### Create Contact List using Go Source: https://docs.autosend.com/api-reference/contact-lists/create This Go program demonstrates creating a contact list. It sends a POST request with JSON data and requires your API token to be inserted for ``. ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { url := "https://api.autosend.com/v1/contact-lists" payload := map[string]interface{}{ "name": "Newsletter Subscribers", "description": "Users who signed up for the weekly newsletter", "type": "list", } jsonData, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error:", err) return } defer resp.Body.Close() fmt.Println("Response Status:", resp.Status) } ``` -------------------------------- ### Example Response for Get Message Source: https://docs.autosend.com/api-reference/inbound-emails/get-message This JSON object represents a successful response when retrieving an inbound email message. It contains metadata about the email, its content (text and HTML), attachments, and spam/virus verdicts. ```json { "success": true, "data": { "id": "60d5ec49f1b2c72d9c8b1234", "messageId": "", "domainName": "support.example.com", "from": { "email": "customer@gmail.com", "name": "Jane Customer" }, "to": [ { "email": "help@support.example.com", "name": null } ], "cc": [], "bcc": [], "replyTo": [], "subject": "Question about my order", "text": "Hi, I wanted to check on the status of order #4821.", "html": "

Hi, I wanted to check on the status of order #4821.

", "attachments": [ { "attachmentId": "att_60d5ec49f1b2c72d9c8b9999", "filename": "receipt.pdf", "contentType": "application/pdf", "size": 20480, "index": 0 } ], "headers": { "from": "Jane Customer ", "to": "help@support.example.com", "subject": "Question about my order" }, "spamVerdict": "PASS", "virusVerdict": "PASS", "spfVerdict": "PASS", "dkimVerdict": "PASS", "dmarcVerdict": "PASS", "status": "PROCESSED", "threadId": "60d5ec49f1b2c72d9c8b1234", "inReplyTo": null, "inReplyToEmailActivityId": null, "inReplyToInboundEmailId": null, "receivedAt": "2026-06-20T10:15:30.000Z" } } ``` -------------------------------- ### Get Unsubscribe Groups (Python) Source: https://docs.autosend.com/api-reference/contacts/get-unsubscribe-groups This Python script demonstrates how to fetch unsubscribe groups for a contact using the `requests` library. Ensure you have the library installed and replace `{id}` and `` with your specific values. ```python import requests url = "https://api.autosend.com/v1/contacts/{id}/unsubscribe-groups" headers = { "Authorization": "Bearer " } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### List Webhook Delivery Logs (Go) Source: https://docs.autosend.com/api-reference/webhooks/list-delivery-logs This Go program demonstrates fetching webhook delivery logs using the `net/http` package. It requires your webhook ID and project API key. Pagination can be controlled using the `page` and `limit` query parameters. ```go package main import ( "fmt" "io" "net/http" ) func main() { webhookID := "60d5ec49f1b2c72d9c8b1234" url := "https://api.autosend.com/v1/webhooks/" + webhookID + "/logs?page=1&limit=50" req, _ := http.NewRequest("GET", url, nil) req.Header.Set("Authorization", "Bearer AS_your-api-key") client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error:", err) return } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Retrieve Custom Field by Name (Ruby) Source: https://docs.autosend.com/api-reference/custom-fields/get-by-name Leverage Ruby's `net/http` library to perform the GET request. Parse the URI and set the Authorization header. This example is useful for Ruby-based backend services or scripts. ```ruby require "net/http" require "uri" uri = URI.parse("https://api.autosend.com/v1/custom-fields/fieldName/planTier") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri) request["Authorization"] = "Bearer " response = http.request(request) puts response.body ``` -------------------------------- ### Create Project Source: https://docs.autosend.com/api-reference/projects/create-project This example demonstrates how to create a new project using the AutoSend API. It includes setting the project name, domain, and region, along with the necessary authorization header. ```APIDOC ## POST /v1/account/projects ### Description Creates a new project for your account. ### Method POST ### Endpoint /v1/account/projects ### Parameters #### Header Parameters - **Authorization** (string) - Required - Organization admin API key header of the form Bearer `ASA_`. Standard project API keys (`AS_` prefix) will receive a `403` error. #### Request Body - **name** (string) - Required - Name of the project (max 100 characters). - **domain** (string) - Optional - Domain name through which you plan to send emails, without the `https://` prefix. Accepts a root domain (e.g., `example.com`) or a subdomain (e.g., `mail.example.com`). - **regionKey** (string) - Optional - Account region where the project data will be stored. Allowed values: `us-east-1`, `us-east-2`, `ap-south-1`, `eu-central-1`. ### Request Example ```json { "name": "My New Project", "domain": "example.com", "regionKey": "us-east-1" } ``` ### Response #### Success Response (201) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - The created project object. - **data.id** (string) - Unique project identifier. - **data.name** (string) - Project name. - **data.domain** (string | null) - Primary domain set for the project, or `null` if none was provided. - **data.domains** (object[]) - List of verified email domains (empty for new projects). - **data.regionKey** (string | null) - Account region for the project. One of `us-east-1`, `us-east-2`, `ap-south-1`, or `eu-central-1`. - **data.trackingOpen** (boolean) - Whether open tracking is enabled. - **data.trackingClick** (boolean) - Whether click tracking is enabled. #### Response Example ```json { "success": true, "data": { "id": "60d5ec49f1b2c72d9c8b1234", "name": "My New Project", "domain": "example.com", "domains": [], "regionKey": "us-east-1", "trackingOpen": false, "trackingClick": false } } ``` #### Error Responses - **403 - Not an admin key** (object) - Returned when using a standard project API key instead of an organization admin API key. ```json { "success": false, "error": { "message": "This endpoint requires an organization admin API key (ASA_ prefix)" } } ``` - **403 - Plan limit reached** (object) - Returned when the organization has reached its plan's project limit. ```json { "success": false, "error": { "message": "Plan upgrade required" } } ``` ``` -------------------------------- ### Create Automation Example Source: https://docs.autosend.com/api-reference/automations/create-automation This example demonstrates how to construct a JSON payload to create a new automation. The automation includes steps for sending emails and waiting for a specified delay. ```APIDOC ## Create Automation ### Description Creates a new automation workflow. This involves defining a series of steps that the automation will execute, such as sending emails or introducing delays. ### Method POST ### Endpoint /v1/automations ### Request Body - **steps** (array) - Required - An array of step objects defining the automation flow. - **stepId** (string) - Required - A unique identifier for the step. - **type** (string) - Required - The type of step (e.g., "email", "wait"). - **email** (object) - Optional - Configuration for email steps. - **senderEmail** (string) - Required - The sender's email address. - **senderName** (string) - Required - The sender's name. - **projectId** (string) - Required - The ID of the project associated with the email. - **templateName** (string) - Required - The name of the email template. - **subject** (string) - Required - The subject line of the email. - **previewText** (string) - Required - The preview text for the email. - **htmlTemplate** (string) - Required - The HTML content of the email. - **delay** (object) - Optional - Configuration for wait steps. - **value** (integer) - Required - The numerical value of the delay. - **unit** (string) - Required - The unit of the delay (e.g., "mins", "hours"). - **parentBranchStepId** (string) - Optional - The ID of the parent step in a branching scenario. - **parentBranchId** (string) - Optional - The ID of the parent branch. - **nextStepId** (string) - Optional - The ID of the next step in a linear flow. ### Request Example ```json { "steps": [ { "stepId": "step_branch", "type": "branch", "parentBranchStepId": "step_start", "parentBranchId": "br_pro", "nextStepId": "step_email_pro_followup" }, { "stepId": "step_email_pro_followup", "type": "email", "email": { "senderEmail": "team@example.com", "senderName": "Example Team", "projectId": "60d5ec49f1b2c72d9c8b1111", "templateName": "Welcome - pro follow-up", "subject": "A quick follow-up on your Pro plan", "previewText": "Tips to get the most out of Pro.", "htmlTemplate": "

Hi {{firstName}}

Here are a few Pro tips.

" }, "parentBranchStepId": "step_branch", "parentBranchId": "br_pro" }, { "stepId": "step_wait_other", "type": "wait", "delay": { "value": 2, "unit": "mins" }, "checkExitCriteria": true, "parentBranchStepId": "step_branch", "parentBranchId": "br_other", "nextStepId": "step_email_other" }, { "stepId": "step_email_other", "type": "email", "email": { "senderEmail": "team@example.com", "senderName": "Example Team", "projectId": "60d5ec49f1b2c72d9c8b1111", "templateName": "Welcome - standard email", "subject": "Welcome to Example!", "previewText": "Glad to have you with us.", "htmlTemplate": "

Welcome {{firstName}}!

Thanks for joining.

" }, "parentBranchStepId": "step_branch", "parentBranchId": "br_other" }, { "stepId": "step_wait_merged", "type": "wait", "delay": { "value": 2, "unit": "mins" }, "checkExitCriteria": true, "nextStepId": "step_email_merged" }, { "stepId": "step_email_merged", "type": "email", "email": { "senderEmail": "team@example.com", "senderName": "Example Team", "projectId": "60d5ec49f1b2c72d9c8b1111", "templateName": "Welcome - merged email", "subject": "Thanks for sticking with us, {{firstName}}", "previewText": "A wrap-up note from the team.", "htmlTemplate": "

Thanks {{firstName}}!

Here is your wrap-up.

" } } ] } ``` ### Response #### Success Response (200) - **automationId** (string) - The ID of the newly created automation. - **message** (string) - A confirmation message. #### Response Example ```json { "automationId": "auto_abc123xyz", "message": "Automation created successfully." } ``` ``` -------------------------------- ### Get Custom Field by Name using Python Source: https://docs.autosend.com/api-reference/custom-fields/get-by-name This Python script demonstrates how to fetch custom field details by name and plan tier using the requests library. Ensure you have the library installed and replace `` with your API token. ```python import requests url = "https://api.autosend.com/v1/custom-fields/fieldName/planTier" headers = { "Authorization": "Bearer " } response = requests.get(url, headers=headers) print(response.json()) ```