Skip to content

Signed API delivery ​

Send JSON batches from your server using the provider HMAC signing key supplied by your operator. This machine flow does not require a portal login. Use the agreed API origin and the request/response contract.

Sign the exact request ​

HeaderMeaning
Racun-Key-IdIssued signing key ID
Racun-IssuerProvider code owning that key
Racun-TimestampUnix seconds, within the server clock tolerance defined in the contract
Racun-Request-IdRequest UUID for correlation, not replay protection
Idempotency-KeyPOST delivery only: identifies the delivery within this provider
Racun-SignatureHMAC-SHA256, strict base64url without padding

The generated contract defines the signing header syntax, lengths and clock tolerance. Each signing header appears once, with visible ASCII and no spaces/control characters. Decode the issued base64url secret into bytes before HMAC. Join the following nine UTF-8 lines with LF and no final newline:

text
RACUN-HMAC-SHA256
<uppercase HTTP method>
<escaped path exactly as sent>
<lowercase Host authority, including its port>
<Racun-Issuer>
<Racun-Timestamp>
<Racun-Request-Id>
<Idempotency-Key, empty for GET/PUT>
<lowercase hexadecimal SHA-256 of exact body bytes>

Compute base64url(HMAC-SHA256(secret_bytes, signed_text)), without padding. For GET, the body is empty. Neither status GET nor PDF PUT permits an Idempotency-Key header, even an empty one. Provider routes accept no query, including a bare ?. Sign the actual Host, not a forwarded value. Do not reserialize JSON, follow redirects, change escaping, compress the body or append a newline after signing. This custom profile is not RFC 9421.

Download the Node signing example. It returns headers for an already chosen exact target/body; it does not provision a key, send a request or log a secret. Partner requests use the same signing lines with the raw-query difference.

Upload and read the receipt ​

POST /v1/provider/deliveries takes application/json with exactly contract: "racun-development-batch" and documents. Use the item-count and body-size bounds for createProviderDelivery in the generated contract. Malformed JSON, duplicate/unknown envelope members or wrong member spelling reject the request. Individual invalid items can be recorded as rejected while valid siblings proceed.

Start with the valid example batch, containing one legacy bill. The examples on this page use invented data.

json
{
  "contract": "racun-development-batch",
  "documents": [
    {
      "source_document_id": "example-provider-guide-2026-10",
      "revision": 1,
      "revision_kind": "original",
      "document_number": "EXAMPLE-GUIDE-2026-10",
      "issue_date": "2026-10-01",
      "currency": "EUR",
      "customer": {
        "provider_account": "invented-customer-001"
      },
      "totals": {
        "net": "20.00",
        "vat": "5.00",
        "gross": "25.00"
      },
      "obligation": {
        "amount_due": "25.00",
        "due_date": "2026-10-20"
      }
    }
  ]
}

For other source formats, see document input selection. The separate mixed-result batch intentionally adds null to demonstrate an item rejection; use it after the valid first case.

A 202 returns delivery_id once the batch and required work are durable, or returns the original ID for an exact replay. Poll GET /v1/provider/deliveries/{delivery_id} with fresh signed requests and a bounded client retry policy. No universal completion deadline or webhook feed is promised.

Delivery statusMeaning
receivedSome or all item outcomes are still missing
processedEvery position has an outcome; rejected/conflicting items can still exist
abandonedEvery position has an outcome and at least one is key_revoked
Item outcomeMeaning
acceptedStored version; includes its version_id
replayExisting version with the same canonical content; includes its version_id
conflictExisting version identity with different canonical content
rejectedCanonical document rejected; optional reason is explanatory text, not a stable code
key_revokedRevocation prevented this item from being processed

Positions are one-based. An item's recorded outcome is immutable, including a rejection later reassessed by staff. A storage failure is not a document rejection. An indefinitely received batch needs operator investigation, not new identities. The signed request UUID and server response X-Request-ID are separate correlations.

