Skip to content

Latest commit

 

History

History
113 lines (72 loc) · 2.26 KB

records.rst

File metadata and controls

113 lines (72 loc) · 2.26 KB

Records

Setup

In order to interact with the functionality of records, you must first retrieve the details of the domain itself. To do this, you must substitute {domainId} for your domain's ID:

$domain = $service->domain('{domainId}');

Get record

In order to retrieve details for a specific DNS record, you will need its id:

$record = $domain->record('{recordId}');

If you do not have this ID at your disposal, you can traverse the record collection and do a string comparison (detailed below).

List records

This call lists all records configured for the specified domain.

$records = $domain->recordList();

foreach ($records as $record) {
    printf("Record name: %s, ID: %s, TTL: %s\n", $record->name, $record->id, $record->ttl);
}

Query parameters

You can pass in an array of query parameters for greater control over your search:

Name Data type Description
type string The record type
name string The record name
data string Data for this record

Find a record ID from its name

For example:

$records = $domain->recordList(array(
    'name' => 'imap.example.com',
    'type' => 'MX'
));

foreach ($records as $record) {
    $recordId = $record->id;
}

Add record

This call adds a new record to the specified domain:

$record = $domain->record(array(
    'type' => 'A',
    'name' => 'example.com',
    'data' => '192.0.2.17',
    'ttl'  => 3600
));

$record->create();

Please be aware that records that are added with a different hostname than the parent domain might fail silently.

Modify record

$record = $domain->record('{recordId}');
$record->ttl -= 100;
$record->update();

Delete record

$record->delete();