JavaScript SDK
The JavaScript and TypeScript SDK is the official client of the API. It validates SPEI transfers against the Banxico CEP, downloads the receipt and verifies webhook signatures. It has no runtime dependencies, its types are generated from the OpenAPI specification and it runs on Node 18 or later, in ESM and CommonJS.
Installation
npm install @veriko-mx/sdkCreate your API key in the Veriko console and store it in the VERIKO_API_KEY environment variable. The client reads it on its own.
export VERIKO_API_KEY=veriko_your_keyValidate a transfer
import { Veriko } from '@veriko-mx/sdk';
const client = new Veriko();
const validation = await client.validateTransfer({
sendDate: '2025-03-15',
amount: 15000.5,
trackingKey: 'MXBA20250315001234',
beneficiaryAccount: '012180004412345678',
});
console.log(validation.attributes.status); // 'valid'The amount is in pesos, with cents. Besides the amount and the beneficiary account, the tracking key or the numeric reference is required. If you omit the date, the API tries candidate dates against Banxico. For the full flow, see Validate a SPEI transfer.
Verify a webhook
Each delivery arrives signed with HMAC-SHA256 in the X-Webhook-Signature header. The body is signed exactly as it arrived, so in Express the route uses express.raw() and not express.json().
import express from 'express';
import { SignatureVerificationError, isKnownWebhookEvent, parseWebhook } from '@veriko-mx/sdk';
const app = express();
const SECRET = process.env.VERIKO_WEBHOOK_SIGNING_KEY;
app.post('/hooks/validations', express.raw({ type: 'application/json' }), (request, response) => {
let event;
try {
event = parseWebhook(request.body, request.headers, SECRET);
} catch (error) {
if (error instanceof SignatureVerificationError) return response.sendStatus(400);
throw error;
}
response.sendStatus(200); // answer 2xx first, process afterwards
if (isKnownWebhookEvent(event) && event.event === 'validation.completed') {
console.log(event.data.id, event.data.attributes.status);
}
});With the request headers, parseWebhook() verifies the timestamped signature inside a time window, which also protects against replays. More about the delivery model in Webhooks architecture.
What it includes
The client groups the 75 M2M operations of the API into eleven families. The three most used are also at the root: validateTransfer(), getValidation() and getCep().
| Family | What it covers |
|---|---|
client.validations | Validate by fields or by image, read, list, export, check the payment, delete, the retry policy and the CEP download |
client.webhooks | Register endpoints, rotate their secret, send a test event and read the delivery history |
client.catalog | SPEI bank catalog, non-business-day calendar, issuing bank of a card and Banxico status |
client.beneficiaries | Saved beneficiary accounts and the bulk import |
client.usage | Validation quota, rate limits and the activity log |
client.account | Profile and default retry policy of the account |
client.dashboard | Dashboard summary |
client.plans | Catalog and comparison of public plans, with no API key |
client.insights | Summary, trends, top banks and top beneficiaries |
client.finance | Summaries, statements, downloads and CEP exports |
client.billing | Active subscription |
The SDK also retries transient failures (5xx, 408 and 429) honoring Retry-After, sends an Idempotency-Key on the operations that accept one and throws typed errors that carry code, the stable contract. See Idempotency, Retry policy and Errors.
While the version is 0.x, a minor version can adjust the public surface of the SDK.
Repository
The code, the changelog and the contribution guide are in the JavaScript SDK repository.