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.

bash
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

bash
npm install @northgale/sdk

2. Wrap your first AI output

typescript
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:

json
{
  "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

ParameterTypeDescription
400Bad RequestMissing or invalid request parameters. Check the error field for details.
401UnauthorizedMissing or invalid x-api-key header.
402Payment RequiredSubscription is canceled or past due. Update payment method in the dashboard.
403ForbiddenYour plan does not include this feature. Upgrade to access it.
404Not FoundResource not found or belongs to a different account.
409ConflictDuplicate resource (e.g. workflow name already exists).
429Too Many RequestsMonthly quota exceeded. Remaining calls shown in X-RateLimit-Remaining header.
500Server ErrorInternal error. Retry with exponential backoff.

Rate limit headers are included on every response:

http
X-RateLimit-Tier: pro
X-RateLimit-Limit: 100000
X-RateLimit-Remaining: 98732
POST

Explain

/api/v1/explain

The 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

ParameterTypeDescription
input_textrequiredstringThe raw AI output to explain. Required. Must be non-empty.
confidencenumberConfidence score (0–1). If omitted, Northgale infers from the text.
reasoningstringWhy the model reached this conclusion. If omitted, extracted from input_text.
evidencearrayArray of {source, text, weight?} objects — sources the model referenced.
risk_factorsarrayArray of {severity: 'high'|'medium'|'low', description} risk conditions.
next_actionstringRecommended human action. Auto-derived from workflow_type + confidence if omitted.
workflow_typestring'sales' | 'support' | 'underwriting' | 'hr' | 'legal' | 'custom'. Drives next_action defaults.
application_idstringYour app's identifier — used for filtering in /explain list and audit exports.
input_modelstringThe model that generated the output, e.g. 'gpt-4o', 'claude-3-5-sonnet'.
input_contextobjectArbitrary key/value context to store alongside the decision card.
workflow_idstringUUID of a saved workflow template to associate with this call.
metadataobjectAdditional key/value pairs to attach to the record.

Example

bash
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

json
{
  "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" }
}
POST

Explain Batch

/api/v1/explain/batch

Explain 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

ParameterTypeDescription
itemsrequiredarrayArray of explain request objects (same fields as POST /explain). Max 10.
workflow_typestringDefault workflow_type applied to all items unless overridden per-item.
application_idstringDefault application_id applied to all items.
input_modelstringDefault input_model applied to all items.
bash
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 }
    ]
  }'
json
{
  "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" }
}
GET

Retrieve Decision Card

/api/v1/explain/:id

Retrieve a previously generated decision card by its ID. The record must belong to your account.

bash
curl /api/v1/explain/dc_01HZR7KL9N2MXP4Q \
  -H "x-api-key: YOUR_API_KEY"
GET

List Decision Cards

/api/v1/explain

Paginated list of decision cards for your account, newest first.

Query params

ParameterTypeDescription
limitintegerNumber of results (default 20, max 100).
offsetintegerPagination offset (default 0).
sinceISO dateOnly return cards created after this timestamp.
workflow_typestringFilter by workflow type.
application_idstringFilter by your app identifier.
bash
# Get last 20 sales workflow cards
curl "/api/v1/explain?workflow_type=sales&limit=20" \
  -H "x-api-key: YOUR_API_KEY"
POST

Create Workflow

/api/v1/workflows

Save 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.

ParameterTypeDescription
namerequiredstringUnique name for this workflow within your account.
workflow_typestring'sales' | 'support' | 'underwriting' | 'hr' | 'legal' | 'custom'.
descriptionstringHuman-readable description.
configobjectArbitrary configuration (e.g. confidence thresholds, prompt templates).
bash
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
    }
  }'
GET

List Workflows

/api/v1/workflows

Returns all active workflow templates for your account.

bash
curl /api/v1/workflows -H "x-api-key: YOUR_API_KEY"
GET

Get Workflow

/api/v1/workflows/:id

Retrieve a specific workflow template by UUID.

bash
curl /api/v1/workflows/wf_01HZR7... -H "x-api-key: YOUR_API_KEY"
PATCH

