Skip to content
nsin docs

Update domain settings

PUT
/domains/{domain}
curl --request PUT \
--url https://api.nsin.ir/domains/example.com \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "dns_mode": "managed", "cache_l2_max_gb": 1, "cache_l2_ttl_days": 1, "cache_cap_mb": 128, "sec_no_sniff": true, "sec_referrer_policy": true, "sec_strip_headers": true, "hsts_enabled": true, "hsts_max_age_sec": 0, "hsts_include_subdomains": true, "hsts_preload": true, "min_tls_version": "1.2", "markdown_for_agents": true, "origin_protocol": "http1", "default_static_cache": true, "bot_cache_enabled": true, "bot_cache_fresh_sec": 1, "bot_cache_max_age_sec": 1, "bot_cache_kinds": [ "googlebot" ], "bot_cache_path_excludes": [ "example" ] }'

Partial update — omitted fields are left unchanged. Requires the domain.settings permission. Every edge node is told to reload the domain’s configuration as soon as the change is saved.

Plan limits apply to three fields: cache_cap_mb, cache_l2_max_gb and cache_l2_ttl_days may not exceed the ceilings of the domain’s plan (403, with the ceiling in the body). Turning markdown_for_agents on needs an active plan, and turning the bot cache on — or changing a bot_cache_* setting while it is on — needs a plan with the bot cache feature. Switching either off is never refused. These two plan checks answer with a plain-text body, not the usual JSON error.

Switching dns_mode keeps records, rules, certificates and the plan, and puts the domain back to pending:

  • to managed — NSIN creates the zone, loads your records into it and waits for the nameservers to point at NSIN (activating straight away if they already do);
  • to external — NSIN removes its zone and opens a fresh 3-day verification window (see ssl_delegation / verification in the response).

A banned domain cannot switch.

domain
required
string

The domain name (for example example.com) — not a numeric id.

Example
example.com
Media type application/json

Every field is optional; omitted fields are left unchanged.

object
dns_mode

Switch how DNS is run. See the operation description for what happens.

string
Allowed values: managed external
cache_l2_max_gb

Disk (L2) cache size cap in GB. At most the plan’s ceiling.

integer
>= 1
cache_l2_ttl_days

Disk cache entry lifetime in days. At most the plan’s ceiling.

integer
>= 1 <= 7
cache_cap_mb

Largest cacheable response body in MB. At most the plan’s ceiling.

integer
Allowed values: 128 256 512 2048 4096
sec_no_sniff

See the sec_no_sniff field on Domain.

boolean
sec_referrer_policy

See the sec_referrer_policy field on Domain.

boolean
sec_strip_headers

See the sec_strip_headers field on Domain.

boolean
hsts_enabled

See the hsts_enabled field on Domain. Cannot be undone for browsers that have already seen the header.

boolean
hsts_max_age_sec

See the hsts_max_age_sec field on Domain. May only be raised one step per request; a bigger jump is rejected with 400 naming the next allowed value.

integer
Allowed values: 0 300 3600 86400 604800 2592000 31536000
hsts_include_subdomains

See the hsts_include_subdomains field on Domain.

boolean
hsts_preload

See the hsts_preload field on Domain. Rejected with 400 unless hsts_enabled, hsts_include_subdomains and a hsts_max_age_sec of 31536000 are all in place after this update.

boolean
min_tls_version

See the min_tls_version field on Domain. TLSv1.3 and tls1.3 are accepted as spellings of 1.3.

string
Allowed values: 1.2 1.3
markdown_for_agents

See the markdown_for_agents field on Domain. Turning it on requires an active plan.

boolean
origin_protocol

See the origin_protocol field on Domain. h1/h2/h3 and HTTP/2-style spellings are accepted too.

string
Allowed values: http1 http2 http3
default_static_cache

See the default_static_cache field on Domain.

boolean
bot_cache_enabled

See the bot_cache_enabled field on Domain. Turning it on, or changing any bot_cache_* setting while it is on, requires the plan flag (403 otherwise); turning it off never does.

boolean
bot_cache_fresh_sec

See the bot_cache_fresh_sec field on Domain.

integer
>= 300 <= 86400
bot_cache_max_age_sec

Must be at least bot_cache_fresh_sec.

integer
>= 300 <= 86400
bot_cache_kinds

