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()
subAccountID := uuid.New()
// Create context for the API call
ctx := context.Background()
// List a sub-account's API keys (paginated, up to 50 per page).
// Note: secret_key is omitted from list responses; only create returns it once.
response, httpResp, err := client.SubAccountsAPI.ListSubAccountAPIKeys(
ctx,
accountID,
subAccountID,
&common.PaginationParams{Limit: ahasend.Int32(50)},
)
if err != nil {
log.Fatalf("Error listing sub-account API keys: %v", err)
}
if httpResp.StatusCode == 200 {
fmt.Printf("✅ Listed sub-account API keys. Status: %d\n", httpResp.StatusCode)
if response != nil {
fmt.Printf("Found %d API keys\n", len(response.Data))
for _, key := range response.Data {
fmt.Printf("API key %s: %s\n", key.ID, key.Label)
}
}
} else {
fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
}
}curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "list",
"data": [
{
"object": "api_key",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"label": "<string>",
"public_key": "<string>",
"scopes": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"api_key_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scope": "<string>",
"domain_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"ip_allow_list": [
"<string>"
],
"last_used_at": "2023-11-07T05:31:56Z",
"secret_key": "<string>"
}
],
"pagination": {
"has_more": true,
"next_cursor": "eyJpZCI6MTIzNH0="
}
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}Sub-Account API Keys
List Sub-Account API Keys
Returns a cursor-paginated list of API keys owned by a sub account. The secret_key field is omitted from list responses.
GET
/
v2
/
accounts
/
{account_id}
/
sub-accounts
/
{sub_account_id}
/
api-keys
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()
subAccountID := uuid.New()
// Create context for the API call
ctx := context.Background()
// List a sub-account's API keys (paginated, up to 50 per page).
// Note: secret_key is omitted from list responses; only create returns it once.
response, httpResp, err := client.SubAccountsAPI.ListSubAccountAPIKeys(
ctx,
accountID,
subAccountID,
&common.PaginationParams{Limit: ahasend.Int32(50)},
)
if err != nil {
log.Fatalf("Error listing sub-account API keys: %v", err)
}
if httpResp.StatusCode == 200 {
fmt.Printf("✅ Listed sub-account API keys. Status: %d\n", httpResp.StatusCode)
if response != nil {
fmt.Printf("Found %d API keys\n", len(response.Data))
for _, key := range response.Data {
fmt.Printf("API key %s: %s\n", key.ID, key.Label)
}
}
} else {
fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
}
}curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/sub-accounts/{sub_account_id}/api-keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "list",
"data": [
{
"object": "api_key",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"label": "<string>",
"public_key": "<string>",
"scopes": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"api_key_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scope": "<string>",
"domain_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"ip_allow_list": [
"<string>"
],
"last_used_at": "2023-11-07T05:31:56Z",
"secret_key": "<string>"
}
],
"pagination": {
"has_more": true,
"next_cursor": "eyJpZCI6MTIzNH0="
}
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}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
API key for authentication
Path Parameters
Parent account ID
Sub account ID
Query Parameters
Maximum number of items to return (1-100)
Required range:
1 <= x <= 100Pagination cursor for the next page. Provide the value from next_cursor in the response.
Pagination cursor for the previous page. Provide the value from previous_cursor in the response.
⌘I

