Skip to main content
NSP protects its REST and WebSocket API with bearer-style API keys. Every request to the daemon — whether from your own agent code, a curl command, or the Python SDK — must include a valid key in the X-Substrate-Key header. The daemon verifies the key by comparing a BLAKE3 hash; the plaintext value is never stored on disk.
Never commit API keys to source control. Store them in environment variables or a secrets manager. The Python SDK reads NSP_API_KEY automatically so you can avoid putting the key in code at all.

Generating a Key

Run keygen from the directory where axon-daemon.exe lives, or from any terminal where it is on your PATH:
The daemon writes a new entry to axon_keys.json and prints the plaintext key once — this is the only time you will see it:
Add a --label to track which key belongs to which agent:
Use one key per agent process. Separate labels make it easy to disable a single agent’s access without affecting others.

Key Format

All NSP API keys start with the prefix sk_nsp_ followed by a random alphanumeric string:
Keys are case-sensitive. Treat them like passwords.

Enabling Authentication in axon.toml

Open axon.toml (located in the daemon’s working directory or C:\ProgramData\Nelieo\) and confirm the [auth] section is configured:
The daemon reloads axon_keys.json every 5 seconds without requiring a restart, so you can add, disable, or delete keys without any downtime.
If require_key is false, the daemon prints a warning every 60 seconds. Treat that warning as a deployment blocker — disable auth only in isolated local development environments.

The Keys File

All keys live in the JSON file pointed to by keys_file. The daemon stores only the BLAKE3 hash — you cannot recover the original key from this file.
To revoke a key while preserving the audit trail, set "enabled": false rather than deleting the entry:

Authenticating Requests

Pass the key in the X-Substrate-Key header on every request.
With a valid key:
Without a key (returns 401):

The NSP_API_KEY Environment Variable

The Python SDK automatically reads NSP_API_KEY from the process environment when you do not pass api_key to NSPClient. Set this variable in your shell profile, a .env file (excluded from source control), or your deployment environment:

401 Error Responses

The daemon returns 401 Unauthorized for three distinct authentication failures: All three return the same JSON envelope:
In the Python SDK, all three map to NSPAuthError. Inspect e.code to distinguish them:

Rotating Keys

Follow these steps when rotating a key — for example, during a periodic security rotation or after a suspected leak:
1

Generate a replacement key

Copy the printed sk_nsp_... value and store it in your secrets manager.
2

Update your agent configuration

Update NSP_API_KEY in your deployment environment or secrets manager to point to the new key.
3

Verify the new key works

Confirm you receive a 200 OK response before proceeding.
4

Disable the old key

Open axon_keys.json and set "enabled": false on the old entry. The daemon picks up the change within 5 seconds.
5

Delete the old key after a grace period

After 24 hours with no authentication errors using the new key, delete the old key entry from axon_keys.json to keep the file tidy.