Node walkthrough ​

Download the client, sign-request.mjs and delivery-valid.json into one directory. Set RACUN_BASE_URL, RACUN_PROVIDER, RACUN_KEY_ID and RACUN_SECRET privately from your handoff. Set RACUN_DELIVERY_KEY to the durable identity of this exact batch, then run node send-delivery.mjs against your agreed test environment.

The client makes one POST and one GET. It prints the delivery ID first, then completion: "pending" for received, or "final" for processed/abandoned, and every item outcome actually returned. Pending responses can contain only some items. A final response is not a claim that every item was accepted.

For a fresh provider/document identity, the valid example's completed result has one item: position: 1, outcome: "accepted", and the returned version_id. If the first read is pending, read that same delivery again later with a fresh signature. The example adds no polling or retry loop. Keep the original bytes, delivery key and returned delivery ID for recovery. It logs no signing secret, headers or source body and follows no redirects. To send another downloaded example, use node send-delivery.mjs delivery-correction.json with its own durable batch key.

js
// Download beside sign-request.mjs and delivery-valid.json. Uses Node's built-in fetch.
// Obtain these settings privately from your approved environment operator.
import { readFile } from 'node:fs/promises'
import { randomUUID } from 'node:crypto'
import { fileURLToPath } from 'node:url'
import { signRequest } from './sign-request.mjs'

for (const name of ['RACUN_BASE_URL', 'RACUN_PROVIDER', 'RACUN_KEY_ID', 'RACUN_SECRET']) {
  if (!process.env[name]) throw new Error(`Missing private setting: ${name}`)
}
const base = new URL(process.env.RACUN_BASE_URL)
const inputFile = process.argv[2] ?? fileURLToPath(new URL('./delivery-valid.json', import.meta.url))
const originalBytes = await readFile(inputFile)
// Persist this key with these exact bytes before sending; reuse both after an unknown outcome.
const deliveryKey = process.env.RACUN_DELIVERY_KEY
if (!deliveryKey) throw new Error('Set RACUN_DELIVERY_KEY to the durable identity of this batch')
// Illustrative client budget, not a server completion guarantee. A timeout keeps
// the outcome unknown: retain the original batch key/bytes for recovery.
const requestTimeoutMs = 30_000
async function signed(method, target, body = Buffer.alloc(0), idempotencyKey = '') {
  const url = new URL(target, base)
  const headers = signRequest({ method, target, authority: url.host,
    issuer: process.env.RACUN_PROVIDER, keyId: process.env.RACUN_KEY_ID,
    secretBase64url: process.env.RACUN_SECRET,
    timestamp: String(Math.floor(Date.now() / 1000)), requestId: randomUUID(),
    body, idempotencyKey })
  return fetch(url, { method, headers: { ...headers, ...(method === 'POST' ? { 'Content-Type': 'application/json' } : {}) },
    ...(method === 'POST' ? { body } : {}), redirect: 'error', signal: AbortSignal.timeout(requestTimeoutMs) })
}
async function refuse(response, operation) {
  let problem
  try { problem = await response.json() } catch { /* A non-JSON failure still has its HTTP status and headers. */ }
  const details = {
    code: typeof problem?.code === 'string' ? problem.code : undefined,
    request_id: typeof problem?.request_id === 'string' ? problem.request_id : undefined,
    'X-Request-ID': response.headers.get('X-Request-ID') ?? undefined,
    'Retry-After': response.headers.get('Retry-After') ?? undefined,
  }
  throw new Error(`${operation}: HTTP ${response.status}; ${JSON.stringify(details)}; preserve the original operation`)
}
const accepted = await signed('POST', '/v1/provider/deliveries', originalBytes, deliveryKey)
if (accepted.status !== 202) await refuse(accepted, 'Delivery not acknowledged')
const { delivery_id } = await accepted.json()
if (typeof delivery_id !== 'string' || !delivery_id) {
  throw new Error('Missing delivery_id; recover using the original batch key and bytes')
}
// Store delivery_id with the original key/body before continuing.
console.log(JSON.stringify({ delivery_id }))
const result = await signed('GET', `/v1/provider/deliveries/${delivery_id}`)
if (!result.ok) await refuse(result, 'Status read failed')
const receipt = await result.json()
if (!['received', 'processed', 'abandoned'].includes(receipt.status) || !Array.isArray(receipt.items)) {
  throw new Error('Unexpected status response; retain delivery_id and the original batch for investigation')
}
console.log(JSON.stringify({ delivery_id, status: receipt.status,
  completion: receipt.status === 'received' ? 'pending' : 'final', items: receipt.items }, null, 2))
