Loading...
Loading...
Integration guide for the Bloque SDK — a TypeScript SDK for programmable financial accounts, cards with spending controls, and multi-asset transfers. Use when the user asks to "integrate Bloque", "create a card", "set up spending controls", "handle card webhooks", "transfer funds", "create pockets", "set up MCC routing", or build any fintech feature on the Bloque platform.
npx skill4agent add bloque-app/skills bloque-sdk-ts@bloque/sdk → Main package (aggregates everything)
@bloque/sdk-core → HttpClient, errors, types
@bloque/sdk-accounts → Accounts, cards, transfers
@bloque/sdk-identity → User identities and aliases
@bloque/sdk-compliance → KYC/KYB verification
@bloque/sdk-orgs → Organizations
@bloque/sdk-swap → Currency swap and bank transfersDUSD/6COPB/6COPM/2KSM/12"10000000"import { SDK } from '@bloque/sdk';
const bloque = new SDK({
origin: process.env.ORIGIN,
auth: { type: 'apiKey', apiKey: process.env.API_KEY },
mode: 'sandbox',
});
// Register a new user
await bloque.register('@alice', {
type: 'individual',
profile: { firstName: 'Alice', lastName: 'Smith', email: 'alice@example.com',
phone: '+1234567890', birthdate: '1990-01-01', city: 'Miami', state: 'FL',
postalCode: '33101', countryOfBirthCode: 'US', countryOfResidenceCode: 'US' },
});
// Connect to an existing user
const user = await bloque.connect('@alice');
// Create a pocket and a card
const pocket = await user.accounts.virtual.create({}, { waitLedger: true });
const card = await user.accounts.card.create(
{ ledgerId: pocket.ledgerId, name: 'My Card' },
{ waitLedger: true },
);| File | When to read |
|---|---|
| Read first for any integration. All methods, params, and exact return types. |
| First-time setup, configuration, auth strategies |
| Creating pockets, Polygon wallets, bank accounts |
| Card creation, default/smart spending, MCC routing |
| Handling transaction events, webhook payloads |
| Moving funds, batch transfers, movement metadata |
ledgerId"default""smart"webhookUrlSYMBOL/DECIMALS10 DUSD = "10000000"register()connect()'@alice''@alice''alice''@Alice'BloqueNotFoundError// Register
await bloque.register('@alice', { type: 'individual', profile: { ... } });
// Connect — MUST use the exact same alias
const user = await bloque.connect('@alice'); // ✅ correct
const user = await bloque.connect('alice'); // ❌ BloqueNotFoundError
const user = await bloque.connect('@Alice'); // ❌ BloqueNotFoundErrorconnect()connect()register()user.accounts.card.create()connect()// ❌ Wrong — no way to know if '@bob' was ever registered
const user = await bloque.connect('@bob'); // Returns session (no error!)
const card = await user.accounts.card.create(); // 💥 Fails here — identity not found
// ✅ Correct — track registration state in your app
const isRegistered = await db.users.exists('@bob');
if (!isRegistered) {
await bloque.register('@bob', { type: 'individual', profile: { ... } });
await db.users.markRegistered('@bob');
}
const user = await bloque.connect('@bob');connect()register()BloqueAPIErrorrequestIdtimestamptoJSON()| Error Class | HTTP | When |
|---|---|---|
| 400 | Invalid params |
| 401/403 | Bad API key or JWT |
| 404 | Resource missing |
| 429 | Too many requests |
| — | Not enough balance |
| — | Connection failed |
| — | Request timed out |
import { BloqueInsufficientFundsError } from '@bloque/sdk-core';
try {
await user.accounts.transfer({ sourceUrn, destinationUrn, amount, asset });
} catch (err) {
if (err instanceof BloqueInsufficientFundsError) {
console.log('Not enough funds:', err.toJSON());
}
}