Domain Management
Relevant source files
The following files were used as context for generating this wiki page:
Domain Management provides the tools to programmatically register, verify, and configure sender domains within the Resend PHP library. It manages the lifecycle of a domain resource from initial creation and DNS record generation to active verification and tracking configuration.
Integration with other systems, such as Tracking and account limits, is handled through specialized resources. The library tracks domain usage against account limits, ensuring that creation requests remain within allowed quotas.
Sources: src/Domain.php, tests/Service/Domain.php:26-30, tests/Fixtures/Usage.php:40-43
Domain Resource Model
The Resend\Domain class represents a domain entity. It contains metadata regarding the domain's identity, its regional placement, and its current functional status.
Resource Properties
The domain resource includes several key attributes that define its state and capabilities.
| Property | Type | Description |
|---|---|---|
id | string | Unique identifier for the domain. |
name | string | The fully qualified domain name. |
status | string | The verification status (e.g., not_started, verified). |
region | string | The AWS region where the domain is provisioned (e.g., us-east-1). |
open_tracking | bool | Indicates if open tracking is enabled. |
click_tracking | bool | Indicates if click tracking is enabled. |
records | array | List of DNS records required for verification and tracking. |
Sources: src/Domain.php:11-21, tests/Fixtures/Domain.php:5-20
Capability Management
Domains possess specific capability flags that indicate what mail operations are permitted. Standard capabilities include sending and receiving, typically returned as enabled or disabled.
Sources: tests/Fixtures/Domain.php:15-18
Service Operations
The Domain service provides methods to interact with the API endpoints. It utilizes a Payload value object to construct HTTP requests with correct methods and URIs.
Domain Lifecycle Flow
The following diagram illustrates the typical sequence for managing a domain from creation to verification.
Core Methods
| Method | HTTP Method | Description |
|---|---|---|
create() | POST | Registers a new domain in the system. |
get() | GET | Retrieves details for a specific domain by ID. |
list() | GET | Returns a Collection of all domains. |
update() | PATCH | Modifies domain settings like tracking. |
verify() | POST | Initiates a verification check for DNS records. |
remove() | DELETE | Deletes the domain resource. |
Sources: tests/Service/Domain.php:5-85
DNS and Verification Configuration
To authorize Resend to send mail on behalf of a domain, specific DNS records must be configured. The domain resource provides a records array containing necessary entries for SPF, DKIM, and Tracking.
Required DNS Records
The system generates different record types to handle authentication and functional features.
- SPF (Sender Policy Framework): Uses
MXandTXTrecords to specify authorized mail servers. - DKIM (DomainKeys Identified Mail): Uses
TXTrecords containing public keys for message signing. - Tracking: Uses
CNAMErecords to point a tracking subdomain to Resend's tracking servers. - TrackingCAA: A
CAA(Certificate Authority Authorization) record specifically for tracking security, identifying permitted certificate issuers likeamazon.com.
Sources: tests/Fixtures/Domain.php:21-65, tests/Service/Domain.php:14-30
Sources: tests/Fixtures/Domain.php:21-65
Usage Limits
Domain creation is subject to account-level quotas. The Usage resource provides visibility into these limits.
| Field | Description |
|---|---|
used | Current number of domains registered. |
limit | Maximum number of domains allowed for the account. |
Sources: src/Usage.php:19, tests/Fixtures/Usage.php:40-43
Summary
Domain Management in the Resend PHP library centralizes the administration of email identity. By providing a structured resource for DNS configuration and verification lifecycle, it ensures that sender domains are correctly authenticated. The system integrates closely with tracking features and enforces account-level usage limits to maintain platform integrity.
Sources: src/Domain.php, src/Usage.php, tests/Service/Domain.php