Run these calls against the sandbox. Nothing there
reaches a carrier and nothing is billed. The same calls work in production
with a production key and https://api.checknetworks.tools/v2.
Before you start
- Get a sandbox. In the production portal, an Owner or Admin goes to Company Settings, then Integrations, then API Keys and chooses Create Sandbox. Choose Open Sandbox on the same page to sign in to it. See The API sandbox.
- In the sandbox portal, go to Company Settings, then Integrations, then
API Keys. Create a key with the
data:readscope. Copy the Client ID and the Client Secret. The secret is shown once. A sandbox secret startscn_test_. See API Keys and Scopes. - Put them in your shell, and every example below runs as it is:
export CN_BASE=https://api.checknetworks.dev/v2
export CN_CLIENT_ID=your-client-id
export CN_CLIENT_SECRET=your-client-secret
The curl examples use jq to take the token out of the response.
1. Get a token
Ask POST /oauth/token for a token with the scopes you need. Here that is
data:read:
TOKEN=$(curl -s "$CN_BASE/oauth/token" \
-d grant_type=client_credentials \
-d client_id="$CN_CLIENT_ID" \
-d client_secret="$CN_CLIENT_SECRET" \
-d scope=data:read | jq -r .access_token)
This is the full response, before jq takes the token out:
{
"token_type": "Bearer",
"expires_in": 3600,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI5ZDZiMmMx...",
"scope": "data:read"
}
scope is what the token can actually do. If you ask for a scope the key
isn’t allowed, we leave it out instead of refusing the request. The token
lasts an hour, and expires_in is in seconds. Reuse it until then, and ask
for a new one when it runs out.
2. Check the token
Send the token on every call as Authorization: Bearer <token>. GET /ping
tells you which key and account answered and what the token carries:
curl -s "$CN_BASE/ping" -H "Authorization: Bearer $TOKEN"
{
"result": {
"keyId": "9d6b2c1e-4f3a-4b8e-9c2d-1a7e5f3b8c40",
"name": "Quick start",
"scopes": ["data:read"],
"accountId": "840100",
"ip": "203.0.113.10",
"ipAllowlistActive": false,
"environment": "sandbox",
"tokenExpiresAt": "2026-11-21T03:00:00+00:00"
}
}
You’ll see your own ids, address and times. environment is sandbox
here and live in production. When a later call is refused, call
GET /ping first. It shows the token’s scopes and the address we saw.
3. List your data services
GET /data/services lists your NBN and Opticomm services:
curl -s "$CN_BASE/data/services" -H "Authorization: Bearer $TOKEN"
A new sandbox has no services yet, so the list is empty:
{
"total": 0,
"page": 1,
"perPage": 50,
"results": []
}
When a connect you order in the sandbox completes, its service shows up here. Data services covers qualifying an address and placing an order. Paging through lists shows how to read past the first page.
The same in PHP, Python and JavaScript
Each script makes the same three calls and reads the same environment variables.
PHP
With Guzzle (composer require guzzlehttp/guzzle):
<?php
require 'vendor/autoload.php';
$base = getenv('CN_BASE');
$http = new GuzzleHttp\Client();
// 1. Get a token.
$token = json_decode((string) $http->post("{$base}/oauth/token", [
'form_params' => [
'grant_type' => 'client_credentials',
'client_id' => getenv('CN_CLIENT_ID'),
'client_secret' => getenv('CN_CLIENT_SECRET'),
'scope' => 'data:read',
],
])->getBody(), true)['access_token'];
$headers = ['Authorization' => "Bearer {$token}", 'Accept' => 'application/json'];
// 2. Check the token.
$ping = json_decode((string) $http->get("{$base}/ping", ['headers' => $headers])->getBody(), true);
echo $ping['result']['environment'], "\n"; // sandbox
// 3. List your data services.
$services = json_decode((string) $http->get("{$base}/data/services", ['headers' => $headers])->getBody(), true);
echo $services['total'], "\n"; // 0 on a new sandbox
Python
With Requests (pip install requests):
import os
import requests
base = os.environ["CN_BASE"]
# 1. Get a token.
token = requests.post(f"{base}/oauth/token", data={
"grant_type": "client_credentials",
"client_id": os.environ["CN_CLIENT_ID"],
"client_secret": os.environ["CN_CLIENT_SECRET"],
"scope": "data:read",
}).json()["access_token"]
headers = {"Authorization": f"Bearer {token}"}
# 2. Check the token.
ping = requests.get(f"{base}/ping", headers=headers).json()
print(ping["result"]["environment"]) # sandbox
# 3. List your data services.
services = requests.get(f"{base}/data/services", headers=headers).json()
print(services["total"]) # 0 on a new sandbox
JavaScript
This needs Node 18 or later, which has fetch built in. Save it as
quick-start.mjs and run node quick-start.mjs:
const base = process.env.CN_BASE;
// 1. Get a token.
const tokenResponse = await fetch(`${base}/oauth/token`, {
method: 'POST',
body: new URLSearchParams({
grant_type: 'client_credentials',
client_id: process.env.CN_CLIENT_ID,
client_secret: process.env.CN_CLIENT_SECRET,
scope: 'data:read',
}),
});
const { access_token: token } = await tokenResponse.json();
const headers = { Authorization: `Bearer ${token}`, Accept: 'application/json' };
// 2. Check the token.
const ping = await (await fetch(`${base}/ping`, { headers })).json();
console.log(ping.result.environment); // sandbox
// 3. List your data services.
const services = await (await fetch(`${base}/data/services`, { headers })).json();
console.log(services.total); // 0 on a new sandbox
In Postman
You can make the same calls in Postman without writing code:
- Import the collection and the sandbox environment. Choose Check Networks Sandbox as the environment.
- Fill in the environment. Replace the placeholders in
clientIdandclientSecretwith your sandbox key’s Client ID and Client Secret.scopestarts asdata:read. Change it to the scopes you need, separated by spaces. - Under Wholesale Account, then Authentication, send
Check Your Token. It is
GET /ping.
You never paste a token in. The collection asks POST /oauth/token for one
before your first request, and for a new one before it expires. To get a
token by hand, send Request an Access Token, the first request in the
collection.
Every call in the reference is in the collection, grouped as the reference
groups them, with its example values filled in. A write that takes an
Idempotency-Key sends a new one each time you send it. For production,
import the
production environment
and fill in a production key. Every call then runs against your real
account.
If a call is refused
Every error has the same body. Its code is what your code branches on,
and its docUrl links to what the error means.
| The API answers | What it means |
|---|---|
401 |
The token is missing or has run out. Ask for a new one. |
403 missing_scope |
The token doesn’t carry the scope the call needs. |
See API errors.
Next steps
| Read | For |
|---|---|
| Webhooks | Having events sent to you instead of polling for them. |
| Retrying writes safely | The Idempotency-Key every carrier write needs. |
| API errors | Every error code and what to do about it. |
| API rate limits | The limits, the headers that say where you stand, and how to back off. |
| Paging through lists | Reading a list to the end, and the CSV and NDJSON downloads. |
| API reference | Every endpoint, with request samples. |
| Client libraries | Clients for PHP, Python and JavaScript that sign in and retry for you. |