Skip to main content

Upload a support file (v2 — optional auto-classification)

The v2 upload endpoint unifies the two real-world cases under one contract:

  • You know the document type → pass support_file_code. v2 behaves like v1: it skips DVS classification and processes the file synchronously against the provider's support-document catalog. The endpoint returns 204 No Content.
  • You don't know the document type → omit support_file_code. RCM persists the file and asks DVS to classify it asynchronously, then runs validation. The endpoint returns 202 Accepted with a document id you can correlate with the webhooks.

If you only have the "you know the type" case, you can keep using v1 — it's identical for that flow. v2 exists for systems pulling documents from generic sources (email attachments, scanner inboxes, drag-and-drop UIs) where the type can't be reliably determined client-side.

Prerequisites​

Same as v1:

  1. 1Access token

    OAuth2 client credentials enabled for support-file upload. See Obtaining tokens.

  2. 2Existing origin event

    At least one origin_event_id from a previously created account/admission.

  3. 3Webhook receiver

    Classification and validation outcomes arrive as webhooks. When support_file_code is omitted, you'll receive two events per upload:

    1. DOCUMENT_CLASSIFICATION_COMPLETED (or DOCUMENT_CLASSIFICATION_FAILED) — within ~5–15 seconds.
    2. If classification completed → a DOCUMENT_VALIDATION_* event follows ~10–30 seconds later.

    See Webhook events → Classification for the full payloads.

Endpoint​

POST /v2/support-files/upload
Content-Type: multipart/form-data
Authorization: Bearer <token>

The request is multipart/form-data with two parts:

PartTypeRequiredDescription
filebinaryyesThe document. PDF or image (JPEG, PNG). Up to 200 MB.
request_dataJSONyesThe metadata object described below.

request_data fields​

FieldTypeRequiredDescription
support_file_codestringnoIf you know the document type, pass it (same behaviour as v1 — synchronous, no DVS). If omitted, RCM asks DVS to classify. Max 64 chars.
eventsarrayyesOne or more events the document supports. Must contain at least one element.
events[].origin_event_idstringyesThe origin event this document supports. Max 64 chars.
events[].agreement_codestringnoAgreement code for the event. Max 64 chars.
events[].charge_codesstring[]noCharge codes to attach the document at charge level. Omit to attach at account level.
authorization_idstringnoAuthorization identifier. Max 256 chars.
authorized_bystringnoWho authorized the upload. Max 128 chars.
support_file_metadataobjectnoFree-form key-value pairs. Persisted with the document. Not echoed in webhook events — neither the classification nor the validation payload carries it.

How the document gets linked to an account or charge​

There is no account_id parameter. RCM resolves the target from the event identifiers:

What you sendWhat it resolves to
events[].origin_event_idThe admission/event you previously created. This is what binds the document to the account — it replaces any notion of passing an account_id.
events[].agreement_codeDisambiguates which provider-payer agreement the event belongs to, when the same origin_event_id exists under more than one.
events[].charge_codesAttaches the document at charge level, to those specific charges of that event. Omit it and the document stays at account level.

Because events is an array, one upload can back several events at once — that's why the linkage lives inside each element rather than at the top level. This applies to Mode A only; in Mode B the document is linked to a single event and charge, see the Mode B limitation.

Two upload modes​

Mode A — support_file_code provided​

Identical behaviour to v1: RCM skips classification and processes the file synchronously against the provider's support-document catalog. Use this mode when migrating an existing v1 integration to v2 without changing your business logic.

curl -X POST https://sandbox.osigu.com/rcm/v2/support-files/upload \
-H "Authorization: Bearer $TOKEN" \
-F "file=@./guia.pdf;type=application/pdf" \
-F 'request_data={"support_file_code":"TISS_GUIDE","events":[{"origin_event_id":"evt-123","agreement_code":"AGR-001","charge_codes":["QS-0001"]}]};type=application/json'

Response: 204 No Content (empty body).

