AhaSend Go SDK
package main
import (
"context"
"fmt"
"log"
"github.com/AhaSend/ahasend-go/api"
"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()
smtpCredentialID := uuid.MustParse("0194f7ac-2f6a-7d29-9f0c-9a27b19f2d1c")
// Create context for the API call
ctx := context.Background()
// Call the ping endpoint
response, httpResp, err := client.SMTPCredentialsAPI.GetSMTPCredential(
ctx,
accountID,
smtpCredentialID,
)
if err != nil {
log.Fatalf("Error getting SMTP credentials: %v", err)
}
// Check response
if httpResp.StatusCode == 200 {
fmt.Printf("✅ Status: %d\n", httpResp.StatusCode)
if response != nil {
fmt.Printf("SMTP credentials: %#v\n", response)
}
} else {
fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
}
}curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/smtp-credentials/{smtp_credential_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/smtp-credentials/{smtp_credential_id}"
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}/smtp-credentials/{smtp_credential_id}', 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}/smtp-credentials/{smtp_credential_id}",
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}/smtp-credentials/{smtp_credential_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/smtp-credentials/{smtp_credential_id}")
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": "credential_smtp",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"name": "<string>",
"username": "<string>",
"sandbox": true,
"domains": [
"<string>"
]
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}SMTP Credentials
Get SMTP Credential
Returns a specific SMTP credential by ID
GET
/
v2
/
accounts
/
{account_id}
/
smtp-credentials
/
{smtp_credential_id}
AhaSend Go SDK
package main
import (
"context"
"fmt"
"log"
"github.com/AhaSend/ahasend-go/api"
"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()
smtpCredentialID := uuid.MustParse("0194f7ac-2f6a-7d29-9f0c-9a27b19f2d1c")
// Create context for the API call
ctx := context.Background()
// Call the ping endpoint
response, httpResp, err := client.SMTPCredentialsAPI.GetSMTPCredential(
ctx,
accountID,
smtpCredentialID,
)
if err != nil {
log.Fatalf("Error getting SMTP credentials: %v", err)
}
// Check response
if httpResp.StatusCode == 200 {
fmt.Printf("✅ Status: %d\n", httpResp.StatusCode)
if response != nil {
fmt.Printf("SMTP credentials: %#v\n", response)
}
} else {
fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
}
}curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/smtp-credentials/{smtp_credential_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/smtp-credentials/{smtp_credential_id}"
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}/smtp-credentials/{smtp_credential_id}', 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}/smtp-credentials/{smtp_credential_id}",
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}/smtp-credentials/{smtp_credential_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/smtp-credentials/{smtp_credential_id}")
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": "credential_smtp",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"name": "<string>",
"username": "<string>",
"sandbox": true,
"domains": [
"<string>"
]
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}Authorizations
API key for authentication
Path Parameters
Account ID
SMTP Credential ID
Response
SMTP credential details
Object type identifier
Available options:
credential_smtp Unique identifier for the SMTP credential
When the credential was created
When the credential was last updated
Credential name
SMTP username
Whether this is a sandbox credential
Credential scope
Available options:
global, scoped Domains this credential can send from
⌘I

