DecisioQ System Architecture Decision Concepts Decision List API Guide Developer Center Decision Studio Quick Start Playground End-to-End Examples

AUTO-TOW-047 End-to-End Example

Prioritize Invoice Review using Identity, the secured Knowledge Catalog, DKS token propagation, and Prepared Decision Input execution.

Automotive Auto Towing Billing & Collections TOPSIS
IdentityIssue bearer token
CatalogDiscover decision metadata
ProfileSelect weights and scenario
ExecuteRun deterministic ranking
ExplainReview result context

Overview

AUTO-TOW-047, Prioritize Invoice Review, ranks towing invoices for review, correction, or approval by invoice amount, billing discrepancy severity, payer priority, invoice age, documentation gaps, and collection risk.

Decision ID
AUTO-TOW-047
Decision Name
Prioritize Invoice Review
Industry Profile
auto-towing-prioritize-invoice-review-auto-tow-047 version 1.0.0
Default Profile
balanced
Default Scenario
standard
Catalog
DKR-AUTO-RUNTIME-001, active DKS runtime catalog
The deterministic Decision Engine ranks the options. AI explanation text, when returned, is explanatory only and must not choose, rerank, or override the deterministic result.

Understanding This Decision

Prioritize Invoice Review helps a towing operation decide which invoices should be reviewed first when billing teams need to resolve discrepancies, approve clean invoices, or intervene before collection risk grows.

Business question

Which invoice review should be recommended for the selected Auto Towing billing context?

Expected outcome

A recommended invoice review or ranked set of invoice reviews with the criteria that most influenced the result.

Typical users

Billing managers, collections teams, towing dispatch administrators, insurer-account coordinators, and integrators building billing review workflows.

Decision boundary

Use this decision to rank supplied invoice review candidates. It does not replace contractual, insurance, tax, or legal billing review.

Architecture

  1. Request a token from the Identity service.
  2. Use the returned jwtToken as the bearer token.
  3. Load the catalog and decision detail from DKS.
  4. Build a Prepared Decision Input using canonical criterion IDs.
  5. Execute the decision through DDE.
  6. Use X-Request-Id and X-Correlation-Id for tracing across DDE and DKS.
Token propagation: when DDE needs authoritative decision metadata during execution, it forwards the caller's bearer token to DKS with the request identifiers. This lets the catalog and execution records share the same security and tracing context.

Authentication

Request a secure session token from Identity. The current token response field is jwtToken.

Token request
POST https://identity.vinquery.com/connect/token
Content-Type: application/json

{
  "clientId": "{clientId}",
  "clientSecret": "{clientSecret}",
  "audience": "vinquery:api:decisioq"
}

Catalog Discovery

Use DKS to discover the catalog and then load complete metadata for AUTO-TOW-047.

Catalog
GET https://dks.vinquery.com/decisioncatalog
Authorization: Bearer {jwtToken}
Decision Detail
GET https://dks.vinquery.com/decisioncatalog/decisions/AUTO-TOW-047
Authorization: Bearer {jwtToken}

Criteria

Criterion IDs are intentionally stable machine identifiers. Display labels are for users; request values should be keyed by canonical criterionId.

Criterion IDNameDirectionWeightValidation
invoice_amountInvoice Amountmaximize20non_negative_currency
billing_discrepancy_scoreBilling Discrepancy Scoremaximize25score_0_to_100
payer_priority_scorePayer Priority Scoremaximize15score_0_to_100
aging_daysAging Daysminimize15non_negative_integer
documentation_gap_scoreDocumentation Gap Scoreminimize15score_0_to_100
collection_risk_scoreCollection Risk Scoreminimize10score_0_to_100

Constraint Processing

This decision includes a catalog-defined hard constraint. DKS returns the constraint with the decision detail, and DDE evaluates it before criteria-based ranking.

Verified Catalog ConstraintStatusEffect
AUTO-TOW-047-AGING-DAYS-MAX-3Hard, enabled, mandatoryRequires aging_days <= 3 before a candidate can participate in routine ranking.
Eligible and Excluded Candidates
{
  "constraintSummary": {
    "definedConstraintCount": 1,
    "activeConstraintCount": 1,
    "eligibleOptionCount": 2,
    "excludedOptionCount": 1,
    "eligibleOptions": [
      "option-1",
      "option-2"
    ],
    "excludedOptions": [
      {
        "optionId": "option-3",
        "reasons": [
          "Aging days exceeds the standard review window of 3 days."
        ]
      }
    ]
  }
}
Constraint Handling Pattern
const constraints = decisionDetail.constraints || [];
if (constraints.length > 0) {
  // DDE applies catalog constraints before ranking.
  // Excluded candidates appear in response.constraintSummary.excludedOptions.
}

const summary = response.constraintSummary;
const excluded = response.decisionResult?.excludedOptions || [];

Excluded candidates do not participate in ranking because hard constraints are evaluated before scoring. For AUTO-TOW-047, option-3 is excluded from the showcase sample because its invoice age is outside the standard review window.

