AhaSend Go SDK
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/AhaSend/ahasend-go"
"github.com/AhaSend/ahasend-go/api"
"github.com/AhaSend/ahasend-go/models/requests"
"github.com/google/uuid"
)
func main() {
client := api.NewAPIClient(api.WithAPIKey(os.Getenv("AHASEND_API_KEY")))
accountID := uuid.MustParse(os.Getenv("AHASEND_ACCOUNT_ID"))
ctx := context.Background()
// Update the account name and open/click tracking settings
response, _, err := client.AccountsAPI.UpdateAccount(ctx, accountID, requests.UpdateAccountRequest{
Name: ahasend.String("Acme Corp"),
TrackOpens: ahasend.Bool(true),
TrackClicks: ahasend.Bool(true),
})
if err != nil {
log.Fatalf("Error updating account: %v", err)
}
fmt.Printf("Updated account %s\n", response.Name)
}import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const account = await client.accounts.update({ name: "Example, Inc." });
console.log("Account updated.", { id: account.id, name: account.name });
curl --request PUT \
--url https://api.ahasend.com/v2/accounts/{account_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Updated Company Name",
"website": "https://example.com",
"track_opens": true
}
'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}"
payload = {
"name": "Updated Company Name",
"website": "https://example.com",
"track_opens": True
}
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}",
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' => 'Updated Company Name',
'website' => 'https://example.com',
'track_opens' => true
]),
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}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Updated Company Name\",\n \"website\": \"https://example.com\",\n \"track_opens\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{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\": \"Updated Company Name\",\n \"website\": \"https://example.com\",\n \"track_opens\": true\n}"
response = http.request(request)
puts response.read_body{
"object": "account",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"parent_account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"name": "<string>",
"website": "<string>",
"about": "<string>",
"track_opens": true,
"track_clicks": true,
"reject_bad_recipients": true,
"reject_mistyped_recipients": true,
"message_metadata_retention": 123,
"message_data_retention": 123,
"owner_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}Accounts
Update Account Settings via the API
Update AhaSend account settings through the API: change the account name, website, and message data or metadata retention within your plan limits.
PUT
/
v2
/
accounts
/
{account_id}
AhaSend Go SDK
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/AhaSend/ahasend-go"
"github.com/AhaSend/ahasend-go/api"
"github.com/AhaSend/ahasend-go/models/requests"
"github.com/google/uuid"
)
func main() {
client := api.NewAPIClient(api.WithAPIKey(os.Getenv("AHASEND_API_KEY")))
accountID := uuid.MustParse(os.Getenv("AHASEND_ACCOUNT_ID"))
ctx := context.Background()
// Update the account name and open/click tracking settings
response, _, err := client.AccountsAPI.UpdateAccount(ctx, accountID, requests.UpdateAccountRequest{
Name: ahasend.String("Acme Corp"),
TrackOpens: ahasend.Bool(true),
TrackClicks: ahasend.Bool(true),
})
if err != nil {
log.Fatalf("Error updating account: %v", err)
}
fmt.Printf("Updated account %s\n", response.Name)
}import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const account = await client.accounts.update({ name: "Example, Inc." });
console.log("Account updated.", { id: account.id, name: account.name });
curl --request PUT \
--url https://api.ahasend.com/v2/accounts/{account_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Updated Company Name",
"website": "https://example.com",
"track_opens": true
}
'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}"
payload = {
"name": "Updated Company Name",
"website": "https://example.com",
"track_opens": True
}
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}",
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' => 'Updated Company Name',
'website' => 'https://example.com',
'track_opens' => true
]),
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}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Updated Company Name\",\n \"website\": \"https://example.com\",\n \"track_opens\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{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\": \"Updated Company Name\",\n \"website\": \"https://example.com\",\n \"track_opens\": true\n}"
response = http.request(request)
puts response.read_body{
"object": "account",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"parent_account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"name": "<string>",
"website": "<string>",
"about": "<string>",
"track_opens": true,
"track_clicks": true,
"reject_bad_recipients": true,
"reject_mistyped_recipients": true,
"message_metadata_retention": 123,
"message_data_retention": 123,
"owner_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}The AhaSend API updates account settings.
Validation Requirements:
namemust be maximum 255 characterswebsitemust be a valid URLmessage_metadata_retentionmust be between 1 and 30 daysmessage_data_retentionmust be between 0 and 30 days
Related Guides
- API authentication, Permission scopes, Team members API.
- Retention rules, API errors, API rate limits.
- Plans and limits.
Authorizations
Body
application/json
Response
Account updated successfully

