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)
}
}
import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const subAccountId = "00000000-0000-4000-8000-000000000004";
const subAccount = await client.subAccounts.update(subAccountId, {
name: "Renamed subsidiary",
});
console.log("Sub-account updated.", { id: subAccount.id, status: subAccount.status });
curl --request PUT \
--url https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Acme Subsidiary",
"website": "acme.example.com",
"monthly_credit": 50000
}
'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}"
payload = {
"name": "Acme Subsidiary",
"website": "acme.example.com",
"monthly_credit": 50000
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Acme Subsidiary',
'website' => 'acme.example.com',
'monthly_credit' => 50000
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.put("https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Acme Subsidiary\",\n \"website\": \"acme.example.com\",\n \"monthly_credit\": 50000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Acme Subsidiary\",\n \"website\": \"acme.example.com\",\n \"monthly_credit\": 50000\n}"
response = http.request(request)
puts response.read_body{
"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"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}Update Sub Account
Updates a sub account’s editable settings
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)
}
}
import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const subAccountId = "00000000-0000-4000-8000-000000000004";
const subAccount = await client.subAccounts.update(subAccountId, {
name: "Renamed subsidiary",
});
console.log("Sub-account updated.", { id: subAccount.id, status: subAccount.status });
curl --request PUT \
--url https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Acme Subsidiary",
"website": "acme.example.com",
"monthly_credit": 50000
}
'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}"
payload = {
"name": "Acme Subsidiary",
"website": "acme.example.com",
"monthly_credit": 50000
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Acme Subsidiary',
'website' => 'acme.example.com',
'monthly_credit' => 50000
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.put("https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Acme Subsidiary\",\n \"website\": \"acme.example.com\",\n \"monthly_credit\": 50000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Acme Subsidiary\",\n \"website\": \"acme.example.com\",\n \"monthly_credit\": 50000\n}"
response = http.request(request)
puts response.read_body{
"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"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}Authorizations
API key for authentication. Non-empty Security Requirement values are AhaSend API-key roles. Roles listed within one requirement object are jointly required; separate requirement objects are alternatives.
Path Parameters
Parent account ID
Sub account ID
Body
- Option 1
- Option 2
- Option 3
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.
Human-readable name for the sub account; leading and trailing whitespace is trimmed and the result must not be blank
1 - 255Account website domain
255Optional monthly cap; 0 means no cap
0 <= x <= 1000000000Response
Sub account updated successfully
Object type identifier
sub_account Unique identifier for the sub account
Parent account ID
When the sub account was created
Sub account name
Account website domain
255Current sub-account status
active, suspended, parent-suspended, deleted Optional monthly cap; 0 means no cap
x >= 0Number of domains owned by the sub account
x >= 0Number of direct members on the sub account
x >= 0Last recorded sub-account email activity

