Northgale API Reference
The Northgale API is an HTTP REST API that wraps any AI model output in a structured Decision Card — surfacing the recommendation, confidence score, evidence trail, risk flags, and a plain-language next action. Every call is automatically logged to a tamper-evident audit trail.
Base URL: https://api.northgale.io/api/v1
All requests must include x-api-key header. Responses are JSON.
Authentication
All API endpoints require an API key passed in the x-api-key request header. Get your key from the dashboard.
curl https://api.northgale.io/api/v1/me \ -H "x-api-key: ng_live_your_key_here"
API keys are prefixed ng_live_ for production and ng_test_ for testing. Keep your key secret — it carries your quota and billing.
Quick Start
Get your first Decision Card in under 60 seconds.
1. Install the SDK
npm install @northgale/sdk
2. Wrap your first AI output
import Northgale from '@northgale/sdk';
const northgale = new Northgale({ apiKey: 'ng_live_your_key_here' });
const result = await northgale.explain({
input_text: 'Account scored 91/100. High purchase intent based on recent engagement.',
workflow_type: 'sales',
confidence: 0.91,
evidence: [
{ source: 'CRM activity', text: 'Opened 14 emails in last 30 days', weight: 0.6 },
{ source: 'Intent data', text: 'Visited pricing page 3x this week', weight: 0.4 },
],
risk_factors: [
{ severity: 'low', description: 'No confirmed technical buyer identified yet' },
],
});
console.log(result.decision_card.next_action);
// → "Prioritize this account — confidence is high. Schedule outreach within 48 hours."
console.log(result.decision_card.confidence);
// → { score: 0.91, label: 'high' }Response:
{
"id": "dc_01HZR7...",
"object": "decision_card",
"created_at": "2026-05-18T21:00:00.000Z",
"workflow_type": "sales",
"decision_card": {
"recommendation": "Account scored 91/100. High purchase intent based on recent engagement.",
"confidence": {
"score": 0.91,
"label": "high"
},
"reasoning": "High purchase intent based on recent engagement.",
"evidence_trail": [
{ "source": "CRM activity", "text": "Opened 14 emails in last 30 days", "weight": 0.6 },
{ "source": "Intent data", "text": "Visited pricing page 3x this week", "weight": 0.4 }
],
"risk_flags": [
{ "severity": "low", "description": "No confirmed technical buyer identified yet" }
],
"next_action": "Prioritize this account — confidence is high. Schedule outreach within 48 hours."
},
"audit": {
"request_id": "req_abc123",
"tier": "pro"
}
}Prefer raw HTTP? See the curl examples in each endpoint section below.
Errors & Rate Limits
| Parameter | Type | Description |
|---|---|---|
| 400 | Bad Request | Missing or invalid request parameters. Check the error field for details. |
| 401 | Unauthorized | Missing or invalid x-api-key header. |
| 402 | Payment Required | Subscription is canceled or past due. Update payment method in the dashboard. |
| 403 | Forbidden | Your plan does not include this feature. Upgrade to access it. |
| 404 | Not Found | Resource not found or belongs to a different account. |
| 409 | Conflict | Duplicate resource (e.g. workflow name already exists). |
| 429 | Too Many Requests | Monthly quota exceeded. Remaining calls shown in X-RateLimit-Remaining header. |
| 500 | Server Error | Internal error. Retry with exponential backoff. |
Rate limit headers are included on every response:
X-RateLimit-Tier: pro X-RateLimit-Limit: 100000 X-RateLimit-Remaining: 98732
Explain
/api/v1/explainThe core Northgale endpoint. Accepts a raw AI model output plus optional context, and returns a fully structured Decision Card with confidence scoring, evidence trail, risk flags, and a plain-language next action. Every call is persisted to your audit log.
Request body
| Parameter | Type | Description |
|---|---|---|
| input_textrequired | string | The raw AI output to explain. Required. Must be non-empty. |
| confidence | number | Confidence score (0–1). If omitted, Northgale infers from the text. |
| reasoning | string | Why the model reached this conclusion. If omitted, extracted from input_text. |
| evidence | array | Array of {source, text, weight?} objects — sources the model referenced. |
| risk_factors | array | Array of {severity: 'high'|'medium'|'low', description} risk conditions. |
| next_action | string | Recommended human action. Auto-derived from workflow_type + confidence if omitted. |
| workflow_type | string | 'sales' | 'support' | 'underwriting' | 'hr' | 'legal' | 'custom'. Drives next_action defaults. |
| application_id | string | Your app's identifier — used for filtering in /explain list and audit exports. |
| input_model | string | The model that generated the output, e.g. 'gpt-4o', 'claude-3-5-sonnet'. |
| input_context | object | Arbitrary key/value context to store alongside the decision card. |
| workflow_id | string | UUID of a saved workflow template to associate with this call. |
| metadata | object | Additional key/value pairs to attach to the record. |
Example
curl -X POST /api/v1/explain \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input_text": "Applicant approved. Debt-to-income ratio within acceptable range.",
"workflow_type": "underwriting",
"confidence": 0.82,
"input_model": "gpt-4o",
"evidence": [
{ "source": "Credit bureau", "text": "DTI: 34%, below 43% threshold", "weight": 0.7 },
{ "source": "Bank statements", "text": "Stable income for 24 months", "weight": 0.3 }
],
"risk_factors": [
{ "severity": "medium", "description": "Recent hard inquiry from another lender" }
]
}'Response
{
"id": "dc_01HZR7KL9N2MXP4Q",
"object": "decision_card",
"created_at": "2026-05-18T21:00:00.000Z",
"workflow_type": "underwriting",
"application_id": null,
"input_model": "gpt-4o",
"decision_card": {
"recommendation": "Applicant approved. Debt-to-income ratio within acceptable range.",
"confidence": { "score": 0.82, "label": "high" },
"reasoning": "Debt-to-income ratio within acceptable range.",
"evidence_trail": [
{ "source": "Credit bureau", "text": "DTI: 34%, below 43% threshold", "weight": 0.7 },
{ "source": "Bank statements", "text": "Stable income for 24 months", "weight": 0.3 }
],
"risk_flags": [
{ "severity": "medium", "description": "Recent hard inquiry from another lender" }
],
"next_action": "Proceed with standard underwriting workflow. Risk profile is well-characterized."
},
"audit": { "request_id": "req_abc123", "tier": "pro" }
}Explain Batch
/api/v1/explain/batchExplain up to 10 AI outputs in a single HTTP request. Useful for bulk account scoring, support queue processing, or batch underwriting. Each item uses the same schema as /explain. Charges 1 token per item.
Request body
| Parameter | Type | Description |
|---|---|---|
| itemsrequired | array | Array of explain request objects (same fields as POST /explain). Max 10. |
| workflow_type | string | Default workflow_type applied to all items unless overridden per-item. |
| application_id | string | Default application_id applied to all items. |
| input_model | string | Default input_model applied to all items. |
curl -X POST /api/v1/explain/batch \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"workflow_type": "sales",
"items": [
{ "input_text": "Acme Corp scored 94. Strong buying signals.", "confidence": 0.94 },
{ "input_text": "BetaCo scored 51. Low engagement this quarter.", "confidence": 0.51 },
{ "input_text": "Gamma Inc scored 78. Mid-cycle, needs review.", "confidence": 0.78 }
]
}'{
"object": "list",
"count": 3,
"results": [
{
"id": "dc_01HZR...", "object": "decision_card",
"decision_card": {
"recommendation": "Acme Corp scored 94...",
"confidence": { "score": 0.94, "label": "high" },
"next_action": "Prioritize this account — confidence is high. Schedule outreach within 48 hours."
}
},
{ "id": "dc_01HZS...", "decision_card": { "confidence": { "score": 0.51, "label": "medium" } } },
{ "id": "dc_01HZT...", "decision_card": { "confidence": { "score": 0.78, "label": "high" } } }
],
"audit": { "request_id": "req_batch_001", "tier": "pro" }
}Retrieve Decision Card
/api/v1/explain/:idRetrieve a previously generated decision card by its ID. The record must belong to your account.
curl /api/v1/explain/dc_01HZR7KL9N2MXP4Q \ -H "x-api-key: YOUR_API_KEY"
List Decision Cards
/api/v1/explainPaginated list of decision cards for your account, newest first.
Query params
| Parameter | Type | Description |
|---|---|---|
| limit | integer | Number of results (default 20, max 100). |
| offset | integer | Pagination offset (default 0). |
| since | ISO date | Only return cards created after this timestamp. |
| workflow_type | string | Filter by workflow type. |
| application_id | string | Filter by your app identifier. |
# Get last 20 sales workflow cards curl "/api/v1/explain?workflow_type=sales&limit=20" \ -H "x-api-key: YOUR_API_KEY"
Create Workflow
/api/v1/workflowsSave a named workflow configuration that can be referenced by ID in /explain calls. Useful for standardizing prompt templates, confidence thresholds, and risk definitions across your team.
| Parameter | Type | Description |
|---|---|---|
| namerequired | string | Unique name for this workflow within your account. |
| workflow_type | string | 'sales' | 'support' | 'underwriting' | 'hr' | 'legal' | 'custom'. |
| description | string | Human-readable description. |
| config | object | Arbitrary configuration (e.g. confidence thresholds, prompt templates). |
curl -X POST /api/v1/workflows \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Enterprise Sales Scoring",
"workflow_type": "sales",
"description": "High-touch enterprise account scoring for deals > $50K",
"config": {
"confidence_threshold": 0.75,
"min_evidence_sources": 2,
"escalate_below": 0.45
}
}'List Workflows
/api/v1/workflowsReturns all active workflow templates for your account.
curl /api/v1/workflows -H "x-api-key: YOUR_API_KEY"
Get Workflow
/api/v1/workflows/:idRetrieve a specific workflow template by UUID.
curl /api/v1/workflows/wf_01HZR7... -H "x-api-key: YOUR_API_KEY"
Update Workflow
/api/v1/workflows/:idUpdate any fields on an existing workflow. Only supplied fields are changed.
| Parameter | Type | Description |
|---|---|---|
| name | string | New name (must be unique within your account). |
| description | string | Updated description. |
| config | object | Replace the config object entirely. |
| is_active | boolean | Set to false to deactivate without deleting. |
Delete Workflow
/api/v1/workflows/:idSoft-deletes the workflow (sets is_active: false). Associated decision cards are preserved.
curl -X DELETE /api/v1/workflows/wf_01HZR7... \
-H "x-api-key: YOUR_API_KEY"
# → { "deleted": true, "id": "wf_01HZR7..." }Get Account
/api/v1/meReturns current plan, usage, quota, and subscription details for the API key owner.
curl /api/v1/me -H "x-api-key: YOUR_API_KEY"
{
"user_id": "usr_...",
"tier": "pro",
"subscription_status": "active",
"current_period_end": "2026-06-18T00:00:00.000Z",
"usage": {
"tokens_used_this_month": 1247,
"monthly_quota": 100000,
"remaining": 98753,
"unlimited": false
}
}Analytics Dashboard
/api/v1/analytics/dashboardAggregated usage metrics including interaction counts, feedback breakdown, and a 30-day usage time series.
curl /api/v1/analytics/dashboard -H "x-api-key: YOUR_API_KEY"
{
"user_id": "usr_...",
"metrics": {
"total_interactions": 1247,
"feedback": {
"thumbs_up": 312,
"thumbs_down": 18,
"hallucinations_reported": 3
},
"usage_last_30_days": [
{ "date": "2026-04-19", "total": 42 },
{ "date": "2026-04-20", "total": 67 }
]
}
}Audit Logs
/api/v1/audit/logsPaginated, filterable log of every API call made with your key — endpoint, tokens, status code, IP, tier, and timestamp. SOC 2–ready. Available on Pro and above.
Query params
| Parameter | Type | Description |
|---|---|---|
| limit | integer | Results per page (default 50, max 200). |
| offset | integer | Pagination offset. |
| since | ISO date | Only return logs after this timestamp. |
curl "/api/v1/audit/logs?limit=10&since=2026-05-01T00:00:00Z" \ -H "x-api-key: YOUR_API_KEY"
{
"logs": [
{
"id": "log_...",
"endpoint": "POST /api/v1/explain",
"tokens_used": 1,
"status_code": 200,
"request_id": "req_abc123",
"source_ip": "1.2.3.4",
"tier": "pro",
"created_at": "2026-05-18T21:00:00.000Z"
}
],
"pagination": { "limit": 10, "offset": 0, "total": 1247 }
}Export Audit Log
/api/v1/audit/exportExport your full audit log as CSV or JSON. Maximum 10,000 rows per request. Use since / until to scope the export. The CSV format is SOC 2–compatible.
| Parameter | Type | Description |
|---|---|---|
| since | ISO date | Include only logs after this date. |
| until | ISO date | Include only logs before this date. |
| format | 'csv'|'json' | Output format. Default: 'csv'. |
# Download CSV for a monthly SOC 2 report
curl -X POST /api/v1/audit/export \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "since": "2026-05-01T00:00:00Z", "until": "2026-05-31T23:59:59Z", "format": "csv" }' \
-o northgale-audit-may2026.csvRecord Telemetry
/api/v1/telemetryTrack custom interaction events from your product for analytics dashboards.
| Parameter | Type | Description |
|---|---|---|
| interaction_idrequired | string | Your unique ID for this interaction (for joining with feedback events). |
| event_typerequired | string | Event name, e.g. 'card_viewed', 'card_expanded', 'action_taken'. |
| client_id | string | Your end-user identifier (hashed/opaque is fine). |
| metadata | object | Arbitrary key/value pairs to attach. |
curl -X POST /api/v1/telemetry \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"interaction_id": "int_abc123",
"event_type": "card_expanded",
"client_id": "usr_hashed_456",
"metadata": { "workflow": "sales", "card_id": "dc_01HZR7..." }
}'Submit Feedback
/api/v1/feedbackRecord user feedback on a decision card to improve trust scores and flag hallucinations.
| Parameter | Type | Description |
|---|---|---|
| interaction_idrequired | string | The interaction ID to attach feedback to. |
| ratingrequired | string | 'thumbs_up' | 'thumbs_down' | 'report_hallucination'. |
| client_id | string | Your end-user identifier. |
| report_reason | string | Required when rating is 'report_hallucination'. Description of the issue. |
curl -X POST /api/v1/feedback \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"interaction_id": "int_abc123",
"rating": "thumbs_up",
"client_id": "usr_hashed_456"
}'<ExplainableCard />
The primary React component. Accepts a Northgale Decision Card payload and renders a full explanation UI with confidence ring, evidence trail, risk flags, and action button. Drop it anywhere in your React or Next.js app.
npm install northgale-ui
import { ExplainableCard } from 'northgale-ui';
export default function AIOutput() {
return (
<ExplainableCard
apiKey="ng_live_your_key_here"
llmResponse={{
recommendation: "Acme Corp is high priority.",
confidence: { score: 0.91, label: "high" },
reasoning: "14 email opens + 3 pricing page visits this week.",
evidence_trail: [
{ source: "CRM", text: "Opened 14 emails in 30 days", weight: 0.6 },
{ source: "Intent", text: "Visited pricing page 3x", weight: 0.4 }
],
risk_flags: [],
next_action: "Schedule outreach within 48 hours."
}}
theme="dark"
onFeedback={(fb) => console.log('Feedback:', fb)}
/>
);
}Props
| Parameter | Type | Description |
|---|---|---|
| apiKeyrequired | string | Your Northgale API key for telemetry and feedback calls. |
| llmResponserequired | object | A Decision Card object from POST /explain, or manually constructed. |
| theme | 'dark'|'light' | Force a visual theme. Defaults to system preference. |
| onFeedback | function | Callback fired with { rating, interaction_id } when user gives feedback. |
| className | string | Additional CSS classes for the container. |
| compact | boolean | Render a condensed version without the full evidence trail. |
<ConfidenceBadge />
Standalone confidence indicator — a colored pill badge with auto-thresholding. Use it anywhere you display an AI score.
import { ConfidenceBadge } from 'northgale-ui';
// Auto-colors: green ≥0.75, yellow ≥0.45, red <0.45
<ConfidenceBadge score={0.88} size="sm" showLabel={true} />| Parameter | Type | Description |
|---|---|---|
| scorerequired | number | Float 0.0–1.0. Auto-colors: ≥0.75 green, ≥0.45 yellow, <0.45 red. |
| size | 'sm'|'md'|'lg' | Badge size. Defaults to 'md'. |
| showLabel | boolean | Show the word 'Confidence' alongside the percentage. |
<CitationTooltip />
Wraps inline text with a glowing underline. On hover/tap, shows a tooltip with the exact source chunk the model used — letting non-technical users verify the AI's reasoning without leaving the page.
import { CitationTooltip } from 'northgale-ui';
<p>
The account was flagged because{' '}
<CitationTooltip
sourceText="User opened 14 emails in 30 days, 3x above average"
url="https://crm.example.com/accounts/acme"
>
engagement is unusually high
</CitationTooltip>
{' '}this quarter.
</p>| Parameter | Type | Description |
|---|---|---|
| sourceTextrequired | string | The exact text from the source that the model referenced. |
| url | string | Optional link to the original source record. |
| childrenrequired | ReactNode | The text to underline in the UI. |