Skip to main content

Credit notes & rebilling

A credit note in RCM is the signal your HIS sends when an already-invoiced account needs to be re-billed — the payer rejected it, the provider found an error, or the agreement changed. It moves the account to NON_PROCESSABLE, prefixes the invoiced charge codes with a random UUID fragment to free the unique constraint, and releases the original charge codes so they can be assigned to a fresh invoice.

Rebilling is the second step: you take those released charge codes and assign them to a new invoice number, reusing the existing assign-charges infrastructure. The two endpoints are always used together and in order.

This is the V3 rebilling flow. It replaces the older V1/V2 reassignment mechanisms with a simpler two-step process. V1 and V2 continue to work — see API versioning.

Where it sits in the flow​

Account (invoiced)
│
├── Step 1: Credit note
│ POST /v1/invoices/credit-note
│ → Account status: NON_PROCESSABLE
│ → Invoiced charges: code prefixed with UUID (enabled stays true)
│ → Base charges: released (invoiceAssigned=false)
│ → Flag: probable_for_refund=true
│
└── Step 2: Rebilling
POST /v1/invoices/rebilling
→ Released charges assigned to a new invoice
→ New invoiced account created (marked as reassigned)
→ Processing is async (poll for status)

Step 1 — Credit note​

POST /v1/invoices/credit-note receives an invoice_number and performs the following atomically:

  1. Validates the account has charges, a payer, and at least one enabled event. If any are missing → 422 with a descriptive message.
  2. Changes account status to NON_PROCESSABLE via the standard account status service, publishing an ACCOUNT_NON_PROCESSABLE integration event.
  3. Prefixes invoiced charge codes — prepends a 4-character random UUID fragment and a dash to each charge's code (e.g. a1b2-CHARGE_001). The charges stay enabled = true. This frees the partial unique index UNIQUE(event_id, code) WHERE enabled = true so the original code can be reused by the rebilled charges. The original code is saved in charge_additional_data (EAV) for traceability.
  4. Releases base charges — sets invoiceAssigned = false on the corresponding base-account charges so they become available for reassignment.
  5. Flags the account as probable_for_refund = true in account_additional_data.
  6. Disables settlement group relations to prevent the non-processable account from appearing in packaging flows.

Request​

{
"invoice_number": "INV-2024-001"
}

Response (200 OK)​

{
"account_id": "a1b2c3d4-...",
"invoice_number": "INV-2024-001",
"previous_status": "OPEN",
"current_status": "NON_PROCESSABLE",
"charges_released": 5,
"probable_for_refund": true,
"message": "Credit note processed successfully"
}

Error codes​

HTTPError keyCondition
404error.credit-note.invoice-not-foundInvoice doesn't exist, isn't ASSIGNED, or is disabled.
422error.credit-note.account-disabledThe account is disabled.
422error.credit-note.already-non-processableAccount is already NON_PROCESSABLE — idempotent guard.
422error.credit-note.no-chargesAccount has no active charges.
422error.credit-note.no-payerAccount has no payer assigned.
422error.credit-note.no-servicesAccount has no enabled events (services).

Step 2 — Rebilling​

POST /v1/invoices/rebilling takes the released charge codes and assigns them to a new invoice. It delegates to the same assign-charges infrastructure — same async worker, same monitoring mechanism — adding only source-account validation.

Request​

{
"agreement_code": "AGREEMENT_001",
"invoice_number": "NEW-INVOICE-002",
"source_invoice_number": "INV-2024-001",
"charge_codes": ["CHARGE_001", "CHARGE_002"],
"settlement_number": "STL-001",
"batch_number": "BATCH-001"
}
FieldRequiredDescription
agreement_codeyesThe provider-payer agreement for the new invoice.
invoice_numberyesYour identifier for the new invoice.
source_invoice_numberyesThe original invoice that was credit-noted. Used for traceability and validation.
charge_codesyesArray of charge codes to reassign. Must all exist and be released (invoiceAssigned = false).
settlement_numbernoPayer's settlement number, when applicable.
batch_numbernoBatch grouping identifier, when applicable.

Response (202 Accepted)​

The response body is empty. A Location header points to the status endpoint:

Location: /rcm/v1/invoices/rebilling/status/{id}

Polling for status​

GET /v1/invoices/rebilling/status/{id} returns the processing state:

{
"id": "f47ac10b-...",
"invoice_number": "NEW-INVOICE-002",
"agreement_code": "AGREEMENT_001",
"total_charges_processed": 2,
"status": "COMPLETED",
"charges": [
{ "code": "CHARGE_001", "status": "COMPLETED", "error_description": null },
{ "code": "CHARGE_002", "status": "COMPLETED", "error_description": null }
]
}

The status field transitions: PENDING → IN_PROGRESS → COMPLETED (or individual charges may show ERROR with a description).

Error codes​

HTTPError keyCondition
404error.rebilling.source-invoice-not-foundSource invoice doesn't exist, isn't ASSIGNED, or is disabled.
422error.rebilling.account-not-non-processableSource account is not in NON_PROCESSABLE status — credit note wasn't applied first.
422error.rebilling.source-account-disabledSource account is disabled.
422error.rebilling.charges-not-foundOne or more charge codes don't exist for the provider.
422error.rebilling.charges-not-availableOne or more charges still have invoiceAssigned = true — they haven't been released.

Idempotency​

Both endpoints have built-in idempotency guards:

  • Credit note: If the account is already NON_PROCESSABLE, the endpoint returns 422 without side effects. It does not re-disable charges or re-flag the account.
  • Rebilling: If a rebilling request with the same charge code set has already been submitted, the existing assignment is returned instead of creating a duplicate. This is implemented via charge code hash deduplication.

Endpoints​

OperationEndpointResponse
Process credit notePOST /v1/invoices/credit-note200 with credit note result
Start rebillingPOST /v1/invoices/rebilling202 with Location header
Check rebilling statusGET /v1/invoices/rebilling/status/{id}200 with per-charge status

Common pitfalls​

  • Calling rebilling before credit note. The source account must be NON_PROCESSABLE — which only happens after the credit note step. Calling rebilling first returns 422.
  • Sending charge codes that are still assigned. If the credit note didn't release the charges (e.g. the credit note was applied to a different invoice), the rebilling endpoint rejects them. Verify the source invoice number matches.
  • Expecting a synchronous response from rebilling. Rebilling returns 202 — the actual charge assignment happens asynchronously. Poll the status endpoint.
  • Reusing the same invoice number. The invoice_number in the rebilling request must be a new, unused number. Reusing the original invoice number is not supported.
  • Skipping the status poll. Individual charges may fail (wrong code, already assigned elsewhere). Always check per-charge status for errors.
  • Charges — the billable lines that are released and reassigned.
  • Accounts — the billing wrapper whose status changes to NON_PROCESSABLE.
  • Pre-settlements — the next step after the new invoice is created.