Industry Profile

The active industry profile uses $.towRequests as the options path, $.optionId as the option ID, and $.name as the option display name.

Business Data PathCriterion ID
option.financial.invoiceAmountinvoice_amount
option.assessment.billingDiscrepancyScorebilling_discrepancy_score
option.assessment.payerPriorityScorepayer_priority_score
option.billing.and.collections.agingDaysaging_days
option.assessment.documentationGapScoredocumentation_gap_score
option.risk.collectionRiskScorecollection_risk_score
Business Data Fragment
{
  "towRequests": [
    {
      "optionId": "option-1",
      "name": "High-Value Insurance Invoice",
      "financial": {
        "invoiceAmount": 125
      },
      "assessment": {
        "billingDiscrepancyScore": 88,
        "payerPriorityScore": 88,
        "documentationGapScore": 88
      },
      "billing": {
        "and": {
          "collections": {
            "agingDays": 1
          }
        }
      },
      "risk": {
        "collectionRiskScore": 88
      }
    }
  ]
}
Prepared Option Values
{
  "optionId": "option-1",
  "name": "High-Value Insurance Invoice",
  "values": {
    "invoice_amount": 125,
    "billing_discrepancy_score": 88,
    "payer_priority_score": 88,
    "aging_days": 1,
    "documentation_gap_score": 88,
    "collection_risk_score": 88
  }
}

Profiles and Scenarios

A profile changes criterion weights. A scenario describes the operating context for the execution. The active DKS catalog exposes these choices with the decision detail response.

Profile IDNamePurpose
balancedBalancedPreserves the default DKS criterion weights.
customer_focusedCustomer FocusedPlaces stronger emphasis on customer priority, satisfaction, communication urgency, and service experience.
cost_controlCost ControlPlaces stronger emphasis on fees, collection risk, waiver exposure, and financial discipline.
compliance_focusedCompliance FocusedPlaces stronger emphasis on policy, documentation, authorization, insurance, and auditability.
Scenario IDNameUse When
standardStandard Operating ScenarioNormal towing customer and billing operating context.
urgent_customerUrgent Customer ScenarioCustomer urgency, stranded motorists, or service recovery require stronger emphasis.
cost_controlCost Control ScenarioFee recovery, margin protection, or collection risk must be controlled.
compliance_reviewCompliance Review ScenarioAuthorization, policy, documentation, or insurance rules require stronger control.

Prepared Input

For Prepared Decision Input, send decisionId, selected profile/scenario IDs, and option values keyed by canonical criterion ID. The showcase request includes two eligible invoice reviews and one excluded invoice so constraint handling is visible.

Prepared Decision Input JSON
{
  "decisionId": "AUTO-TOW-047",
  "mappingProfileId": "auto-towing-prioritize-invoice-review-auto-tow-047",
  "mappingProfileVersion": "1.0.0",
  "profileId": "balanced",
  "scenarioId": "standard",
  "algorithm": "TOPSIS",
  "weightStrategy": "Manual",
  "runSensitivity": false,
  "requestContext": {
    "correlationId": "auto-tow-047-demo-001"
  },
  "options": [
    {
      "optionId": "option-1",
      "name": "High-Value Insurance Invoice",
      "values": {
        "invoice_amount": 125,
        "billing_discrepancy_score": 88,
        "payer_priority_score": 88,
        "aging_days": 1,
        "documentation_gap_score": 88,
        "collection_risk_score": 88
      }
    },
    {
      "optionId": "option-2",
      "name": "Disputed Commercial Invoice",
      "values": {
        "invoice_amount": 250,
        "billing_discrepancy_score": 81,
        "payer_priority_score": 81,
        "aging_days": 2,
        "documentation_gap_score": 81,
        "collection_risk_score": 81
      }
    },
    {
      "optionId": "option-3",
      "name": "Aged Storage Invoice",
      "values": {
        "invoice_amount": 500,
        "billing_discrepancy_score": 74,
        "payer_priority_score": 74,
        "aging_days": 4,
        "documentation_gap_score": 74,
        "collection_risk_score": 74
      }
    }
  ]
}

Execute

cURL
curl -X POST "https://dde.vinquery.com/api/v1/decide" \
  -H "Authorization: Bearer ${DECISIOQ_TOKEN}" \
  -H "Content-Type: application/json" \
  -H "X-Correlation-Id: auto-tow-047-demo-001" \
  --data @auto-tow-047-execute.json

DDE retrieves authoritative criteria, constraints, and validation metadata from DKS, executes the deterministic ranking, and returns the decision result plus execution metadata.

Interpret the Result

The successful response is centered on decisionResult. The winner and ranking are deterministic outputs; optional explanation fields add context but do not change the ranking.

