Guides

End-to-end examples

Three copy-paste flows that string the API together end to end — mint a token, take an application, read the decision, and pull public product data with no token at all. Every call targets Production; swap the base URL for sandbox to dry-run.

These examples reuse the same authentication and conventions described on the API reference overview. For the full token lifecycle see OAuth 2.0; for retries see Idempotency.

1 — Mint a token, create an application, read the decision

The core partner flow. Exchange your client credentials for a short-lived access token, create a business-loan application, then read the AI-led decision. Always set an Idempotency-Key on the write.

bash
# 1. Mint an access token (client-credentials)
TOKEN=$(curl -s https://sso.credicorp.co.uk/oauth2/token \
  -d grant_type=client_credentials \
  -d client_id=$CC_CLIENT_ID -d client_secret=$CC_CLIENT_SECRET \
  -d scope="apply:write decision:read" | jq -r .access_token)

# 2. Create an application (amounts are integer pence)
APP=$(curl -s https://api.credicorp.co.uk/partner/v1/applications \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"company_number":"16093826","amount_pence":30000,"term_days":56}')
APP_ID=$(echo "$APP" | jq -r .id)

# 3. Read the decision for that application
curl -s https://api.credicorp.co.uk/partner/v1/decisions?application=$APP_ID \
  -H "Authorization: Bearer $TOKEN"
javascript
import { Credicorp } from '@credicorp/sdk';
import { randomUUID } from 'node:crypto';

const cc = new Credicorp({
  clientId: process.env.CC_CLIENT_ID,
  clientSecret: process.env.CC_CLIENT_SECRET,
  environment: 'live', // or 'sandbox'
});

// Create an application — the SDK mints + refreshes the token for you
const app = await cc.applications.create(
  { company_number: '16093826', amount_pence: 30000, term_days: 56 },
  { idempotencyKey: randomUUID() }
);

const decision = await cc.decisions.retrieve({ application: app.id });
console.log(decision.outcome, decision.reason_codes);

2 — Public product & pricing data (no token)

The public/v1 ring is unauthenticated. Pull the product catalogue and figures, or the loyalty ladder, straight from the hub — ideal for a comparison page or an assistant.

bash
# Product catalogue + live figures
curl -s https://hub.credicorp.co.uk/public/v1/products | jq '.products.business_loan.figures'

# Loyalty tiers and their arrangement-fee discounts
curl -s https://hub.credicorp.co.uk/public/v1/loyalty/tiers | jq '.tiers[] | {slug, discount: .benefits.arrangement_fee_discount_pct}'

3 — A live quote via the MCP tool

Ask the MCP server for a representative Business Loan quote over JSON-RPC. No auth; the result is in pence.

bash
curl -s https://hub.credicorp.co.uk/public/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call",
       "params":{"name":"get_quote",
                 "arguments":{"amount":300,"term":56,"frequency":"weekly"}}}' \
  | jq '.result.structuredContent | {total_repayable, periods, payment_each}'

Chain the public and partner rings: quote publicly with MCP or public/v1 to show a price, then, once the borrower is ready, take the real application through partner/v1 (example 1) for a binding decision.

Where to go next