Integrate Autheona using PHP

Server-side PHP integration guide for Autheona Trust Verification API with copy-paste ready code using curl standard library.

Prerequisites

Before using this code, you need:

  1. An Autheona account: Sign up at https://app.autheona.com/sign-up
  2. A project (Sandbox or Production): See project creation guide
  3. An access token with API permissions: See access token documentation

Store your access token securely using environment variables. Never hardcode tokens in your source code.

Code

This function sends an HTTP POST request to the Autheona API with the email address to validate. It accepts an optional customPolicy parameter for testing validation rules. The function returns the API response as an array containing the validation result and email intelligence data.

<?php

function validateEmail(string $email, string $apiKey, ?array $customPolicy = null): array {
    $normalizedEmail = strtolower(trim($email));
    
    $payload = ['email_address' => $normalizedEmail];
    if ($customPolicy !== null) {
        $payload['custom_policy'] = $customPolicy;
    }
    
    $ch = curl_init('https://api.autheona.com/v1/intelligence');
    
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'x-api-key: ' . $apiKey
    ]);
    
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    if ($httpCode !== 200) {
        throw new Exception('HTTP ' . $httpCode);
    }
    
    return json_decode($response, true);
}

Usage

Include the file, provide your API key via environment variable, and call validateEmail with an email address. The function returns an array with action field ('allow', 'block', or 'ignore') and detailed email analysis. For testing specific rules, pass a custom policy as the third argument.

<?php

require_once 'autheona.php';

$apiKey = $_ENV['AUTHEONA_API_KEY'];

// Basic validation
$result = validateEmail('user@example.com', $apiKey);
echo $result['action'];

// With custom policy for testing
$customPolicy = [
    'parent_rules' => [
        ['action' => 'block', 'field' => 'domain_disposable', 'operator' => '==', 'target' => ['bool' => true]]
    ],
    'stop_on_block' => true,
    'version' => '1.0'
];

$testResult = validateEmail('user@tempmail.com', $apiKey, $customPolicy);
echo $testResult['action'];

Custom Policy Parameter

Warning

The custom_policy parameter is for testing only. In production, configure policies using the Policy Editor instead of sending them in requests.

Add custom_policy to your request body to test custom validation rules:

$customPolicy = [
    'parent_rules' => [
        ['action' => 'block', 'field' => 'domain_disposable', 'operator' => '==', 'target' => ['bool' => true]],
        ['action' => 'block', 'field' => 'email_deliverable', 'operator' => '==', 'target' => ['bool' => false]],
        ['action' => 'ignore', 'field' => 'domain_free', 'operator' => '==', 'target' => ['bool' => true]]
    ],
    'stop_on_block' => true,
    'version' => '1.0'
];

Available fields: domain_disposable, domain_free, email_deliverable, domain_has_website, email_has_fraud_pattern, and more from the API response.

Environment Variables

Set your API key as an environment variable to keep it out of your code:

export AUTHEONA_API_KEY="your-api-key"

Note

This is a minimal integration example. For production use cases, error handling, retry logic, rate limiting, and advanced response processing, refer to the API Reference Documentation.

Support

For issues with the API, refer to: