# Update DNS record

## updateDnsRecord()

Gets executed when a customer creates a dns record in the storefront.

### Parameters

<table><thead><tr><th width="142">Type</th><th width="166">Name</th><th>Description</th></tr></thead><tbody><tr><td>IpamRdnsHost </td><td>$ipamRdnsHost, </td><td>The DNS host</td></tr><tr><td>String</td><td>$zoneName</td><td>The zone name</td></tr><tr><td>DnsRecordItem </td><td>$originalDnsRecord</td><td>The DNS record BEFORE</td></tr><tr><td>DnsRecordItem</td><td>$updatedDnsRecord</td><td>The new, updated DNS record.</td></tr></tbody></table>

### Response

No response.

Throwing an Exception() will display a generic error message:\
Throwing a StorefrontException() will display the exact message to the customer.

### Example Code

```php
public function updateDnsRecord(IpamRdnsHost $ipamRdnsHost, string $zoneName, DnsRecordItem $originalDnsRecord, DnsRecordItem $updatedDnsRecord) {
	$zoneName = $this->getZoneName($zoneName, $ipamRdnsHost);

	try {
		$this->_sendRequest($ipamRdnsHost, "zones/{$zoneName}/dns_records/{$originalDnsRecord->id}", "PUT", [
			"content" => $updatedDnsRecord->content,
			"name" => $updatedDnsRecord->hostname,
			"type" => $updatedDnsRecord->type,
			"ttl" => $updatedDnsRecord->ttl,
		]);
	} catch (ClientException $e) {
		throw new Exception($this->_getErrorMessage($e));
	}
}
```

### Testing

You can test this function by updating a dns record as a customer.
