Skip to content

Authentication API

Verify a PIN and receive a bearer token for accessing protected endpoints.

POST /api/auth
Content-Type: application/json
{
"pin": "your-pin"
}
FieldTypeRequiredDescription
pinstringYesYour authentication PIN
{
"token": "a1b2c3d4e5f6789012345678901234567890123456789012345678901234"
}
FieldTypeDescription
tokenstring64-character hex string (32 bytes)
{
"error": "Invalid PIN"
}
{
"error": "Rate limited"
}
{
"error": "Failed to read PIN hash: ..."
}
  • Format: 64 hex characters (32 random bytes)
  • Expiry: 15 minutes from creation
  • Storage: In-memory only (cleared on restart)
  • Limit: 10 attempts per minute per IP address
  • Window: 60 seconds (sliding window)
  • Scope: Per IP address (different IPs have separate limits)

If rate limited, wait 60 seconds before retrying.

Terminal window
curl -X POST http://localhost/api/auth \
-H "Content-Type: application/json" \
-d '{"pin": "1234"}'
const response = await fetch('http://localhost/api/auth', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ pin: '1234' })
});
const { token } = await response.json();
import requests
response = requests.post(
'http://localhost/api/auth',
json={'pin': '1234'}
)
token = response.json()['token']

Include the token in the Authorization header for protected endpoints:

Terminal window
curl http://localhost/api/status \
-H "Authorization: Bearer $TOKEN"

See API Overview for the full authentication flow.