Back to Getting Started

Getting Started with the NOC API | NOC.org Support

The NOC REST API lets you programmatically manage CDN sites, WAF rules, DNS records, and monitoring endpoints. This guide covers authentication, common endpoints, and practical curl examples to get you started.

Prerequisites

  • An active NOC.org account.
  • An API key generated from the NOC Dashboard.
  • curl or any HTTP client (Postman, httpie, etc.).

Step 1 — Generate an API Key

  1. Log in to the NOC Dashboard.
  2. Click your account name in the top-right corner and select API Keys.
  3. Click Create API Key.
  4. Give the key a descriptive name (e.g., "CI/CD Pipeline" or "Monitoring Script").
  5. Copy the key immediately — it will not be shown again.

Important: Treat your API key like a password. Do not commit it to version control or share it in public channels.

Step 2 — Authentication

All API requests require an Authorization header with your API key:

Authorization: Bearer YOUR_API_KEY

The base URL for all API endpoints is:

https://api.noc.org/v1

Step 3 — Common API Endpoints

List All Sites

curl -s -H "Authorization: Bearer YOUR_API_KEY" \
  https://api.noc.org/v1/sites

Returns a JSON array of all sites on your account with their IDs, domains, and status.

Get Site Details

curl -s -H "Authorization: Bearer YOUR_API_KEY" \
  https://api.noc.org/v1/sites/{site_id}

Create a New Site

curl -s -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "example.com",
    "origin_ip": "203.0.113.50",
    "origin_port": 443,
    "ssl": true
  }' \
  https://api.noc.org/v1/sites

Purge CDN Cache

# Purge everything
curl -s -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"purge_all": true}' \
  https://api.noc.org/v1/sites/{site_id}/cache/purge

# Purge specific URLs
curl -s -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://example.com/style.css", "https://example.com/app.js"]}' \
  https://api.noc.org/v1/sites/{site_id}/cache/purge

Update WAF Rules

curl -s -X PATCH \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"waf_enabled": true, "block_bad_bots": true}' \
  https://api.noc.org/v1/sites/{site_id}/waf

List DNS Records

curl -s -H "Authorization: Bearer YOUR_API_KEY" \
  https://api.noc.org/v1/dns/{domain}/records

Delete a Site

curl -s -X DELETE \
  -H "Authorization: Bearer YOUR_API_KEY" \
  https://api.noc.org/v1/sites/{site_id}

Response Format

All responses are returned as JSON. A successful response includes a status field:

{
  "status": "success",
  "data": { ... }
}

Error responses include a message and HTTP status code:

{
  "status": "error",
  "message": "Site not found",
  "code": 404
}

Rate Limits

API requests are rate-limited to 60 requests per minute per API key. If you exceed this limit, you will receive a 429 Too Many Requests response. The Retry-After header indicates how many seconds to wait before retrying.

Next Steps

Improve Your Websites Speed and Security

14 days free trial. No credit card required.