Skip to main content
GET
/
v2
/
accounts
/
{account_id}
/
sub-accounts
/
usage
AhaSend Go SDK
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()

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

  response, httpResp, err := client.SubAccountsAPI.GetSubAccountsUsage(ctx, accountID)
  if err != nil {
    log.Fatalf("Error getting sub-accounts usage: %v", err)
  }

  if httpResp.StatusCode == 200 {
    fmt.Printf("✅ Retrieved sub-accounts usage! Status: %d\n", httpResp.StatusCode)
    if response != nil {
      fmt.Printf("Currency: %s\n", response.Currency)
      fmt.Printf("Allocation method: %s\n", response.AllocationMethod)
      fmt.Printf("Total reception count: %d\n", response.Total.ReceptionCount)
      fmt.Printf("Total allocated cost: %.2f\n", response.Total.AllocatedCost)

      fmt.Printf("Sub-accounts: %d\n", len(response.SubAccounts))
      for i, sub := range response.SubAccounts {
        fmt.Printf("  [%d] reception count: %d, allocated cost: %.2f\n", i, sub.ReceptionCount, sub.AllocatedCost)
      }
    }
  } else {
    fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
  }
}
{
  "billing_period": {
    "start": "2024-01-01T00:00:00Z",
    "end": "2024-02-01T00:00:00Z"
  },
  "currency": "usd",
  "allocation_method": "proportional",
  "allocation_note": "allocated_cost is a proportional share of the parent's pooled invoice for the period, not what the sub would pay on its own plan.",
  "parent": {
    "account_id": "9d0cf9d0-4f5e-4674-bcf1-8ec39968b6e1",
    "reception_count": 1000000,
    "allocated_cost": 20
  },
  "sub_accounts": [
    {
      "account_id": "2f3c5d2a-9ef8-4c91-a5f4-79990c8c1d3a",
      "name": "Acme Subsidiary",
      "reception_count": 3000000,
      "allocated_cost": 60
    }
  ],
  "removed_sub_accounts": {
    "reception_count": 0,
    "allocated_cost": 0
  },
  "total": {
    "reception_count": 4000000,
    "allocated_cost": 80
  }
}
Platform Partner feature: Sub Accounts is part of our Platform Partner capabilities and is currently in early access. Contact us to enable it on your account.

Authorizations

Authorization
string
header
required

API key for authentication

Path Parameters

account_id
string<uuid>
required

Parent account ID

Response

Sub-account usage breakdown

billing_period
object
required
currency
string
required

Currency code used for cost allocation

allocation_method
enum<string>
required

Method used to allocate the pooled parent invoice cost

Available options:
proportional
allocation_note
string
required

Disclaimer explaining that allocated cost is not standalone sub-account pricing

parent
object
required
Example:
{
"account_id": "2f3c5d2a-9ef8-4c91-a5f4-79990c8c1d3a",
"name": "Acme Subsidiary",
"reception_count": 3000000,
"allocated_cost": 60
}
sub_accounts
object[]
required

Per-sub-account usage and allocated cost

removed_sub_accounts
object
required

Aggregated usage from sub accounts deleted during the period; still billed to the parent and not identified individually

Example:
{
"account_id": "2f3c5d2a-9ef8-4c91-a5f4-79990c8c1d3a",
"name": "Acme Subsidiary",
"reception_count": 3000000,
"allocated_cost": 60
}
total
object
required
Example:
{
"account_id": "2f3c5d2a-9ef8-4c91-a5f4-79990c8c1d3a",
"name": "Acme Subsidiary",
"reception_count": 3000000,
"allocated_cost": 60
}