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

Set the NsinNabz analytics tag

puthttps://api.nsin.ir/domains/{domain}/analytics-tag

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

Stores the NsinNabz tag for the edge to insert into the HTML pages of this domain's proxied hostnames, so the site needs no pasted snippet. Gateway hostnames never get it. NsinNabz calls this itself when its "Install automatically through the NSIN edge" switch is turned on; the NSIN panel only shows the result. Requires domain.settings. No plan is needed.

The tag must be exactly NsinNabz's tag, matching the whole string against:

text
^<script async src="https://[a-z0-9]([a-z0-9.-]{0,251}[a-z0-9])?(:[0-9]{1,5})?/s\.js" data-site="[A-Za-z0-9_]{8,64}" data-edge="1"( data-gpc="1")?( data-cookie="1")?( data-api="https://[a-z0-9]([a-z0-9.-]{0,251}[a-z0-9])?(:[0-9]{1,5})?/e")?></script>$

and its script host (with the port, if there is one) must be a NsinNabz tracker host (nabz-s.nsincloud.ir or s.nsinnabz.ir). Nothing else is ever inserted into your pages.

Sending the tag that is already stored changes nothing: the answer carries the stored updated_at. A new tag reaches every edge node with the next records sync.

Path parameters

  • domainstringrequiredpath

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

Request body

Content type: application/json · required

  • tagstringrequired

    The NsinNabz <script> tag, byte for byte.

Responses

200The stored tag.

Content type: application/json

  • tagstring | nullrequired

    The <script> tag the edge inserts into the domain's HTML pages.

  • updated_atstring | null (date-time)required

    When the tag last changed (UTC).

json
{
  "tag": "string",
  "updated_at": "2026-01-01T00:00:00Z"
}
400The body is not JSON or has no string tag (invalid request body), or the tag is refused with code invalid_analytics_tag: it does not match the pattern above, or its script host is not a NsinNabz tracker host. Nothing is stored.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

  • codestring
    One of: "invalid_analytics_tag"
json
{
  "error": "invalid request body"
}
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"
}
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/analytics-tag" \
  -H "Authorization: Bearer $NSIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "tag": "<script async src=\"https://nabz-s.nsincloud.ir/s.js\" data-site=\"site_AAAA1111\" data-edge=\"1\" data-gpc=\"1\"></script>"
}'
esc