Because the file is processed synchronously, there is no document id to return — the outcome is applied immediately, exactly as in v1. If the support_file_code is not in your provider's catalog, the endpoint returns 404 Not Found:

{
"code": "055-0300-0020",
"message": "No se pudo encontrar el documento de soporte."
}

The message is localised — send Accept-Language: en or pt to change it. code stays the same; see Error format.

Mode B — support_file_code omitted​

RCM enters the auto-classify flow: it persists the file and submits it to DVS asynchronously.

curl -X POST https://sandbox.osigu.com/rcm/v2/support-files/upload \
-H "Authorization: Bearer $TOKEN" \
-F "file=@./documento_desconocido.pdf;type=application/pdf" \
-F 'request_data={"events":[{"origin_event_id":"evt-123"}]};type=application/json'

Response (202 Accepted):

{
"document_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"status": "RECEIVED"
}

status is always RECEIVED — it's an acknowledgement that the file is queued, not a processing state. The response has no other fields.

Mode B links one event and one charge

When support_file_code is omitted, RCM links the classified document only to the first element of events, and within it only to the first code in charge_codes. Any further events or charge codes are accepted without error but are not linked.

If the same document backs several events or charges, either upload it once per event–charge pair, or — if you know the type — use Mode A, which links every event and charge you send.

First you'll receive a DOCUMENT_CLASSIFICATION_* event. If it's DOCUMENT_CLASSIFICATION_COMPLETED, RCM persists the detected support_file_code on the support file record AND runs validation; a DOCUMENT_VALIDATION_* event arrives afterwards. If it's DOCUMENT_CLASSIFICATION_FAILED, the file goes to UNCLASSIFIED state and no validation event will follow.

document_id does not carry over to the validation event

The document_id in this response identifies the inbox record that holds your upload. The DOCUMENT_CLASSIFICATION_* event repeats that same id, so those two correlate directly.

Once classification succeeds, RCM creates a separate support file record with its own id, and that is the document_id (and entity_id) you'll see on the DOCUMENT_VALIDATION_* event. It is a different UUID, and the inbox id is not included anywhere in the validation event. This is also why entity_type changes from support_document to support_file between the two.

To follow one upload end to end, key your state on origin_event_id + support_file_code (both events carry them), and treat document_id as meaningful only within a single event type. See the two-event flow below.

Choosing between modes​

Your situationRecommended mode
Your system has a "Document type" dropdown filled by the end userMode A (pass the code) — DVS doesn't need to classify what the user already told you.
Your system receives documents from email or a generic upload boxMode B (omit the code) — let DVS decide.
You're not sure if the user picked the right typeMode A is still safer: DVS validates based on the code you passed. If it rejects with field-mismatch errors, the user may have picked the wrong type.
You're building a fully automated pipeline (PMS → RCM, no human)Depends. If the source signals the type unambiguously, Mode A. Otherwise Mode B + fallback to manual review on DOCUMENT_CLASSIFICATION_FAILED.

Node.js example (Mode B)​

import fs from 'node:fs';
import FormData from 'form-data';
import fetch from 'node-fetch';

async function autoClassifyAndValidate({token, filePath, originEventId, chargeCodes}) {
const form = new FormData();
form.append('file', fs.createReadStream(filePath), {contentType: 'application/pdf'});
// NB: support_file_code intentionally omitted — RCM will ask DVS to classify
const requestData = {
events: [{origin_event_id: originEventId, charge_codes: chargeCodes ?? []}],
};
form.append('request_data', JSON.stringify(requestData), {contentType: 'application/json'});

const res = await fetch('https://sandbox.osigu.com/rcm/v2/support-files/upload', {
method: 'POST',
headers: {Authorization: `Bearer ${token}`},
body: form,
});

if (res.status !== 202) {
throw new Error(`Upload failed: ${res.status} ${await res.text()}`);
}
const {document_id, status} = await res.json();
console.log(`Uploaded document=${document_id} status=${status}`);
// Now wait for DOCUMENT_CLASSIFICATION_* and DOCUMENT_VALIDATION_* webhooks.
return document_id;
}