Update Workflow

/api/v1/workflows/:id

Update any fields on an existing workflow. Only supplied fields are changed.

ParameterTypeDescription
namestringNew name (must be unique within your account).
descriptionstringUpdated description.
configobjectReplace the config object entirely.
is_activebooleanSet to false to deactivate without deleting.
DELETE

Delete Workflow

/api/v1/workflows/:id

Soft-deletes the workflow (sets is_active: false). Associated decision cards are preserved.

bash
curl -X DELETE /api/v1/workflows/wf_01HZR7... \
  -H "x-api-key: YOUR_API_KEY"
# → { "deleted": true, "id": "wf_01HZR7..." }
GET

Get Account

/api/v1/me

Returns current plan, usage, quota, and subscription details for the API key owner.

bash
curl /api/v1/me -H "x-api-key: YOUR_API_KEY"
json
{
  "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
  }
}
GET

Analytics Dashboard

/api/v1/analytics/dashboard

Aggregated usage metrics including interaction counts, feedback breakdown, and a 30-day usage time series.

bash
curl /api/v1/analytics/dashboard -H "x-api-key: YOUR_API_KEY"
json
{
  "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 }
    ]
  }
}
GETpro+

Audit Logs

/api/v1/audit/logs

Paginated, 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

ParameterTypeDescription
limitintegerResults per page (default 50, max 200).
offsetintegerPagination offset.
sinceISO dateOnly return logs after this timestamp.
bash
curl "/api/v1/audit/logs?limit=10&since=2026-05-01T00:00:00Z" \
  -H "x-api-key: YOUR_API_KEY"
json
{
  "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 }
}
POSTpro+

Export Audit Log

/api/v1/audit/export

Export 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.

ParameterTypeDescription
sinceISO dateInclude only logs after this date.
untilISO dateInclude only logs before this date.
format'csv'|'json'Output format. Default: 'csv'.
bash
# 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.csv
POST

Record Telemetry

/api/v1/telemetry

Track custom interaction events from your product for analytics dashboards.

ParameterTypeDescription
interaction_idrequiredstringYour unique ID for this interaction (for joining with feedback events).
event_typerequiredstringEvent name, e.g. 'card_viewed', 'card_expanded', 'action_taken'.
client_idstringYour end-user identifier (hashed/opaque is fine).
metadataobjectArbitrary key/value pairs to attach.
bash
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..." }
  }'
POST

Submit Feedback

/api/v1/feedback

Record user feedback on a decision card to improve trust scores and flag hallucinations.

ParameterTypeDescription
interaction_idrequiredstringThe interaction ID to attach feedback to.
ratingrequiredstring'thumbs_up' | 'thumbs_down' | 'report_hallucination'.
client_idstringYour end-user identifier.
report_reasonstringRequired when rating is 'report_hallucination'. Description of the issue.
bash
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.

bash
npm install northgale-ui
tsx
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

ParameterTypeDescription
apiKeyrequiredstringYour Northgale API key for telemetry and feedback calls.
llmResponserequiredobjectA Decision Card object from POST /explain, or manually constructed.
theme'dark'|'light'Force a visual theme. Defaults to system preference.
onFeedbackfunctionCallback fired with { rating, interaction_id } when user gives feedback.
classNamestringAdditional CSS classes for the container.
compactbooleanRender 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.

tsx
import { ConfidenceBadge } from 'northgale-ui';

// Auto-colors: green ≥0.75, yellow ≥0.45, red <0.45
<ConfidenceBadge score={0.88} size="sm" showLabel={true} />
ParameterTypeDescription
scorerequirednumberFloat 0.0–1.0. Auto-colors: ≥0.75 green, ≥0.45 yellow, <0.45 red.
size'sm'|'md'|'lg'Badge size. Defaults to 'md'.
showLabelbooleanShow 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.

tsx
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>
ParameterTypeDescription
sourceTextrequiredstringThe exact text from the source that the model referenced.
urlstringOptional link to the original source record.
childrenrequiredReactNodeThe text to underline in the UI.