GET
/
v2
/
accounts
/
{account_id}
/
messages
AhaSend Go SDK
package main

import (
  "context"
  "fmt"
  "log"

  "github.com/AhaSend/ahasend-go"
  "github.com/AhaSend/ahasend-go/api"
  "github.com/AhaSend/ahasend-go/models/requests"
  "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()

  // Create context for the API call
  ctx := context.Background()

  // Call the ping endpoint
  response, httpResp, err := client.MessagesAPI.GetMessages(
    ctx,
    accountID,
    requests.GetMessagesParams{
      Status: ahasend.String("bounced,failed"),
      Sender: ahasend.String("[email protected]"),
    },
  )
  if err != nil {
    log.Fatalf("Error getting messages: %v", err)
  }

  // Check response
  if httpResp.StatusCode == 200 {
    fmt.Printf("✅ Status: %d\n", httpResp.StatusCode)
    if response != nil {
      fmt.Printf("Found %d messages\n", len(response.Data))
    }
  } else {
    fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
  }
}
{
  "object": "list",
  "data": [
    {
      "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": "incoming",
      "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": "[email protected]",
      "recipient": "[email protected]",
      "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"
    }
  ],
  "pagination": {
    "has_more": true,
    "next_cursor": "eyJpZCI6MTIzNH0="
  }
}

Authorizations

Authorization
string
header
required

API key for authentication

Path Parameters

account_id
string<uuid>
required

Account ID

Query Parameters

status
string

Filter by comma-separated list of message statuses

sender
string<email>

Sender email address (must be from domain in API key scopes)

recipient
string<email>

Recipient email address

subject
string

Filter by subject text

message_id_header
string

Filter by message ID header (same ID returned by CreateMessage API)

from_time
string<date-time>

Filter messages created after this time (RFC3339 format)

to_time
string<date-time>

Filter messages created before this time (RFC3339 format)

limit
integer
default:100

Maximum number of items to return (1-100)

Required range: 1 <= x <= 100
cursor
string

Pagination cursor for the next page

Response

200
application/json

List of messages

The response is of type object.