Successful Response Shape
{
  "success": true,
  "decisionType": "AUTO-TOW-047",
  "decisionResult": {
    "winner": "option-1",
    "ranking": [
      {
        "optionId": "option-1",
        "name": "High-Value Insurance Invoice",
        "score": 0.91
      },
      {
        "optionId": "option-2",
        "name": "Disputed Commercial Invoice",
        "score": 0.84
      }
    ],
    "excludedOptions": [
      {
        "optionId": "option-3",
        "reasons": [
          "Aging days exceeds the standard review window of 3 days."
        ]
      }
    ]
  },
  "constraintSummary": {
    "definedConstraintCount": 1,
    "activeConstraintCount": 1,
    "eligibleOptionCount": 2,
    "excludedOptionCount": 1
  },
  "requestContext": {
    "correlationId": "auto-tow-047-demo-001"
  }
}
WinnerThe selected option ID in decisionResult.winner.
RankingAll eligible options ordered by score.
Constraint SummaryEligible and excluded candidates with reasons.

Sensitivity Analysis

Set runSensitivity to true on catalog execution when the client wants recommendation-stability information in the same response. The sensitivity engine perturbs criterion weights by controlled factors and reports whether the winner remains stable.

Sensitivity Result Shape
{
  "sensitivityResult": {
    "stableWinner": true,
    "winner": "option-1",
    "mostSensitiveCriterion": "invoice_amount",
    "confidence": 95,
    "criterionImpacts": {
      "invoice_amount": 0.1842
    },
    "winnerChangeCounts": {
      "invoice_amount": 0
    }
  }
}

Use sensitivity output to decide whether a recommendation is robust enough for automation or should be reviewed by a person.

Explanation of Decision Result

Every successful response can include deterministic explanation text under decisionResult.explanation and explanation. If the optional AI layer is enabled, the response may also include an ai block with structured business-language explanation fields.

AI Explanation Shape
{
  "ai": {
    "enabled": true,
    "generated": true,
    "schemaValidated": true,
    "explanation": {
      "summary": "The selected invoice review provided the strongest billing review priority.",
      "whyRecommended": "It combined invoice value, billing discrepancy severity, payer priority, and acceptable invoice age.",
      "keyDrivers": [],
      "tradeoffs": [],
      "competitors": [],
      "sensitivitySummary": "Sensitivity analysis was not included in this response.",
      "scenarioSummary": "The standard scenario was selected.",
      "risks": [],
      "nextSteps": [],
      "assumptions": []
    }
  }
}
Explanation output is supporting context. Business-facing pages should render the explanation, warnings, assumptions, and limitations without provider branding.

Tracing and Logs

Use request identifiers to connect client, catalog, and execution activity during support or integration testing.

X-Request-Id
Optional client-supplied request ID. If omitted, the server generates one.
X-Correlation-Id
Optional client correlation value propagated from DDE to DKS.
requestContext.correlationId
Optional payload value echoed in the response and used for tracing.
executionTrace
Advanced execution metadata including selected profile, selected scenario, effective weights, and applied constraints.

Code Examples

These examples demonstrate the current DecisioQ flow:

  1. Request jwtToken from https://identity.vinquery.com/connect/token.
  2. Load AUTO-TOW-047 metadata from https://dks.vinquery.com/decisioncatalog/decisions/AUTO-TOW-047.
  3. Execute a Prepared Decision Input at https://dde.vinquery.com/api/v1/decide.

Set these environment variables before running any companion example:

Environment variables
DECISIOQ_CLIENT_ID
DECISIOQ_CLIENT_SECRET
DECISIOQ_AUDIENCE=vinquery:api:decisioq

Optional:
DECISIOQ_IDENTITY_URL=https://identity.vinquery.com/connect/token
DECISIOQ_DKS_URL=https://dks.vinquery.com
DECISIOQ_DDE_URL=https://dde.vinquery.com

Download the source files directly:

Troubleshooting

SymptomLikely CauseWhat to Check
401 UnauthorizedMissing, expired, or invalid bearer token.Request a fresh jwtToken from Identity and send it as Authorization: Bearer ....
Decision not foundThe decision ID is not in the active catalog.Load /decisioncatalog/decisions/AUTO-TOW-047 and confirm the ID is published.
Validation failedA required criterion value is missing or outside its rule.Use canonical criterion IDs and keep score values in the expected range.
Candidate excludedThe candidate violates a hard catalog constraint.Review constraintSummary.excludedOptions; for AUTO-TOW-047, aging days must be no greater than 3.
HTML error responseAn upstream hosted service failed before returning JSON.Check service health and server logs for Identity, DKS, or DDE.

Production Checklist

Security

Keep API Consumer credentials and jwtTokens on the server side. Use HTTPS, short-lived bearer tokens, and an API Consumer linked to a DecisioQ account for usage accounting.

Catalog

Load decision metadata from DKS and cache cautiously. Refresh when catalog versions change.

Request Quality

Use canonical criterion IDs, validate value ranges, and send at least two candidate options.

Operations

Send correlation IDs, record request IDs, and monitor non-JSON upstream failures.

Explanation

Display explanation text as supporting context only. Never let AI text override deterministic results.

User Experience

Show business labels to users and keep raw execution trace collapsed for advanced diagnostics.