Crawlers the bot cache serves. Case-insensitive; duplicates are dropped.

Array<string>
>= 1 items
Allowed values: googlebot bingbot applebot duckduckbot yandexbot
bot_cache_path_excludes

Wildcard path patterns (/api/*) never served from the bot cache. Blank entries are dropped. Replaces the whole list.

Array<string>
<= 50 items

Updated domain.

Media type application/json
object
id
integer
name
string
status
  • pending — waiting to be activated: a managed domain for its nameservers to point at NSIN (disabled after 28 days without that), an external-DNS domain for its verification record (3-day window).
  • failed — an external-DNS domain whose 3-day verification window ran out. Start a new window with POST /domains/{domain}/verify/retry.
  • active — serving.
  • moved — was active, but the delegation (managed) or the verification record (external) is gone. The domain keeps serving for a 3-day grace window, then is disabled; putting it back reactivates it at the next check.
  • disabled — not serving: zone removed, records un-proxied, cache purged. Re-enable with POST /domains/{domain}/enable.
  • banned — administratively blocked.
string
Allowed values: pending failed active moved disabled banned
dns_mode

managed — NSIN hosts the DNS zone. external — you host DNS elsewhere and prove ownership with a TXT record.

string
Allowed values: managed external
user_id

Id of the owning user.

integer
verification_started_at

External-DNS domains: when the current 3-day verification window opened (at creation, on a switch to external, on re-enable and on verify/retry).

string format: date-time
cache_l2_max_gb

Per-domain cap on disk (L2) cache size, in GB.

integer
cache_l2_ttl_days

How long a disk-cache entry may live, in days. Maximum 7.

integer
>= 1 <= 7
cache_cap_mb

Largest response body NSIN will buffer and cache, in MB. Bigger responses stream straight from origin and are never cached. The selectable ceiling depends on the domain’s plan.

integer
Allowed values: 128 256 512 2048 4096
developer_mode_until

While set and in the future, the edge bypasses cache reads and writes for this domain and passes the origin’s own error responses through (see POST /domains/{domain}/developer-mode). Absent when developer mode is off.

string format: date-time
pending_since

When the domain last entered pending.

string format: date-time
moved_since

When the domain went moved; the 3-day grace window counts from here.

string format: date-time
next_check_at

When the background nameserver checker will next look at this domain.

string format: date-time
last_manual_ns_check_at

Last user-triggered nameserver check; these are limited to one per hour.

string format: date-time
last_manual_verify_at

Last user-triggered verification check (POST /domains/{domain}/verify); limited to one per minute.

string format: date-time
under_attack

Under Attack Mode is switched on (see GET /domains/{domain}/under-attack).

boolean
under_attack_bypass_paths

Under Attack Mode’s bypass paths.

Array<string> | null
under_attack_since

When Under Attack Mode was switched on.

string | null format: date-time
under_attack_until

When Under Attack Mode switches itself off; null = no timer.

string | null format: date-time
shield_dismissed_at

Set when the default “NSIN Shield” WAF rule was deleted from this domain. While set, the rule is not re-created automatically; POST /domains/{domain}/rules/waf/shield/restore brings it back and clears this.

string format: date-time
sec_no_sniff

Send X-Content-Type-Options: nosniff. Off by default — it can break an origin that mislabels asset MIME types.

boolean
sec_referrer_policy

Send Referrer-Policy: strict-origin-when-cross-origin.

boolean
sec_strip_headers

Strip origin fingerprint headers from responses.

boolean
hsts_enabled

Send Strict-Transport-Security, telling browsers to use HTTPS only for this domain. Off by default.

This one cannot be undone. A browser that has seen the header refuses plain HTTP for the whole hsts_max_age_sec even after the header stops being sent; switching it off only stops new visitors from being pinned. Enable it only when every path on the domain works over HTTPS. The edge’s value replaces an origin’s own Strict-Transport-Security header (a browser reads only the first one it receives).

boolean
hsts_max_age_sec

How long browsers keep enforcing HTTPS, in seconds. 0 is “never set”. Only the listed values are accepted, and this API raises it one step at a time — from 0 the only allowed next value is 300, then 3600, and so on. Lowering it is always allowed and is the way back out. The edge treats anything under 300 as off. Turning hsts_enabled on while this is 0 sets it to 300.

integer
Allowed values: 0 300 3600 86400 604800 2592000 31536000
hsts_include_subdomains

Add includeSubDomains, applying the rule to every subdomain, including ones created later. A subdomain not served over HTTPS becomes unreachable for visitors who have seen the header.

boolean
hsts_preload

Add the preload directive, the prerequisite for submitting the domain at hstspreload.org. Requires hsts_enabled, hsts_include_subdomains and hsts_max_age_sec of 31536000.

Effectively permanent: getting off the browser preload list means asking hstspreload.org to delist the domain and waiting for people to update their browsers. If a precondition is later removed, this flag is cleared with it.

boolean
min_tls_version

Lowest TLS version a visitor may connect with. 1.2 (default) accepts TLS 1.2 and 1.3; 1.3 refuses TLS 1.2 handshakes. Nothing below 1.2 is offered on any domain. It is enforced during the TLS handshake from the SNI, so a client below the minimum gets a connection error rather than an HTTP response. HTTP/3 is TLS 1.3 by definition and is unaffected.

string
Allowed values: 1.2 1.3
markdown_for_agents

Serve a Markdown rendering of eligible HTML pages to clients sending Accept: text/markdown. Requires an active plan.

boolean
analytics_tag

The NsinNabz <script> tag the edge inserts into this domain’s HTML pages; empty when there is none. Set and removed through /domains/{domain}/analytics-tag, not through this object.

string
analytics_tag_updated_at

When analytics_tag last changed. Absent when there is no tag.

string format: date-time
origin_protocol

HTTP version the edge speaks to this domain’s origins on the direct path. Default http1, and deliberately so: over HTTP/2 an upload is limited by the origin’s per-stream window (64 KB on nginx), which caps each upload near 4 MB/s at a 16 ms edge-to-origin round trip. http3 falls back to TCP per origin when the QUIC dial fails. The tunnel path from Iranian edges to foreign origins is always HTTP/1.1. Probe what your origin supports with GET /domains/{domain}/origin-protocols.

string
Allowed values: http1 http2 http3
default_static_cache

Cache static files (CSS, JavaScript, images, fonts, media, downloads) at the edge automatically, even with no cache rule — the way Cloudflare does for every proxied hostname. On by default. HTML is never cached by this; your own cache rules always take precedence, and any path you exclude in a rule is never cached by the default. Freshness follows your origin’s Cache-Control; with none, 5 minutes.

boolean
bot_cache_enabled

Bot cache: keep an edge copy of every HTML page for verified search-engine crawlers (Googlebot, Bingbot, Applebot, DuckDuckBot, YandexBot) and serve them from it, regardless of the origin’s Cache-Control. Human visitors are unaffected. A crawler must pass the operator’s own verification (published IP ranges / reverse DNS); a spoofed User-Agent never gets the copy. Requires a plan with bot_cache_enabled; the edge switches it off automatically while the plan lacks it.

boolean
bot_cache_fresh_sec

Bot cache: seconds a copy is served without asking the origin (300–86400, default 3600). Older copies are still served and refreshed in the background with a conditional request.

integer
bot_cache_max_age_sec

Bot cache: seconds after which a copy is no longer served and is fetched again (300–86400, default 86400).

integer
bot_cache_kinds

Crawlers the bot cache serves. A domain that never set it (empty) serves all of them; an update must list at least one.

Array<string>
Allowed values: googlebot bingbot applebot duckduckbot yandexbot
bot_cache_path_excludes

Wildcard path patterns (/api/*) never served from the bot cache.

Array<string>
proxy_ips

Edge addresses every proxied record of this domain is pinned to, instead of the platform default set. Set by NSIN support only (for example for a dedicated address); absent in the normal case.

Array<string>
gateway_requests_30d

Requests served by this domain’s gateway hostnames in the rolling 30-day window, as of gateway_quota_counted_at.

integer format: int64
gateway_bytes_30d

Egress bytes of the gateway hostnames over the same window. A meter for the gateway allowance, not a second charge — the bytes are already billed as the domain’s ordinary traffic.

integer format: int64
gateway_quota_exceeded

The plan’s gateway allowance (requests or bytes) is spent, so the gateway hostnames answer 429 until enough traffic ages out of the window. The rest of the domain is unaffected.

boolean
gateway_quota_counted_at

When the gateway usage above was last recomputed. Absent before the first count.

string format: date-time
gateway_quota_reason

Which gateway cap tripped. Absent while nothing has.

string
Allowed values: requests bytes
gateway_terms_accepted_at

When this domain’s gateway terms of use were accepted (see POST /domains/{domain}/gateways/terms/accept). Absent until then; switching a gateway on is refused without it.

string format: date-time
gateway_terms_accepted_by

User id of whoever accepted the gateway terms.

integer
billing_user_id

The member nominated to pay for this domain. Absent when the owner pays (the normal case). Only the owner can set it, in the panel — API keys cannot change who pays.

integer
billing_user_set_by

User id of whoever made the current billing nomination.

integer
billing_user_set_at

When the current billing nomination took effect. Charges for a billing window that started earlier stay with the previous payer.

string format: date-time
outage_alerts

Notify the owner when a subdomain suffers a sustained origin outage.

boolean
uptime_threshold_pct

Per-minute origin-error percentage that counts as “down”.

integer
>= 50 <= 100
uptime_window_min

Minutes the domain must stay down before an incident opens.

integer
>= 2 <= 60
uptime_min_requests

Minimum origin-eligible requests in the window — the traffic floor below which no incident opens.

integer
uptime_min_active_min

Minimum populated one-minute buckets required in the window.

integer
uptime_recover_min

Consecutive clear minutes before an incident resolves.

integer
uptime_host_match_type

How the host filter — host_pattern, host_includes and host_excludes — is matched. One strategy covers all three, exactly as one path_match_type covers both path lists.

The empty string means “no host filter”, and is the only valid value when the pattern and both lists are empty. Set a list without a match type and the API defaults it to wildcard.

A wildcard entry matches subdomains, not the label itself: *.example.com covers shop.example.com but not example.com — the same reading as the DNS wildcard. Add the bare name as its own entry to include it.

string
Allowed values: "" exact wildcard regex
uptime_host_includes

Subdomains the default whole-host uptime watch covers. Absent or empty means every subdomain. Change with PUT /uptime/settings.

Array<string>
uptime_host_excludes

Subdomains the default uptime watch skips; an exclude always beats an include.

Array<string>
suspended

Paused for billing. The edge refuses the domain’s TLS handshake, so visitors get a connection error. Clears automatically once the wallet is no longer negative.

boolean
suspended_at
string format: date-time
created_at
string format: date-time
updated_at
string format: date-time
deleted_at

Always null — deleted domains are never returned.

string | null format: date-time
verification

The legacy TXT record that proves ownership of an external-DNS domain. Still accepted, but new domains verify with the CNAME in ssl_delegation, which also keeps their certificate renewing — prefer that one.

object
host

Name to create the TXT record at.

string
type
string
Allowed value: TXT
value

Exact TXT value to publish.

string
verified

Whether the domain has passed verification: false only while it is pending or failed.

boolean
expires_at

End of the current 3-day verification window. Absent once verified.

string format: date-time
seconds_remaining

Seconds left in the verification window.

integer
next_manual_check_at

When POST /domains/{domain}/verify may be called again (once a minute). Absent once verified, or if it never ran.

string format: date-time
auto_check_seconds

How often NSIN re-checks the record on its own, in seconds (300).

integer
ssl_delegation

An external-DNS domain’s verification record: one CNAME, created once and never rotated. It proves ownership (a pending domain activates when it is found) and stays in place afterwards as the domain’s connection to NSIN, which is what lets NSIN issue and renew the certificate for the apex and its wildcard. Once it has passed, removing or changing it marks the domain moved — it keeps serving for a 3-day grace period, then is disabled — exactly as a managed domain whose nameservers leave.

object
host

Name to create the CNAME at, e.g. _acme-challenge.example.com.

string
type
string
Allowed value: CNAME
value

The CNAME target, unique to this domain.

string
ok

Whether the last live check found this domain’s delegation in place.

boolean
checked_at

When the last check ran.

string format: date-time
ok_at

When the delegation last passed.

string format: date-time
error

Why the last check failed — or, with ok true, a CAA policy on the domain that prevents Let’s Encrypt from issuing.

string
next_manual_check_at
string format: date-time
auto_check_seconds

How often NSIN re-checks the record on its own.

integer
nsin_ns

The canonical (first) accepted nameserver set.

Array<string>
nsin_ns_sets

Every accepted nameserver set. The delegation must name every NSIN nameserver node, through any set’s hostname for it, and nothing else; see GET /domains/ns-sets.

Array<Array<string>>
current_ns

The nameservers currently observed in the parent zone.

Array<string>
my_role

Your role on a domain. owner is implicit for the domain’s creator and for global admins; the other three are grantable via sharing.

string
Allowed values: owner admin editor viewer
my_permissions
Array<string>
Allowed values: domain.view domain.settings domain.delete records.edit rules.edit cache.edit ssl.manage analytics.view billing members.manage
ns_check_interval_seconds

How often the background checker re-checks the delegation.

integer
billing_member

Whose wallet this domain’s charges come out of. Always present — it falls back to the owner — so a client can name the payer without a second request. Only the owner can change it, in the panel — API keys cannot.

object
user_id
integer
name
string
email
string
set_by

Who made the nomination. Absent when the owner pays.

integer
set_at
string format: date-time
is_owner

True when no nomination is in force and the domain owner pays. The owner being named explicitly is stored as no nomination, so this never disagrees with ownership.

boolean
Example
{
"name": "example.com",
"status": "pending",
"dns_mode": "managed",
"cache_cap_mb": 128,
"hsts_max_age_sec": 0,
"min_tls_version": "1.2",
"origin_protocol": "http1",
"bot_cache_kinds": [
"googlebot"
],
"gateway_quota_reason": "requests",
"uptime_host_match_type": "",
"verification": {
"type": "TXT"
},
"ssl_delegation": {
"type": "CNAME"
},
"my_role": "owner",
"my_permissions": [
"domain.view"
]
}

Malformed body or an invalid value — dns_mode not managed/external, cache_l2_max_gb below 1, cache_l2_ttl_days outside 1–7, cache_cap_mb not one of the tiers, an HSTS step that skips a rung or a hsts_preload without its prerequisites, min_tls_version or origin_protocol not one of the listed values, a bot_cache_* window outside 300–86400 s (or fresh longer than max age), an unknown or empty bot_cache_kinds, or a path exclude that does not start with /, is longer than 256 characters, or is one of more than 50.

Media type application/json

The single error shape used by every endpoint.

object
error
required

Human-readable description of what went wrong.

string
Examples
Example hstsStep
{
"error": "hsts_max_age_sec can only be raised one step at a time: next step is 3600 seconds. HSTS cannot be undone once browsers have seen it, so raise it only after the site has run without trouble at the current value"
}

Missing, malformed, revoked or expired API key. (A valid key whose account has been deactivated gets 403 account is inactive instead.)

Media type application/json

The single error shape used by every endpoint.

object
error
required

Human-readable description of what went wrong.

string
Examples
Example invalidKey
{
"error": "invalid API key"
}

The domain has no active plan and the update turns markdown_for_agents or the bot cache on. Plain-text body.

Media type text/plain
string
Example
This domain does not have an active plan.

Read-only key or insufficient role (JSON); a cache value above the plan’s ceiling (JSON, with max_cap_mb, max_disk_gb or max_ttl_days and upgrade_url); or the plan lacks the bot cache feature (plain-text body).

object
error
required

Human-readable description of what went wrong.

string
max_cap_mb

The largest cache_cap_mb the plan allows.

integer
max_disk_gb

The largest cache_l2_max_gb the plan allows.

integer
max_ttl_days

The largest cache_l2_ttl_days the plan allows.

integer
upgrade_url

Where in the panel to upgrade the plan.

string
Examples
Example capTooBig
{
"error": "cache_cap_mb exceeds your plan limit",
"max_cap_mb": 512,
"upgrade_url": "/plans"
}

No such domain, or it is not visible to this account. Domains you cannot access are reported as not found rather than forbidden.

Media type application/json

The single error shape used by every endpoint.

object
error
required

Human-readable description of what went wrong.

string
Example
{
"error": "read-only API key"
}

The domain is banned, so its dns_mode cannot be changed.

Media type application/json

The single error shape used by every endpoint.

object
error
required

Human-readable description of what went wrong.

string
Example
{
"error": "read-only API key"
}

The key exceeded its request budget (300 requests per minute by default).

Media type application/json

The single error shape used by every endpoint.

object
error
required

Human-readable description of what went wrong.

string
Examples
Example limited
{
"error": "rate limit exceeded"
}