// Exactly one POST and one GET. If pending, read this delivery again later; do not start a new batch.

Replay, conflict and revisions ​

IdentityExact replayConflict
Provider + delivery idempotency keySame exact batch bytes → original delivery IDChanged bytes → HTTP 409 delivery_conflict
Provider + exact document-byte digestRecover the first recorded intake outcomeA staff reassessment does not rewrite that outcome
Provider + source document ID + revisionSame canonical content → item replayChanged canonical content → item conflict

After a timeout, lost response or retryable server failure, retain the same bytes and idempotency key, with a fresh timestamp, request UUID and signature. A failed response does not prove the transaction failed. JSON reformatting under the same delivery key conflicts even if the bill meaning is unchanged.

Correct source content as a new full revision. Do not overwrite a revision or change a delivery key merely to hide an unknown outcome. 400 needs request repair; 401 needs signing/key/clock repair; 429 requires waiting at least Retry-After. Use bounded increasing delays for transport/5xx failures and stop for investigation when the budget is exhausted.

A connected revision example ​

Run these files in order for an unused source_document_id in your test provider, and finish each delivery before the next. All five use example-provider-guide-2026-10, the same customer reference and EUR. D1 and V1 below name the delivery/version IDs returned for the original; retain the actual returned values.

StepFile and delivery keyFinal result
Originaldelivery-valid.json, key guide-originalNew D1; item 1 accepted, version V1, revision 1
Recover the original requestSame exact file and guide-originalSame D1 and its recorded result; no additional version
Canonical replaydelivery-replay.json, new key guide-replayNew delivery; item 1 replay, same V1
Conflicting revision 1delivery-conflict.json, new key guide-conflictNew delivery; item 1 conflict, no version ID; V1 stays unchanged
Correct to revision 2delivery-correction.json, new key guide-correctionItem 1 accepted, new V2; full correction states 20.00 due
Cancel with revision 3delivery-cancellation.json, new key guide-cancellationItem 1 accepted, new V3; cancellation states 0.00 due

The replay file changes the JSON member order while preserving every bill value. This exercises version replay. Sending identical document bytes under a new batch key can instead recover that document's first recorded accepted outcome. Do not expect an earlier result to be rewritten as replay.

Reusing guide-original with the conflict file has a different result: HTTP 409 delivery_conflict, before item processing. A new batch key does not make changed content at an occupied document/revision valid.

A correction or cancellation is a full source version, not a patch. The highest revision is current, including when versions arrive out of order. Cancellation neither deletes earlier evidence nor refunds a payment. See document semantics.

Attach a PDF ​

Use version_id from an accepted/replay item for PUT /v1/provider/bills/{version_id}/pdf. Send exact application/pdf bytes starting with %PDF-, within the body-size bound for putProviderBillPdf in the generated contract. Sign their digest with an empty idempotency line and no query/header key. First attachment returns 201; the same bytes return 200; different bytes conflict with 409. Each revision has its own PDF.

A PDF is optional and is a display copy, never a source for amounts or payment instructions. Signing authenticates the submitting key, not agreement between PDF content and bill data. Customer/partner download still requires current access.

Documentation for providers and partners.