Skip to main content
PUT
/
v2
/
accounts
/
{account_id}
/
sub-accounts
/
{sub_account_id}
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()
  subAccountID := uuid.New()

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

  response, httpResp, err := client.SubAccountsAPI.UpdateSubAccount(ctx, accountID, subAccountID, requests.UpdateSubAccountRequest{Name: ahasend.String("Acme Subsidiary"), MonthlyCredit: ahasend.Int64(50000)})
  if err != nil {
    log.Fatalf("Error updating sub account: %v", err)
  }

  if httpResp.StatusCode == 200 {
    fmt.Printf("✅ Sub account updated! Status: %d\n", httpResp.StatusCode)
    if response != nil {
      fmt.Printf("ID: %s\n", response.ID)
      fmt.Printf("Name: %s\n", response.Name)
      fmt.Printf("MonthlyCredit: %d\n", response.MonthlyCredit)
    }
  } else {
    fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
  }
}
{
  "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"
}
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

sub_account_id
string<uuid>
required

Sub account ID

Body

application/json

At least one non-null field must be provided, and at least one provided value must differ from the current value. Omitted or null fields are left unchanged.

name
string
required

Human-readable name for the sub account; leading and trailing whitespace is trimmed and the result must not be blank

Required string length: 1 - 255
website
string<fqdn> | null

Account website domain

Maximum string length: 255
monthly_credit
integer<int64> | null

Optional monthly cap; 0 means no cap

Required range: 0 <= x <= 1000000000

Response

Sub account updated successfully

object
enum<string>
required

Object type identifier

Available options:
sub_account
id
string<uuid>
required

Unique identifier for the sub account

parent_account_id
string<uuid>
required

Parent account ID

created_at
string<date-time>
required

When the sub account was created

name
string
required

Sub account name

website
string<fqdn>
required

Account website domain

Maximum string length: 255
status
enum<string>
required

Current sub-account status

Available options:
active,
suspended,
parent-suspended,
deleted
monthly_credit
integer<int64>
required

Optional monthly cap; 0 means no cap

Required range: x >= 0
domain_count
integer<int64>
required

Number of domains owned by the sub account

Required range: x >= 0
member_count
integer<int64>
required

Number of direct members on the sub account

Required range: x >= 0
last_activity_at
string<date-time> | null
required

Last recorded sub-account email activity