API
Programmatically register domains, manage DNS, and let your app act on heynom domains via OAuth. Build integrations, automate workflows, and extend your domain management.
Introduction
The heynom API gives you programmatic access to every action you can take in the dashboard — registering domains, managing DNS records and nameservers, updating WHOIS, and more. Two authentication options:
- API keys (
sk_live_…) — owned by a single heynom user. Use these for first-party scripts. - OAuth tokens (
oat_live_…) — issued to a third-party app on behalf of a user. Use these when you're building something other people will install.
Both share the same scopes and the same per-domain binding model. You generally don't write per-token code differently — pick whichever credential model fits, send it as a Bearer token, and call the endpoints below.
Quickstart
Make your first API call in four steps.
From your developer dashboard, click New Key, name it, pick the scopes you need (start with domains:read), and copy the secret. It's only shown once.
# Replace with your key
curl -H "Authorization: Bearer sk_live_your_api_key" \
https://heynom.com/v1/domains
curl -X POST https://heynom.com/v1/domains/example.com/dns \
-H "Authorization: Bearer sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{"record_type":"A","name":"www","value":"1.2.3.4","ttl":3600}'
Need to act on other users' domains? Build an OAuth app. Want a drop-in domain picker for your site? Use the embed widget.
Authentication
Every request needs a Bearer token in the Authorization header. Two formats:
# Personal API key — generate from the dashboard
Authorization: Bearer sk_live_xxxxxxxxxxxxxxxxxx
# OAuth access token — issued by the OAuth flow
Authorization: Bearer oat_live_xxxxxxxxxxxxxxxx
Base URL
All endpoints are relative to:
https://heynom.com/v1
Response Format
Successful responses return JSON with a data key:
{ "data": { ... } }
Error responses look like:
{
"error": {
"code": "not_found",
"message": "Domain not found"
}
}
Rate Limits
API keys are limited to 60 requests per minute. Rate-limit info comes back in response headers:
| Header | Description |
|---|---|
| X-RateLimit-Limit | Max requests per window (60) |
| X-RateLimit-Remaining | Remaining requests in current window |
When throttled you'll get a 429. Wait, then retry.
Error Codes
| Status | Code | Description |
|---|---|---|
| 400 | bad_request | Invalid request parameters |
| 401 | unauthorized | Missing or invalid credentials |
| 403 | forbidden | Insufficient scope permissions |
| 404 | not_found | Resource not found |
| 429 | rate_limited | Too many requests |
| 502 | registry_error | Upstream registry error |
Domains
List Domains
Returns all domains on your account.
// Response
{
"data": [
{
"id": "abc123...",
"domain_name": "example.com",
"status": "active",
"auto_renew": true,
"locked": true,
"expires_at": "2027-04-04T00:00:00Z",
"nameservers": ["ns1.systemdns.com", "ns2.systemdns.com"]
}
]
}
Get Domain
Returns full detail for a single domain.
| Parameter | In | Description |
|---|---|---|
| :domain | path | Domain name (URL-encoded) |
Check Domain Availability
Check if a domain is available for registration and fetch the price.
| Body | Type | Description |
|---|---|---|
| domain | string | Full domain name, e.g. example.com |
// Response
{
"data": {
"domain": "example.com",
"available": true,
"price": 12.99
}
}
Check Transfer Eligibility
Check if a domain is eligible for transfer to heynom.
| Body | Type | Description |
|---|---|---|
| domain | string | Full domain name |
// Response
{ "data": { "domain": "example.com", "transferable": true, "price": 11.99 } }
Set Transfer Lock
Enable or disable the transfer lock on a domain. Locked domains cannot be transferred away.
| Body | Type | Description |
|---|---|---|
| lock | boolean | true to lock, false to unlock |
Toggle Auto-Renew
| Body | Type | Description |
|---|---|---|
| auto_renew | boolean | true or false |
DNS
List DNS Records
Returns all DNS records for the domain.
// Response
{
"data": [
{ "id": "rec_123", "record_type": "A", "name": "@", "value": "1.2.3.4", "ttl": 3600 }
]
}
Create DNS Record
| Field | Type | Description |
|---|---|---|
| record_typereq | string | A, AAAA, CNAME, MX, TXT, NS, SRV, CAA |
| namereq | string | Subdomain or @ for root |
| valuereq | string | Record value |
| ttlopt | integer | TTL in seconds (60–86400, default 3600) |
| priorityopt | integer | Priority for MX/SRV |
// Request body
{ "record_type": "A", "name": "www", "value": "1.2.3.4", "ttl": 3600 }
Delete DNS Record
Deletes a single DNS record by ID. Admin-locked records cannot be deleted.
Nameservers
Get Nameservers
// Response
{ "data": ["ns1.systemdns.com", "ns2.systemdns.com"] }
Update Nameservers
Replace the nameservers for a domain. If the domain is transfer-locked, the lock is temporarily removed and re-applied automatically.
| Field | Type | Description |
|---|---|---|
| nameserversreq | string[] | Array of nameserver hostnames (min 1) |
WHOIS
Get WHOIS Contacts
Returns the WHOIS contact set (owner, admin, billing, tech) from the registry.
Update WHOIS Contacts
Update WHOIS contacts. Provide a contact_set object with the contacts to update.
// Request body
{
"contact_set": {
"owner": {
"first_name": "Jane",
"last_name": "Doe",
"email": "jane@example.com",
"phone": "+1.5551234567",
"address1": "123 Main St",
"city": "Denver",
"state": "CO",
"postal_code": "80202",
"country": "US"
}
}
}
Billing
List Payment Methods
Returns saved payment methods (cards) on the account — brand + last 4 only.
// Response
{
"data": [
{ "id": "pm_123", "brand": "visa", "last4": "4242", "exp_month": 12, "exp_year": 2028, "is_default": 1 }
]
}
Embed Widget
The heynom embed lets your users connect their heynom domains to your app without leaving your site. It's an iframe you drop in — your users see their domains, click Connect, and your app receives an OAuth authorization code.
When to use the embed vs. a plain OAuth link: use the embed when you want users to see their domains in context (e.g. on your "Add domain" page). Use a plain OAuth link when you just need a "Connect heynom" button somewhere. Both flows end the same way — you receive an authorization_code at your registered redirect_uri.
Quickstart
Drop the helper script on your page and call heynom.embed():
<div id="heynom-connect"></div>
<script src="https://heynom.com/embed.js"></script>
<script>
heynom.embed({
element: '#heynom-connect',
clientId: 'hn_app_xxxxxxxxxxxx',
scope: ['dns:read', 'dns:write'],
redirectUri: 'https://yoursite.com/oauth/callback',
state: 'your_csrf_token',
// Optional: restrict the register search to these TLDs
tlds: ['com', 'io', 'dev'],
onAuthorized: ({ code, state }) => {
// Send code+state to your backend to exchange for tokens
},
});
</script>
Or write the iframe by hand:
<iframe
src="https://heynom.com/embed?client_id=hn_app_xxx&scope=dns:read+dns:write
&redirect_uri=https%3A%2F%2Fyoursite.com%2Foauth%2Fcallback&state=abc"
style="width:100%;border:0;background:transparent;min-height:320px"></iframe>
Content-Security-Policy: frame-ancestors.URL parameters
| Parameter | Required | Description |
|---|---|---|
| client_id | Yes | Your OAuth app's hn_app_* identifier. |
| scope | Yes | Space- or plus-separated list of scopes the OAuth flow will request. |
| redirect_uri | Yes | Where the OAuth flow returns the user. Must match a registered URI exactly. |
| state | Recommended | Opaque CSRF token; echoed back in the redirect. |
| target | No | _self (default) navigates the top window for OAuth. _blank opens a popup and postMessages the result back. |
| mode | No | connect (default), search, or both. |
| suggest_domains | No | Comma-separated list pre-checked on the OAuth consent screen. |
| tlds | No | Comma-separated TLD allowlist for the register search (e.g. tlds=com,io,dev). When set, only these TLDs are searched. Leading dots are tolerated. Falls back to heynom's popular TLDs when omitted. |
| theme | No | transparent (default), light, or dark. |
postMessage events
The iframe posts these events to window.parent, origin-checked against your registered embed origins:
| Event | Payload | When |
|---|---|---|
| heynom:ready | { client_id } | Iframe has loaded. |
| heynom:resize | { height } | Iframe content height changed. |
| heynom:register_start | { domain } | User clicked Register on a search result; checkout popup opening. |
| heynom:registered | { domain, order_id } | Registration completed. |
| heynom:authorized | { code, state } | Only with target=_blank: user authorized the app; exchange the code server-side. |
With the JS helper, subscribe via onReady, onRegistered, onAuthorized, and onRegisterStart.
OAuth 2.0
OAuth lets your app act on a user's heynom domains without ever seeing their password or API key.
Send the user to https://heynom.com/oauth/authorize?… with your client_id, scopes, and a redirect_uri.
They sign in (if needed), pick which of their domains your app may manage, and approve.
heynom redirects them back to your redirect_uri with a one-time code.
Your server exchanges the code (plus a client secret or PKCE verifier) for an access token at POST /api/oauth/token.
Any /v1/* endpoint accepts Authorization: Bearer oat_live_….
Registering an app
Create an OAuth app from your developer dashboard → OAuth Apps → New OAuth App. You'll choose:
- Redirect URIs — exact URLs heynom will redirect to. Must match what you send in the authorize call.
- Embed origins — top-level sites permitted to iframe the heynom embed widget for your app.
- Scopes — what the app will ask for during consent. Users can't grant scopes you didn't register.
- PKCE required (default: yes) — recommended for SPAs/mobile/CLIs without a server-side secret.
After creating, you'll see the client_id (always visible) and the client_secret (shown once; rotate it if lost).
Authorize URL
Send the user here to start consent.
| Parameter | Required | Description |
|---|---|---|
| response_type | Yes | Must be code. |
| client_id | Yes | Your app's identifier. |
| redirect_uri | Yes | Must exactly match a registered redirect URI. |
| scope | Yes | Space-separated scopes. Must be a subset of what the app is registered for. |
| state | Recommended | Opaque value echoed back unmodified. |
| code_challenge | If PKCE | Base64url-encoded SHA-256 of your code_verifier. |
| code_challenge_method | If PKCE | Must be S256. |
| suggest_domains | No | Comma-separated domain names to pre-check on the consent screen. |
On success, the user is redirected to:
https://yoursite.com/callback?code=hn_code_xxx&state=abc
On denial:
https://yoursite.com/callback?error=access_denied&state=abc
Token exchange
Exchange a one-time code for an access + refresh token. Accepts either application/json or application/x-www-form-urlencoded.
| Field | Required | Description |
|---|---|---|
| grant_type | Yes | authorization_code |
| code | Yes | The code from the redirect. |
| redirect_uri | Yes | Must match the value used in the authorize call. |
| client_id | Yes | Your app's identifier. |
| client_secret | If non-PKCE | Required when PKCE isn't being used. Send via body or HTTP Basic. |
| code_verifier | If PKCE | The original verifier whose SHA-256 produced your code_challenge. |
// Successful response
{
"access_token": "oat_live_...",
"refresh_token": "ort_live_...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "dns:read dns:write"
}
Access tokens live 1 hour; refresh tokens live 30 days. Codes expire after 30 seconds and may be redeemed once.
Refreshing tokens
Trade a refresh token for a fresh access token. The refresh token is rotated — the old value is invalidated.
// Request
{
"grant_type": "refresh_token",
"refresh_token": "ort_live_...",
"client_id": "hn_app_...",
"client_secret": "hn_sec_..."
}
PKCE example
PKCE removes the need for a client secret and is the right choice for browser SPAs, mobile apps, and CLIs.
// 1) Generate a verifier and challenge in the browser
async function sha256(text) {
const data = new TextEncoder().encode(text);
const digest = await crypto.subtle.digest('SHA-256', data);
return btoa(String.fromCharCode(...new Uint8Array(digest)))
.replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
}
const verifier = crypto.randomUUID() + crypto.randomUUID();
sessionStorage.setItem('pkce_verifier', verifier);
const challenge = await sha256(verifier);
// 2) Send the user to authorize with the challenge
location.href = `https://heynom.com/oauth/authorize?` + new URLSearchParams({
response_type: 'code', client_id: 'hn_app_...',
redirect_uri: 'https://yoursite.com/cb', scope: 'dns:read dns:write',
state: 'csrf123', code_challenge: challenge, code_challenge_method: 'S256',
});
// 3) On the callback, exchange the code using the verifier
const res = await fetch('https://heynom.com/api/oauth/token', {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
grant_type: 'authorization_code',
code: new URLSearchParams(location.search).get('code'),
redirect_uri: 'https://yoursite.com/cb',
client_id: 'hn_app_...',
code_verifier: sessionStorage.getItem('pkce_verifier'),
}),
});
Scopes reference
Scopes work the same for OAuth tokens and API keys. Grant only what you need.
| Scope | What it allows |
|---|---|
| domains:read | List and inspect domains |
| domains:write | Toggle auto-renew, lock, etc. |
| dns:read | List DNS records |
| dns:write | Create / delete DNS records |
| nameservers:read | Read nameservers |
| nameservers:write | Replace nameservers |
| whois:read | Read WHOIS contacts |
| whois:write | Update WHOIS contacts |
| billing:read | Read saved payment methods (brand + last 4) |
| domains:all | Sensitive. Grants access to the user's current and future domains, bypassing per-domain selection. Requires admin-approved status and an explicit user opt-in. |
Domain binding
Unlike most OAuth implementations, heynom tokens are bound to a specific set of domains chosen by the user during consent. The token's effective permission is the cross-product of the requested scopes and the domains the user selected.
You can hint which domains to pre-select with suggest_domains=example.com,b.com. The user is in full control of the final list.
Calls against a domain the token isn't bound to return 404 not_found. If you need flexibility for users who add domains later, request domains:all — this requires admin approval and an explicit consent-screen toggle.
Revocation
Invalidate an access or refresh token. Returns 200 whether or not the token existed.
// Body (JSON or form-encoded)
{ "token": "oat_live_..." }
Users can also revoke an app at any time from /dashboard/settings → Connected apps.
Code Examples
# List all domains
curl -H "Authorization: Bearer sk_live_your_key" \
https://heynom.com/v1/domains
# Create a DNS record
curl -X POST https://heynom.com/v1/domains/example.com/dns \
-H "Authorization: Bearer sk_live_your_key" \
-H "Content-Type: application/json" \
-d '{"record_type":"A","name":"www","value":"1.2.3.4","ttl":3600}'
# Check domain availability
curl -X POST https://heynom.com/v1/domains/check \
-H "Authorization: Bearer sk_live_your_key" \
-H "Content-Type: application/json" \
-d '{"domain":"coolstartup.com"}'
const API_KEY = 'sk_live_your_key';
const BASE = 'https://heynom.com/v1';
async function heynom(path, options = {}) {
const res = await fetch(BASE + path, {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
...options.headers,
},
...options,
});
return res.json();
}
// List domains
const { data } = await heynom('/domains');
console.log(data);
// Add DNS record
await heynom('/domains/example.com/dns', {
method: 'POST',
body: JSON.stringify({
record_type: 'A', name: 'www',
value: '1.2.3.4', ttl: 3600,
}),
});
import requests
API_KEY = "sk_live_your_key"
BASE = "https://heynom.com/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# List domains
domains = requests.get(f"{BASE}/domains", headers=HEADERS).json()
print(domains["data"])
# Add DNS record
requests.post(
f"{BASE}/domains/example.com/dns",
headers=HEADERS,
json={
"record_type": "A",
"name": "www",
"value": "1.2.3.4",
"ttl": 3600,
},
)