package main
import (
"context"
"fmt"
"log"
"github.com/AhaSend/ahasend-go/api"
"github.com/google/uuid"
)
func main() {
// Create API client with authentication
client := api.NewAPIClient(
api.WithAPIKey("aha-sk-your-64-character-key"),
)
accountID := uuid.New()
messageID := uuid.New()
// Create context for the API call
ctx := context.Background()
// Fetch a single message by ID
response, httpResp, err := client.MessagesAPI.GetMessage(ctx, accountID, messageID)
if err != nil {
log.Fatalf("Error getting message: %v", err)
}
if httpResp.StatusCode == 200 {
fmt.Printf("✅ Message retrieved! Status: %d\n", httpResp.StatusCode)
if response != nil {
fmt.Printf("Subject: %s\n", response.Subject)
fmt.Printf("Status: %s\n", response.Status)
fmt.Printf("Sender: %s\n", response.Sender)
fmt.Printf("Recipient: %s\n", response.Recipient)
fmt.Printf("Attempts: %d\n", response.NumAttempts)
fmt.Printf("Opens: %d\n", response.OpenCount)
fmt.Printf("Clicks: %d\n", response.ClickCount)
}
} else {
fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
}
}
import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const messageId = "00000000-0000-4000-8000-000000000002";
const message = await client.messages.get(messageId);
console.log("Message found.", { id: message.id, status: message.status });
curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/messages/{message_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/messages/{message_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/messages/{message_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.ahasend.com/v2/accounts/{account_id}/messages/{message_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/messages/{message_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "message",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"sent_at": "2023-11-07T05:31:56Z",
"delivered_at": "2023-11-07T05:31:56Z",
"retain_until": "2023-11-07T05:31:56Z",
"direction": "inbound",
"is_bounce_notification": true,
"bounce_classification": "<string>",
"delivery_attempts": [
{
"time": "2023-11-07T05:31:56Z",
"log": "<string>",
"status": "<string>"
}
],
"message_id": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"subject": "<string>",
"tags": [
"<string>"
],
"sender": "jsmith@example.com",
"recipient": "jsmith@example.com",
"status": "<string>",
"num_attempts": 123,
"click_count": 123,
"open_count": 123,
"reference_message_id": 123,
"domain_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"content": "<string>",
"content_parsed": {
"parts": [
{
"content_type": "text/html",
"content": "<string>"
}
],
"attachments": [
{
"filename": "document.pdf",
"content": "<string>",
"content_type": "application/pdf",
"content_id": "image001@example.com"
}
],
"headers": {
"Content-Type": [
"text/html; charset=utf-8"
],
"X-Custom-Header": [
"value1",
"value2"
]
}
}
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}Get Message
Returns the complete message by its ID, including raw content and parsed content structure.
Access requires messages:read:all or a read role matching the
message’s sender domain.
package main
import (
"context"
"fmt"
"log"
"github.com/AhaSend/ahasend-go/api"
"github.com/google/uuid"
)
func main() {
// Create API client with authentication
client := api.NewAPIClient(
api.WithAPIKey("aha-sk-your-64-character-key"),
)
accountID := uuid.New()
messageID := uuid.New()
// Create context for the API call
ctx := context.Background()
// Fetch a single message by ID
response, httpResp, err := client.MessagesAPI.GetMessage(ctx, accountID, messageID)
if err != nil {
log.Fatalf("Error getting message: %v", err)
}
if httpResp.StatusCode == 200 {
fmt.Printf("✅ Message retrieved! Status: %d\n", httpResp.StatusCode)
if response != nil {
fmt.Printf("Subject: %s\n", response.Subject)
fmt.Printf("Status: %s\n", response.Status)
fmt.Printf("Sender: %s\n", response.Sender)
fmt.Printf("Recipient: %s\n", response.Recipient)
fmt.Printf("Attempts: %d\n", response.NumAttempts)
fmt.Printf("Opens: %d\n", response.OpenCount)
fmt.Printf("Clicks: %d\n", response.ClickCount)
}
} else {
fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
}
}
import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const messageId = "00000000-0000-4000-8000-000000000002";
const message = await client.messages.get(messageId);
console.log("Message found.", { id: message.id, status: message.status });
curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/messages/{message_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/messages/{message_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/messages/{message_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.ahasend.com/v2/accounts/{account_id}/messages/{message_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/messages/{message_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "message",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"sent_at": "2023-11-07T05:31:56Z",
"delivered_at": "2023-11-07T05:31:56Z",
"retain_until": "2023-11-07T05:31:56Z",
"direction": "inbound",
"is_bounce_notification": true,
"bounce_classification": "<string>",
"delivery_attempts": [
{
"time": "2023-11-07T05:31:56Z",
"log": "<string>",
"status": "<string>"
}
],
"message_id": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"subject": "<string>",
"tags": [
"<string>"
],
"sender": "jsmith@example.com",
"recipient": "jsmith@example.com",
"status": "<string>",
"num_attempts": 123,
"click_count": 123,
"open_count": 123,
"reference_message_id": 123,
"domain_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"content": "<string>",
"content_parsed": {
"parts": [
{
"content_type": "text/html",
"content": "<string>"
}
],
"attachments": [
{
"filename": "document.pdf",
"content": "<string>",
"content_type": "application/pdf",
"content_id": "image001@example.com"
}
],
"headers": {
"Content-Type": [
"text/html; charset=utf-8"
],
"X-Custom-Header": [
"value1",
"value2"
]
}
}
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}content (if available),
while the message objects returned in the List Messages API do not include
the email content.Authorizations
API key for authentication. Non-empty Security Requirement values are AhaSend API-key roles. Roles listed within one requirement object are jointly required; separate requirement objects are alternatives.
Path Parameters
Account ID
Message API ID. Accepts the generated Message-ID returned by Create Message API, for example <uuid@example.com>, or the bare UUID portion.
Response
Message details
Object type identifier
message When the message was created
When the message was last updated
When the message was sent
When the message was delivered
When the message data will be purged
Message direction
inbound, outbound Whether this is a bounce notification
Classification of bounce if applicable
List of delivery attempts for this message
Show child attributes
Show child attributes
Message-ID header value
API-generated message ID
Message subject
Tags associated with the message
Sender email address
Recipient email address
Current message status
Number of delivery attempts
Number of clicks tracked for this message
Number of opens tracked for this message
ID of the original message (for bounce messages)
Domain ID this message was sent from
Account ID this message belongs to
Original raw email content in RFC822 format. Omitted when message content is unavailable.
Parsed message content. Omitted when message content is unavailable.
Show child attributes
Show child attributes

