Skip to main content
GET
/
v2
/
accounts
/
{account_id}
/
sub-accounts
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/common"
  "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()

  // List sub accounts (limit results to 50 per page)
  response, httpResp, err := client.SubAccountsAPI.ListSubAccounts(ctx, accountID, &common.PaginationParams{Limit: ahasend.Int32(50)})
  if err != nil {
    log.Fatalf("Error listing sub accounts: %v", err)
  }

  if httpResp.StatusCode == 200 {
    fmt.Printf("✅ Sub accounts listed! Status: %d\n", httpResp.StatusCode)
    fmt.Printf("Found %d sub accounts\n", len(response.Data))
    for _, sub := range response.Data {
      fmt.Printf("- ID: %s, Name: %s, Status: %s\n", sub.ID, sub.Name, sub.Status)
    }
  } else {
    fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
  }
}
{
  "object": "list",
  "data": [
    {
      "object": "sub_account",
      "id": "2f3c5d2a-9ef8-4c91-a5f4-79990c8c1d3a",
      "parent_account_id": "9d0cf9d0-4f5e-4674-bcf1-8ec39968b6e1",
      "name": "Acme Subsidiary",
      "website": "acme.example.com",
      "status": "active",
      "monthly_credit": 0,
      "created_at": "2024-01-01T00:00:00Z",
      "domain_count": 2,
      "member_count": 3,
      "last_activity_at": "2024-01-15T12:00:00Z"
    }
  ],
  "pagination": {
    "has_more": true,
    "next_cursor": "eyJpZCI6MTIzNH0="
  }
}

Authorizations

Authorization
string
header
required

API key for authentication

Path Parameters

account_id
string<uuid>
required

Parent account ID

Query Parameters

limit
integer
default:100

Maximum number of items to return (1-100)

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

Pagination cursor for the next page. Provide the value from next_cursor in the response.

before
string

Pagination cursor for the previous page. Provide the value from previous_cursor in the response.

Response

List of sub accounts

object
enum<string>
required

Object type identifier

Available options:
list
data
object[]
required

Array of sub accounts

pagination
object
required
Example:
{
"has_more": true,
"next_cursor": "eyJpZCI6MTIzNH0="
}