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 returns204 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 returns202 Acceptedwith 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:
- 1Access token
OAuth2 client credentials enabled for support-file upload. See Obtaining tokens.
- 2Existing origin event
At least one
origin_event_idfrom a previously created account/admission. - 3Webhook receiver
Classification and validation outcomes arrive as webhooks. When
support_file_codeis omitted, you'll receive two events per upload:DOCUMENT_CLASSIFICATION_COMPLETED(orDOCUMENT_CLASSIFICATION_FAILED) — within ~5–15 seconds.- 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:
| Part | Type | Required | Description |
|---|---|---|---|
file | binary | yes | The document. PDF or image (JPEG, PNG). Up to 200 MB. |
request_data | JSON | yes | The metadata object described below. |
request_data fields
| Field | Type | Required | Description |
|---|---|---|---|
support_file_code | string | no | If you know the document type, pass it (same behaviour as v1 — synchronous, no DVS). If omitted, RCM asks DVS to classify. Max 64 chars. |
events | array | yes | One or more events the document supports. Must contain at least one element. |
events[].origin_event_id | string | yes | The origin event this document supports. Max 64 chars. |
events[].agreement_code | string | no | Agreement code for the event. Max 64 chars. |
events[].charge_codes | string[] | no | Charge codes to attach the document at charge level. Omit to attach at account level. |
authorization_id | string | no | Authorization identifier. Max 256 chars. |
authorized_by | string | no | Who authorized the upload. Max 128 chars. |
support_file_metadata | object | no | Free-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 send | What it resolves to |
|---|---|
events[].origin_event_id | The 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_code | Disambiguates which provider-payer agreement the event belongs to, when the same origin_event_id exists under more than one. |
events[].charge_codes | Attaches 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.
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 eventThe 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 situation | Recommended mode |
|---|---|
| Your system has a "Document type" dropdown filled by the end user | Mode 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 box | Mode B (omit the code) — let DVS decide. |
| You're not sure if the user picked the right type | Mode 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:
- 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.
- Fall back to Mode A with an explicit
support_file_codeif 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 beAPPROVED.
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 said | Actual 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 target | No 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 modes | 204 No Content in Mode A, 202 Accepted in Mode B. |
Response field support_file_id, e.g. sf_01HX9KP7VQ2D4FZ8N0YPRQAW6X | Does 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_at | Never returned. The 202 body contains exactly document_id and status. Mode A returns no body at all. |
status values PENDING_VALIDATION / PENDING_CLASSIFICATION | The 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:
- Change the URL from
/v1/support-files/uploadto/v2/support-files/upload. - Keep passing
support_file_codeinsiderequest_data. The behaviour is identical (skips classification, returns204 No Content). - Your response handling stays the same — Mode A returns
204with no body, just like v1. - 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.