Skip to main content
POST
/
v2
/
accounts
/
{account_id}
/
members
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()

  response, httpResp, err := client.AccountsAPI.AddAccountMember(ctx, accountID, requests.AddMemberRequest{
    Email: "teammate@example.com",
    Name:  ahasend.String("Jordan Lee"),
    Role:  "Developer",
  }, api.WithIdempotencyKey("add-member-20240101-jordan"))
  if err != nil {
    log.Fatalf("Error adding account member: %v", err)
  }

  if httpResp.StatusCode == 201 {
    fmt.Printf("✅ Member added successfully! Status: %d\n", httpResp.StatusCode)
    if response != nil {
      fmt.Printf("User ID: %s\n", response.UserID)
      fmt.Printf("Role: %s\n", response.Role)
    }
  } else {
    fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
  }
}
{
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z",
  "user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}

Authorizations

Authorization
string
header
required

API key for authentication

Headers

Idempotency-Key
string

Optional idempotency key for safe request retries. Must be a unique string for each logical request. Requests with the same key will return the same response. Keys for non-secret responses expire after 24 hours. API-key create responses include a one-time secret_key, so their encrypted replay responses expire after 5 minutes.

Maximum string length: 255

Path Parameters

account_id
string<uuid>
required

Account ID

Body

application/json
email
string<email>
required

Email address of the user to add

role
enum<string>
required

Role to assign to the user

Available options:
Administrator,
Developer,
Analyst,
Billing Manager
name
string

Display name for the user

Response

Member added successfully

created_at
string<date-time>
required

When the relationship was created

updated_at
string<date-time>
required

When the relationship was last updated

user_id
string<uuid>
required

User ID

account_id
string<uuid>
required

Account ID

role
enum<string>
required

User role in the account

Available options:
Administrator,
Developer,
Analyst,
Billing Manager