nsindocs Search the docs⌘K
  1. Docs
  2. API & MCP

API reference

Public REST API for NSIN CDN, DNS and edge-security management. 355 endpoints · base URL https://api.nsin.ir · openapi.yaml

The NSIN API lets you manage everything you can manage from the panel: domains, DNS records, edge rules (cache, WAF, redirects, rate limiting, …), TLS certificates, analytics, uptime and domain sharing.

Authentication

Every endpoint in this reference is authenticated with an API key, with one exception: the NSIN SSO endpoints at the end, which are the OAuth 2.1 / OpenID Connect provider and authenticate with their own credentials (see that section). Create a key in the panel under Settings → API keys. Keys are shown once at creation time and are prefixed nsin_.

Send the key either way — both are equivalent:

text
Authorization: Bearer nsin_xxxxxxxxxxxxxxxxxxxx
text
X-Api-Key: nsin_xxxxxxxxxxxxxxxxxxxx

Read-only keys

A key marked read-only may only issue GET, HEAD and OPTIONS requests, plus one POST that writes nothing: POST /analytics/query, which runs a read-only query over your request logs. Any other write returns 403 with {"error": "read-only API key"}, regardless of the endpoint.

GET /whoami tells a client which credential it is holding — whether the key is read-only, whether it may read mail (email_read), and for app-issued credentials which domains it may touch.

Reading mail (email:read)

Mail kept in a domain's inbox (Email Routing with an inbox plan) can be read with a key only when that key has the email:read permission. It is off for every key unless you turn it on, when you create the key or later, in Settings → API keys. Full access does not include it. A key without it gets 403 with "code": "email_read_required" on the inbox endpoints.

With it, a key may list the inbox, open a message, download the raw .eml and download an attachment, for the domains the key can see. It can never move, mark, or delete mail, or accept the inbox terms: those stay in the panel. Opening a message with a key does not mark it read unless you add ?mark_read=true (a read-only key never marks it). Every read made with a key, lists included, is recorded with the key, the message and the caller's IP.

To learn when mail arrives without polling, set a mail webhook on the domain (see the mailEvent webhook below) and open the message by the inbox_message_id it carries.

What API keys cannot do

Some parts of the product are deliberately unreachable with a key, so that a leaked key can never take over the account or spend money. These return 403 for every key, including full-access ones:

Surface Reason
/users/** Profile, password, sessions and API-key management. A key cannot mint or revoke keys.
/auth/** Login, registration, OTP.
/billing/** Plan catalogue and billing settings.
/admin/** Administrative surface.
/oauth/**, /.well-known/** NSIN SSO. A key must never be able to mint a federated login; these endpoints take their own credentials (see the SSO section).
POST /wallet/topup Moves money.
POST /subscriptions/purchase, /switch, /auto-renew Moves money.
POST /domains/{domain}/subscriptions/purchase, /switch, /auto-renew Moves money.
POST /domains/{domain}/gateway-packs/purchase Moves money.
PUT /domains/{domain}/billing-member Chooses whose wallet pays for the domain.
/domains/{domain}/email-routing/inbox/** writes and terms Moving, marking and deleting stored mail and accepting the inbox terms stay in the panel. Reads need email:read.
/domains/{domain}/email-routing/webhook/** The mail webhook settings carry its signing secret; they are set in the panel.

The denied surfaces answer {"error": "this endpoint is not available to API keys"}; the money-moving writes answer {"error": "API keys cannot move money — top-ups and plan purchases must be done from the panel"}. Reading subscription, feature, traffic-usage, invoice and wallet state is allowed — only the money-moving writes are blocked.

Keys belonging to a deactivated account are refused with 403 {"error": "account is inactive"}.

Rate limiting

Requests are limited per key, by default to 300 requests per minute. Exceeding it returns 429 with {"error": "rate limit exceeded"}. Panel (browser) traffic is limited separately and does not consume your key's budget.

Conventions

  • {domain} path parameter — every path segment written as {domain} is the domain name (example.com), not a numeric id. Percent-encode it if it contains characters that are unsafe in a path segment.
  • Errors — all errors share one shape: {"error": "human readable message"}. See the Error schema.
  • Timestamps — RFC 3339 / ISO 8601 strings in UTC unless stated otherwise.
  • Byte counts — always bytes; traffic and quota values are documented per field.
  • Access control — a key inherits the permissions of the user who owns it. For a shared domain that is the role granted to that user (viewer, editor, admin); for your own domains it is owner. Endpoints document the permission they require, and return 403 when the role lacks it and 404 when the domain is not visible to you at all.

Plan features

Several endpoints are gated on the domain's active plan (analytics, logs, WAF, custom certificates, …). When the plan does not include the feature the response is 403 with an error explaining which feature is missing. When the domain has no active plan at all — for example a subscription that expired and was not renewed — the gated endpoints answer 402 instead, and so do the writes that count against a plan allowance (new DNS records, rules and email addresses).

Endpoints

Domains

Add, configure, verify and remove domains.

DNS Records

DNS record CRUD, bulk operations, zone scan and import — including the staged import sessions that let a scan be reviewed before it is written.

Gateways

Ready-made records you can switch on for a domain in one call.

SSL

Certificate status, manual issuance and custom certificate upload.

Rules

Edge rules — cache, drop, redirect, rewrite, header, web optimization, WAF, captcha, basic auth, rate limit, bot routing, origin pools and routes, fingerprinting and error pages. Every type has the same seven operations: list, create, reorder, get, update, delete and toggle.

Cache

Cache statistics, key browsing and purging.

Analytics

Traffic analytics, request logs and ad-hoc queries over your own traffic.

Uptime

Origin outage detection: incidents, live per-host status, detection settings, path-scoped monitors, the alert channels (email, SMS, webhook) and the signed uptime webhook.

Custom Name Servers

Let a domain answer under its own name servers (ns1.example.com, ns2.example.com) instead of NSIN's. You set the names and their IPs at your registrar. Enterprise plans.

Email Routing

Custom email addresses on a domain (info@example.com) forwarded to destination addresses you verify by clicking an emailed link. NSIN publishes the MX, SPF and DKIM records into the zone and receives and forwards the mail; nothing is stored.

Recommendations

The per-domain advisory checklist — speed, SEO, reachability, security and plan findings — with per-user dismissals, and an account-wide view.

Sharing

Domain members and invitations.

Billing

Read-only access to subscriptions, features, traffic usage, invoices and wallet.

Support

Support tickets.

Notifications

The notification feed — domain, plan and account events.

Account

Account-wide reads: who the calling credential is (/whoami), the unread counters (/badges) and the edge addresses to point DNS at.

Reseller

For accounts NSIN has made resellers: create users, add and manage their domains, choose who pays, move money, invite users to log in and see what their domains cost. Amounts are in rials. A guide is at https://reseller.nsin.ir/docs.

SSO

NSIN SSO — the OAuth 2.1 / OpenID Connect provider that lets another application sign users in with their NSIN account. These endpoints do not take an API key; each one authenticates with its own credential.

esc