Punos API
General
Everything the web interface does can be done through the Punos API: zones, records, networks and addresses.
| Item | Value |
|---|---|
| Address | https://app.punos.cloud/v1 |
| Format | JSON (UTF-8); requests carry Content-Type: application/json |
| Authentication | Authorization: Bearer <API-token> |
| Machine-readable description | https://app.punos.cloud/v1/openapi.json (OpenAPI) |
| Rate limit | 600 requests a minute per IP address; beyond that 429 with a Retry-After header |
| Largest request | 1 MB |
Every customer path starts with /v1/tenants/{tenant_id}. Your identifier is shown on the API tokens page of the web interface. Unknown fields in a request are refused (422), and every response carries an X-Request-Id header you can give to support.
The examples use these variables:
API=https://app.punos.cloud/v1
TOKEN=pt_... # API token
T=<tenant_id>
H="Authorization: Bearer $TOKEN"
J="Content-Type: application/json"
Authentication
The API is used with an API token. A signed-in admin or owner creates one on the API tokens page of the web interface.
- The token is shown once, when created. Punos stores only its hash.
- A token has a role and a lifetime (1–365 days, 90 by default).
- A token belongs to one customer and does not work on another customer's paths.
- A token cannot create tokens or manage users.
- Revoking it in the web interface takes effect at once.
| Token role | May |
|---|---|
viewer | read zones, records, networks and addresses, and search |
editor | also change records, networks and addresses |
admin | also add and delete zones, create spaces and read the audit log |
curl -s "$API/tenants/$T" -H "$H"
The answer gives the customer's name, the token's role, the limits and the nameservers. Give each integration its own token and the smallest role that is enough.
Zones
A zone is served only once ownership of the domain has been proven with a TXT record at the domain's current DNS provider. Every zone is signed with DNSSEC automatically.
| Request | Role | What it does |
|---|---|---|
GET /tenants/{t}/zones | viewer | lists the zones |
POST /tenants/{t}/zones | admin | adds a zone as pending and returns the verification record |
GET /tenants/{t}/zones/{zone_id} | viewer | one zone |
POST /tenants/{t}/zones/{zone_id}/verify | admin | checks the TXT record and activates the zone |
GET /tenants/{t}/zones/{zone_id}/dnssec | viewer | DS records for the registrar |
DELETE /tenants/{t}/zones/{zone_id} | admin | deletes the zone; body {"confirm": "<zone name>"} |
curl -s -X POST "$API/tenants/$T/zones" -H "$H" -H "$J" -d '{"name": "example.fi"}'
{
"id": "da9e9d90-b383-4277-aaa5-c5581d3ee7d2",
"name": "example.fi.",
"status": "pending",
"challenge": {
"name": "_punos-challenge.example.fi.",
"type": "TXT",
"value": "punos-verify=3f9c..."
}
}
Add the challenge record to the domain's current DNS and then call verify. If the record is not visible yet the answer is 409 with code not_verified, and the call can be repeated. A domain, or a name above or below it, can be active for one customer only.
Records
Records are handled as sets (rrsets): one name and type, its TTL and all its values. Changes are sent as a batch that is applied as a whole or not at all, and reach the nameservers in a few seconds.
| Request | Role | What it does |
|---|---|---|
GET /tenants/{t}/zones/{zone_id}/rrsets | viewer | lists; parameters name, type, limit (at most 1000), offset |
PATCH /tenants/{t}/zones/{zone_id}/rrsets | editor | a batch of 1–500 changes |
curl -s -X PATCH "$API/tenants/$T/zones/$Z/rrsets" -H "$H" -H "$J" -d '{
"changes": [
{"name": "www", "type": "A", "ttl": 300, "records": ["192.0.2.10", "192.0.2.11"]},
{"name": "@", "type": "MX", "ttl": 3600, "records": ["10 mail"]},
{"name": "@", "type": "TXT", "ttl": 3600, "records": ["v=spf1 -all"]},
{"name": "old", "type": "CNAME", "delete": true}
]
}'
| Field | Content |
|---|---|
name | @ is the zone itself; a relative name (www) or a full name with a dot (www.example.fi.) |
type | A, AAAA, CAA, CNAME, DS, MX, NS, PTR, SRV, SSHFP, TLSA, TXT |
ttl | 30–604800 seconds |
records | 1–100 values in zone-file form; a relative target (mail) is taken to be inside the zone |
delete | true deletes the set; then no ttl or records |
A TXT value can be given without quotes. Values are stored normalised, so a listing may return them in a slightly different form than you sent. The zone's own NS and SOA records cannot be changed. One invalid value refuses the whole batch (422, invalid_record).
IPAM
IPAM consists of spaces, networks and addresses. A space is a separate address space: the same network can exist in two spaces. Every customer starts with the space default. The network tree follows from the addresses themselves.
| Request | Role | What it does |
|---|---|---|
GET /tenants/{t}/ipam/spaces | viewer | the spaces |
POST /tenants/{t}/ipam/spaces | admin | a new space |
GET /tenants/{t}/ipam/networks?space_id=… | viewer | the networks of a space, with parent_id, depth, address_count, hosts |
POST /tenants/{t}/ipam/networks | editor | a new network |
GET /tenants/{t}/ipam/networks/{id} | viewer | a network, its parents, subnets and addresses |
PATCH /tenants/{t}/ipam/networks/{id} | editor | changes name, description, VLAN or tags |
DELETE /tenants/{t}/ipam/networks/{id} | editor | deletes the network; subnets and addresses are kept |
POST /tenants/{t}/ipam/networks/{id}/next-network | editor | creates the next free subnet |
POST /tenants/{t}/ipam/networks/{id}/next-address | editor | records the network's next free address |
GET /tenants/{t}/ipam/addresses?space_id=… | viewer | the addresses of a space |
POST /tenants/{t}/ipam/addresses | editor | records an address |
PATCH, DELETE /tenants/{t}/ipam/addresses/{id} | editor | changes or deletes an address |
curl -s -X POST "$API/tenants/$T/ipam/networks" -H "$H" -H "$J" -d '{
"space_id": "'$SPACE'", "cidr": "10.20.0.0/16", "name": "Suomi",
"vlan": 20, "tags": {"maa": "FI"}
}'
A network address must be exact: 10.20.0.1/16 is refused and the error suggests 10.20.0.0/16. An address has the fields ip, status (used or reserved), hostname, mac, description and tags.
Next free network and address
These two calls are made for automation. They allocate and record the result in one step, and two simultaneous calls never get the same answer.
curl -s -X POST "$API/tenants/$T/ipam/networks/$NET/next-network" -H "$H" -H "$J" \
-d '{"prefix_len": 24, "name": "Tampere LAN", "tags": {"site": "TRE"}}'
curl -s -X POST "$API/tenants/$T/ipam/networks/$NET/next-address" -H "$H" -H "$J" \
-d '{"hostname": "printer-tre-01", "status": "used"}'
Search and audit log
GET /tenants/{t}/search?q=… searches networks, addresses and zones in one call. Searching by IP address also returns every network the address is inside.
GET /tenants/{t}/audit (role admin) returns changes newest first: who, when, from which IP address, and the values before and after. Parameters are limit, before_id (paging) and action (for example records or ipam.network). The log cannot be changed or deleted.
Errors
An error always has the same shape. A program should act on code; message is for people and may change.
{
"error": {
"code": "invalid_record",
"message": "change 2 (bad A): invalid A record: '999.1.1.1'",
"request_id": "e744226acd724ac1946291749809c24c"
}
}
| HTTP | Code | When |
|---|---|---|
| 401 | unauthorized | the token is missing, wrong, expired or revoked |
| 403 | forbidden | the token's role is not enough |
| 404 | not_found | no such thing, or it belongs to another customer |
| 409 | zone_exists, zone_taken, not_verified, zone_not_active | the zone's state prevents the request |
| 409 | network_exists, address_exists, space_exists | it already exists |
| 409 | no_free_network, no_free_address | nothing free is left |
| 409 | zone_limit, record_limit, network_limit, address_limit | the customer's limit is reached |
| 422 | invalid_request, invalid_zone_name, invalid_record, invalid_cidr, invalid_ip | a field or value of the request is not valid |
| 422 | rejected_by_dns | the nameserver refused the change, for example a CNAME beside another record |
| 429 | rate_limited | too many requests; wait as long as Retry-After says |
| 502, 503 | dns_backend_error, verification_unavailable | a temporary fault; try again shortly |
Example: a new site, automatically
A new site gets a network, an address for its gateway and a DNS name for that address in three calls.
# 1. Next free /24 inside the network $FI
NET=$(curl -s -X POST "$API/tenants/$T/ipam/networks/$FI/next-network" -H "$H" -H "$J" \
-d '{"prefix_len": 24, "name": "Tampere", "tags": {"site": "TRE"}}')
NET_ID=$(echo "$NET" | jq -r .id); CIDR=$(echo "$NET" | jq -r .cidr)
# 2. First free address of that network, for the gateway
GW=$(curl -s -X POST "$API/tenants/$T/ipam/networks/$NET_ID/next-address" -H "$H" -H "$J" \
-d '{"hostname": "gw-tre.example.fi"}' | jq -r .ip)
# 3. A DNS name for the address ($Z is the id of the zone example.fi)
curl -s -X PATCH "$API/tenants/$T/zones/$Z/rrsets" -H "$H" -H "$J" \
-d '{"changes": [{"name": "gw-tre", "type": "A", "ttl": 3600, "records": ["'$GW'"]}]}'
echo "$CIDR $GW"
In a script, check each call's HTTP status before the next: if step 2 or 3 fails, the network allocated in step 1 is already recorded.