nsindocs Search the docs⌘K
  1. Docs
  2. API reference
  3. Domains

Set the domain's custom pages

puthttps://api.nsin.ir/domains/{domain}/custom-pages

Auth: Authorization: Bearer nsin_… or X-Api-Key: nsin_… — see API keys.

Replaces the whole setting — send all four pages, since a page left out goes back to the NSIN page. Each page is one of three modes: nsin (the branded NSIN page), custom (your own HTML, at most 32 KiB, UTF-8) or redirect (a 302 to a full http:// or https:// URL). The field the mode does not use is kept as stored, so switching modes does not lose a draft.

While maintenance.enabled is true, every request to the domain is answered by the edge with 503 and never reaches the origin, except from maintenance.bypass_ips. A maintenance redirect must point at another domain.

Anything other than the defaults needs a plan with rules. The change reaches the edge with the next records sync. Requires domain.settings.

Path parameters

  • domainstringrequiredpath

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

Request body

Content type: application/json · required

  • blockedCustomPage

    One page the edge serves itself.

    Fields
    • modestring

      nsin — the branded NSIN page; custom — the HTML in html; redirect — a 302 to url.

      One of: "nsin" "custom" "redirect"
      Default: "nsin"
    • htmlstring

      Your page, used in mode custom. At most 32 KiB, UTF-8.

    • urlstring

      Full http:// or https:// address, used in mode redirect. At most 2048 characters.

  • wafCustomPage

    One page the edge serves itself.

    Fields
    • modestring

      nsin — the branded NSIN page; custom — the HTML in html; redirect — a 302 to url.

      One of: "nsin" "custom" "redirect"
      Default: "nsin"
    • htmlstring

      Your page, used in mode custom. At most 32 KiB, UTF-8.

    • urlstring

      Full http:// or https:// address, used in mode redirect. At most 2048 characters.

  • rate_limitCustomPage

    One page the edge serves itself.

    Fields
    • modestring

      nsin — the branded NSIN page; custom — the HTML in html; redirect — a 302 to url.

      One of: "nsin" "custom" "redirect"
      Default: "nsin"
    • htmlstring

      Your page, used in mode custom. At most 32 KiB, UTF-8.

    • urlstring

      Full http:// or https:// address, used in mode redirect. At most 2048 characters.

  • maintenanceobject

    One page the edge serves itself.

    Fields
    • modestring

      nsin — the branded NSIN page; custom — the HTML in html; redirect — a 302 to url.

      One of: "nsin" "custom" "redirect"
      Default: "nsin"
    • htmlstring

      Your page, used in mode custom. At most 32 KiB, UTF-8.

    • urlstring

      Full http:// or https:// address, used in mode redirect. At most 2048 characters.

    • enabledboolean

      While true, the edge answers every request with 503 and the origin is not reached.

    • bypass_ipsarray of string

      Addresses that still reach the site during maintenance — single IPs, CIDR prefixes or low-high ranges.

Responses

200The stored setting.

Content type: application/json

  • blockedCustomPage

    One page the edge serves itself.

    Fields
    • modestring

      nsin — the branded NSIN page; custom — the HTML in html; redirect — a 302 to url.

      One of: "nsin" "custom" "redirect"
      Default: "nsin"
    • htmlstring

      Your page, used in mode custom. At most 32 KiB, UTF-8.

    • urlstring

      Full http:// or https:// address, used in mode redirect. At most 2048 characters.

  • wafCustomPage

    One page the edge serves itself.

    Fields
    • modestring

      nsin — the branded NSIN page; custom — the HTML in html; redirect — a 302 to url.

      One of: "nsin" "custom" "redirect"
      Default: "nsin"
    • htmlstring

      Your page, used in mode custom. At most 32 KiB, UTF-8.

    • urlstring

      Full http:// or https:// address, used in mode redirect. At most 2048 characters.

  • rate_limitCustomPage

    One page the edge serves itself.

    Fields
    • modestring

      nsin — the branded NSIN page; custom — the HTML in html; redirect — a 302 to url.

      One of: "nsin" "custom" "redirect"
      Default: "nsin"
    • htmlstring

      Your page, used in mode custom. At most 32 KiB, UTF-8.

    • urlstring

      Full http:// or https:// address, used in mode redirect. At most 2048 characters.

  • maintenanceobject

    One page the edge serves itself.

    Fields
    • modestring

      nsin — the branded NSIN page; custom — the HTML in html; redirect — a 302 to url.

      One of: "nsin" "custom" "redirect"
      Default: "nsin"
    • htmlstring

      Your page, used in mode custom. At most 32 KiB, UTF-8.

    • urlstring

      Full http:// or https:// address, used in mode redirect. At most 2048 characters.

    • enabledboolean

      While true, the edge answers every request with 503 and the origin is not reached.

    • bypass_ipsarray of string

      Addresses that still reach the site during maintenance — single IPs, CIDR prefixes or low-high ranges.

json
{
  "blocked": {
    "mode": "nsin",
    "html": "string",
    "url": "string"
  },
  "waf": {
    "mode": "nsin",
    "html": "string",
    "url": "string"
  },
  "rate_limit": {
    "mode": "nsin",
    "html": "string",
    "url": "string"
  },
  "maintenance": {
    "mode": "nsin",
    "html": "string",
    "url": "string",
    "enabled": true,
    "bypass_ips": [
      "string"
    ]
  }
}
400The body is not JSON, or a page is invalid: an unknown mode, custom with no HTML, redirect with no URL, HTML over 32 KiB or not UTF-8, a URL that is not a full http(s):// address or is over 2048 characters, a maintenance redirect onto the domain itself, more than 100 bypass addresses, or a bypass entry that is not an IP, a CIDR or a low-high range. The message names the page. Nothing is stored.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "rate_limit: add the HTML of your page"
}
401Missing, malformed, revoked or expired API key. (A valid key whose account has been deactivated gets 403 account is inactive instead.)

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "invalid API key"
}
402The domain has no active plan and the setting is not the default.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "This domain does not have an active plan."
}
403The key is read-only, your role on the domain lacks the required permission, or the domain's plan does not include the feature.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
404No such domain, or it is not visible to this account. Domains you cannot access are reported as not found rather than forbidden.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
429The key exceeded its request budget (300 requests per minute by default).

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "rate limit exceeded"
}

Example request

bash
curl -X PUT "https://api.nsin.ir/domains/example.com/custom-pages" \
  -H "Authorization: Bearer $NSIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "blocked": {
    "mode": "nsin",
    "html": "",
    "url": ""
  },
  "waf": {
    "mode": "nsin",
    "html": "",
    "url": ""
  },
  "rate_limit": {
    "mode": "custom",
    "html": "<h1>Slow down</h1>",
    "url": ""
  },
  "maintenance": {
    "mode": "redirect",
    "html": "",
    "url": "https://status.example.net/",
    "enabled": true,
    "bypass_ips": [
      "203.0.113.7",
      "198.51.100.0/24"
    ]
  }
}'
esc