Handling the two-event flow in Mode B​

Your receiver needs to handle both classification and validation events for the same upload. Because document_id changes between them (see the warning above), key your state on the pair origin_event_id + support_file_code:

key = (origin_event_id, support_file_code)

# 202 response: record the inbox id under the origin_event_id you just uploaded for.
# support_file_code is not known yet in Mode B — DVS fills it in.

state(key) = AWAITING_CLASSIFICATION
→ on DOCUMENT_CLASSIFICATION_COMPLETED (entity_type: support_document)
payload.document_id == the id returned by the 202
set support_file_code from the payload → AWAITING_VALIDATION
→ on DOCUMENT_CLASSIFICATION_FAILED → UNCLASSIFIED, surface to operator

state(key) = AWAITING_VALIDATION
→ on DOCUMENT_VALIDATION_COMPLETED (entity_type: support_file)
payload.document_id is a NEW id — store it, don't match on it
→ APPROVED
→ on DOCUMENT_VALIDATION_REJECTED → REJECTED, surface errors

In Mode A there is no classification event and no 202 body, so the only key you have is the origin_event_id + support_file_code you sent.

For idempotency: store event_id as a primary key in a processed_events table before applying the state transition. If the same event_id arrives twice, the insert fails and you skip processing. Note that event_id is per delivery attempt of an event, stable across retries — it is not a document identifier.

What if I want auto-classification but RCM rejects the file with LOW_CONFIDENCE?​

Two paths forward:

  1. Re-upload a cleaner copy of the same document — re-scan at higher quality, or pull the PDF directly from the source system instead of via an email forward.
  2. Fall back to Mode A with an explicit support_file_code if you and the end user actually know what the document is. DVS will skip classification and go straight to validation; if the rules match, the file will be APPROVED.

There's no automatic re-classification in RCM — once a file is UNCLASSIFIED, you have to act on it explicitly.

If you built against an earlier version of this page​

Until mid-2026 this guide (and its Spanish and Portuguese translations) described a contract that the API never implemented. If your integration was written against it, these are the corrections:

Earlier version saidActual behaviour
Flat form fields: -F support_file_code=…, -F account_id=…, -F charge_code=…Two parts only: binary file + request_data JSON. All metadata goes inside request_data.
account_id identifies the targetNo such field. Use events[].origin_event_id (see linking).
charge_code (single, form field)events[].charge_codes (array, inside each event).
202 Accepted in both modes204 No Content in Mode A, 202 Accepted in Mode B.
Response field support_file_id, e.g. sf_01HX9KP7VQ2D4FZ8N0YPRQAW6XDoes not exist. Mode B returns document_id, a plain UUID. There is no sf_-prefixed identifier anywhere in RCM.
Response fields processing_mode, webhooks_will_be_emitted, uploaded_atNever returned. The 202 body contains exactly document_id and status. Mode A returns no body at all.
status values PENDING_VALIDATION / PENDING_CLASSIFICATIONThe only value is RECEIVED.

To know which events an upload will produce, use the mode you chose rather than a response field: Mode A → DOCUMENT_VALIDATION_* only; Mode B → a DOCUMENT_CLASSIFICATION_* event, then a DOCUMENT_VALIDATION_* event if classification succeeded.

Migration from v1​

If you're switching from v1 to v2 without changing your business logic:

  1. Change the URL from /v1/support-files/upload to /v2/support-files/upload.
  2. Keep passing support_file_code inside request_data. The behaviour is identical (skips classification, returns 204 No Content).
  3. Your response handling stays the same — Mode A returns 204 with no body, just like v1.
  4. Your webhook handler stays the same — Mode A on v2 emits the same DOCUMENT_VALIDATION_* events as v1.

No webhook subscription changes needed; the same subscription works for both v1 and v2 uploads.