SDK ALPHA · TYPES-ONLY
Build on Vaultro
One contract for every Worker: generated TypeScript types, explicit version negotiation and a stable error envelope. Start with the OpenAPI document, keep the types in sync, then call the API.
Quickstart
The SDK is a types-only alpha generated from the same Zod schemas the Workers enforce at runtime. The wire contract is plain HTTPS + JSON, so any language can integrate today.
-
1. Read the contract
Pick a Worker from the index, or download a single document.
curl -s https://docs.vaultro.space/openapi/index.json curl -s https://docs.vaultro.space/openapi/relayer.json -
2. Keep the types in sync
Inside the monorepo,
@vaultro/sdkexposes one namespace per Worker. Regenerate it after any endpoint change.pnpm api:spec && pnpm api:sdk && pnpm sdk:type-checkimport type { relayer, registry } from '@vaultro/sdk'; type SubmitIntent = relayer.operations['relayer-submit-intent']; type SubmitIntentBody = SubmitIntent['requestBody']['content']['application/json']; type SubmitIntentResult = SubmitIntent['responses'][200]['content']['application/json']; type CreateInvoice = registry.operations['registry-create-invoice']; type CreateInvoiceBody = CreateInvoice['requestBody']['content']['application/json']; -
3. Call the API
Public reads need no credentials. Authenticated calls use a service API key or a device signature, and every response advertises the negotiated contract version.
const response = await fetch('https://relayer.vaultro.space/api/status/0x...', { headers: { 'X-Vaultro-Api-Version': '1' }, }); if (!response.ok) { const error = await response.json(); // { error, code, correlationId, issues? } throw new Error(`${response.status} ${error.code ?? error.error}`); } const status = await response.json();
Authentication
Pick the credential that matches the caller. Never ship a service key in a client.
| Caller | Credential | Use it for |
|---|---|---|
| Anyone | — |
/health, /ready, public status, prices and OpenAPI documents. |
| Server / integrator | X-Vaultro-Api-Key |
Service-to-service calls. Keep the key server-side and rotate it on a schedule. |
| Vaultro app | X-Vaultro-Device-* |
P-256 proof-of-possession bound to the request, device and timestamp. |
| Admin | Password + TOTP cookie | Internal admin routes only; sessions are HttpOnly, Secure and SameSite=Strict. |
Errors
Every Worker returns the same JSON envelope. Validation failures add an issues array with the
field path and a stable message code.
{
"success": false,
"error": "Invalid request body",
"code": "INVALID_BODY",
"correlationId": "5f0c...",
"issues": [{ "path": "chainId", "message": "invalid_chain_id" }]
}
| Status | Meaning | What to do |
|---|---|---|
400 | Invalid body, query or API version. | Read code/issues; do not retry unchanged. |
401 | Missing or invalid credential. | Refresh the device signature or check the service key. |
403 | Authenticated but not allowed. | Check the route scope or merchant ownership. |
404 | Unknown resource. | Verify the address, invoice or intent hash. |
409 | State conflict (replay, reorg, duplicate invoice payment). | Re-read the resource; do not re-broadcast blindly. |
410 | Endpoint removed. | Move to the replacement from the deprecation notice. |
413 | Payload above the Worker limit. | Split the request or reduce the batch. |
429 | Rate limit exceeded. | Honor Retry-After and back off with jitter. |
500 | Internal error (sanitized). | Retry idempotent calls; include correlationId in support. |
503 | Dependency unavailable. | Check /ready; retry later. |
Idempotency & retries
Mutating relayer and registry calls accept Idempotency-Key. Reuse the same random key when
retrying after a timeout or a 5xx: the API replays the stored response instead of running the
operation twice.
POST /invoice
Idempotency-Key: 8f14e45f-ceea-467f-a8f7-7f2b2a8a1d11
# first call: 200 {"invoiceId":"..."}
# retry with the same key and body:
# 200 + Idempotency-Replayed: true (same body)
Same key with a different body returns 409 IDEMPOTENCY_KEY_REUSED. The same key while the
first call is still running returns 409 IDEMPOTENCY_IN_PROGRESS with Retry-After: 1.
Keys live for 24 hours; use a new key for a genuinely new operation.
Rate limits
Limits are enforced per identity and route using a Durable Object, with 429,
Retry-After and RateLimit-* headers. Values below are the documented defaults;
a specific route or plan may be stricter.
| Worker | Default | Scope |
|---|---|---|
history | 60 / min | POST /sync |
price, registry, download, status | 120 / min | Public routes |
token, aggregator, rpc | Per route | Batch and proxy routes |
relayer | Per identity | /api/*, weighted by route cost |
Batch endpoints cap the number of items (price: 200, token: 500, RPC: 50 envelopes). Split larger work
instead of retrying a 400.
Versioning & deprecation
The major version travels in X-Vaultro-Api-Version. Omit it for the current stable version;
every response echoes the negotiated value and adds Vary.
# current stable (v1)
curl -s -H 'X-Vaultro-Api-Version: 1' https://relayer.vaultro.space/health
# unsupported major: 400 UNSUPPORTED_API_VERSION
curl -s -H 'X-Vaultro-Api-Version: 2' https://relayer.vaultro.space/health
Breaking changes require a new major version. Deprecated routes send Deprecation (RFC 9745),
Sunset (RFC 8594), a migration Link and
X-Vaultro-Deprecation-Notice. The minimum window is 90 days for public routes and 30 days for
internal ones.