package main
import (
"context"
"fmt"
"log"
"os"
"github.com/AhaSend/ahasend-go/api"
"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()
// Address a contact by its ID or its email address; the SDK escapes the path.
response, _, err := client.ContactsAPI.GetContact(ctx, accountID, "user+tag@example.com")
if err != nil {
log.Fatalf("Error getting contact: %v", err)
}
fmt.Printf("%s %s unsubscribed=%t\n", response.ID, response.Email, response.Unsubscribed)
}import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const idOrEmail = "User+Tag@Example.COM";
const contact = await client.contacts.get(idOrEmail);
console.log("Contact found.", { id: contact.id, status: contact.status });
curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/contacts/{id_or_email} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/contacts/{id_or_email}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/contacts/{id_or_email}",
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}/contacts/{id_or_email}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/contacts/{id_or_email}")
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": "contact",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"email": "jsmith@example.com",
"first_name": "<string>",
"last_name": "<string>",
"status": "enabled",
"status_reason": "<string>",
"unsubscribed": true,
"unsubscribed_at": "2023-11-07T05:31:56Z",
"attributes": {},
"validation_status": "unvalidated",
"last_validated_at": "2023-11-07T05:31:56Z"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}Get a Contact via the API
Retrieve one AhaSend contact by ID or email address, with its name, status, account-wide unsubscribe, attributes and validation result.
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/AhaSend/ahasend-go/api"
"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()
// Address a contact by its ID or its email address; the SDK escapes the path.
response, _, err := client.ContactsAPI.GetContact(ctx, accountID, "user+tag@example.com")
if err != nil {
log.Fatalf("Error getting contact: %v", err)
}
fmt.Printf("%s %s unsubscribed=%t\n", response.ID, response.Email, response.Unsubscribed)
}import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const idOrEmail = "User+Tag@Example.COM";
const contact = await client.contacts.get(idOrEmail);
console.log("Contact found.", { id: contact.id, status: contact.status });
curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/contacts/{id_or_email} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/contacts/{id_or_email}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/contacts/{id_or_email}",
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}/contacts/{id_or_email}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/contacts/{id_or_email}")
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": "contact",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"email": "jsmith@example.com",
"first_name": "<string>",
"last_name": "<string>",
"status": "enabled",
"status_reason": "<string>",
"unsubscribed": true,
"unsubscribed_at": "2023-11-07T05:31:56Z",
"attributes": {},
"validation_status": "unvalidated",
"last_validated_at": "2023-11-07T05:31:56Z"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}contacts:read.
{id_or_email} is the contact ID or its email address. A value in UUID form is read as the ID. Percent-encode an email address exactly once, so user+tag@example.com becomes user%2Btag%40example.com. The official SDKs encode it for you. See Name a contact in the path.
The contact does not show its lists. To read them, use List Contact’s Lists.
Related Guides
- API authentication, Permission scopes, Update Contact.
- Contacts API overview, API errors, API rate limits.
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
Account ID
Contact UUID or email address. Percent-encode an email exactly once as a path segment; SDK callers pass the raw email value.
Response
Contact
Public contact projection. Attribute reads are legacy-safe: values can contain null, booleans, numbers, strings, arrays, or nested objects even though new writes accept only canonical dashboard-defined values.
Object type identifier
contact Unique identifier for the contact
When the contact was created
When the contact was last updated
Normalized contact email address
enabled, disabled, blocked Show child attributes
Show child attributes
unvalidated, valid, invalid, risky, unknown 
