Record Templates

A template is a saved set of DNS records that you apply to a zone in one step. It fits the common agency setup: your customers' domains live in PrimeDNS, the website and the mailboxes live at some other provider, and every new domain needs the same handful of records pointing there. Instead of typing them again for each domain, pick a template, fill in the few values that differ, check the preview and confirm.

Plans: viewing templates is open to every plan. Creating and editing templates, server profiles and applying a template to a zone need the Professional plan or above.

Quick start with a ready-made template

Open Templates in the panel. Ready-made templates covers common hosting and mail providers. Press Add and apply on one: it is copied to My templates, where you can still edit it, and the apply page opens right away.

Ready-made templates for hosting and mail providers, each with its records and the values it asks for
Ready-made templateCreatesYou provide
Website on a server with a fixed IPA and AAAA for the domain, CNAME for www. Fits a VPS, a dedicated server (for example a Hetzner Cloud server) or hosting that gives you an IP address.web_ip4, optional web_ip6
NetlifyA for the domain, CNAME for wwwyour site name
VercelA for the domain, CNAME for wwwthe A record value and CNAME target shown in your project's domain settings
GitHub PagesA and AAAA for the domain, CNAME for wwwyour GitHub user or organisation address
Cloudflare Pages (subdomain)one CNAME for a subdomainsubdomain, Pages host name
Google Workspace mailMX and SPFnothing
Microsoft 365 mailMX, SPF and the Autodiscover CNAMEMX host and Autodiscover target from your Microsoft 365 admin center
Hostinger mailtwo MX, SPF and the three DKIM CNAMEsnothing

The values come from each provider's own documentation, and the card shows the source and the date it was checked. Providers change their addresses now and then, so treat a ready-made template as a starting point: the preview always shows exactly what will be written, and where a provider hands out values per project or tenant (Vercel, Microsoft 365) the template asks for them instead of guessing.

Apply a template to a zone

You can start from three places: Apply to a zone next to a template, Apply template next to a zone in DNS Zones, or Apply template at the top of a zone's records page.

  1. Choose the zone, and optionally a server profile (see below).
  2. Fill in the values. Each field says what the value is, gives an example and tells you whether it is required.
  3. Choose what happens if the zone already has a record that contradicts the template.
  4. Press Preview changes. Nothing is written yet.
  5. Check the table, then press the apply button. It applies exactly what the preview shows.
Apply page with the values filled in and the preview listing five records to create

What the preview can show

ActionMeaning
CreateThe record does not exist yet and will be added.
Already thereThe zone already has this exact record. It is left alone, so applying a template twice is harmless.
SPF to extendThe zone already has an SPF record. The template's SPF part is added to it instead of creating a second SPF record, which would break SPF.
ConflictThe zone has a record that contradicts the template, for example a CNAME where the template wants an A record on the same name.

If there are conflicts, the setting you chose decides what happens:

SettingBehaviour
Stop (default)Nothing is changed and the conflicts are listed.
Keep mineConflicting records stay as they are and the rest of the template is added.
ReplaceConflicting records are deleted and the template's records are used.

Records created from a template are ordinary records. You can edit or delete them later, and every change appears in the Audit Log like any other.

Write your own template

Press New template under My templates, or Edit on a template you added earlier. A template has a name, a list of variables and a list of records.

Template editor with a variables box and a records box

Variables

A variable is a value that differs per customer or per server. Write one per line:

name type [required] [default=VALUE] [# description]
TypeAccepts
ip4an IPv4 address
ip6an IPv6 address
hostnamea host name
textany text, for example a verification token

The description after # is shown next to the field when the template is applied. Say what the value is and where to find it, because that text is all the person applying the template sees. A variable that is not marked required is optional: records that use it are simply left out when it is empty. This is how one template serves both servers with IPv6 and servers without it. {{domain}} is always available and is the zone the template is applied to.

Records

Write one per line, with variables in double braces:

name [ttl] type content
@ 300 A {{web_ip4}}
@ 300 AAAA {{web_ip6}}
www 300 CNAME {{domain}}.
@ 3600 MX 10 {{mail_host}}.
@ 3600 TXT v=spf1 include:_spf.mail.example.net ~all

Use @ for the zone apex. For MX and SRV records the first word of the content is the priority. Lines that start with # are comments. NS and SOA records are managed by PrimeDNS and cannot be part of a template. A template can have up to 20 variables and 50 records, and an account up to 100 templates.

Server profiles

If several customers sit on the same hosting server, typing its IP addresses for every customer invites mistakes. A server profile is a named set of variable values, for example the addresses of one server. Create it once under Server profiles, then pick it on the apply page: it fills in every variable it has a value for. Values you type on the apply page win over the profile.

Server profile editor with one field per variable used by your templates

The profile form lists the variables your templates use, with the same descriptions. Fill in the ones this server has and leave the rest empty. When the server's IP changes, edit the profile once; the next customer you set up gets the new address. Records that were already created are not changed.

Programmatic access (API)

Everything above is available through the API, so templates can be part of onboarding automation. API keys need the dns:read scope to read and dns:write to create, change or apply. Applying a template also needs the Professional plan or above.

Create a template:

curl -X POST https://api.primedns.net/v1/templates \
  -H "X-API-Key: pdns_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Studio standard",
    "variables": [
      {"name": "web_ip4", "type": "ip4", "required": true, "description": "IPv4 address of the web server"},
      {"name": "web_ip6", "type": "ip6", "description": "IPv6 address of the web server"}
    ],
    "records": [
      {"name": "@", "type": "A", "content": "{{web_ip4}}", "ttl": 300},
      {"name": "@", "type": "AAAA", "content": "{{web_ip6}}", "ttl": 300},
      {"name": "www", "type": "CNAME", "content": "{{domain}}.", "ttl": 300}
    ]
  }'

Save a server profile:

curl -X POST https://api.primedns.net/v1/template-profiles \
  -H "X-API-Key: pdns_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"label": "Server 1", "vars": {"web_ip4": "203.0.113.10", "web_ip6": "2001:db8::10"}}'

Preview what applying it to a zone would do. dry_run writes nothing and returns the plan, with an action of create, exists, merge or conflict for every record:

curl -X POST https://api.primedns.net/v1/zones/example.com/templates/42/apply \
  -H "X-API-Key: pdns_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"profile": "Server 1", "dry_run": true}'

Send the same request without dry_run to apply it. on_conflict is fail (default), skip or replace, the same three choices as in the panel. With fail, a conflict returns HTTP 409 with the code TEMPLATE_CONFLICT and nothing is written. Pass values directly with a variables object, for example {"variables": {"web_ip4": "203.0.113.20"}}.

Teams: a DNS Viewer cannot apply templates. A member restricted to one zone can apply a template to that zone, but cannot create or change templates and profiles, because those belong to the whole account. See Team & RBAC.