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:
- Validates the account has charges, a payer, and at least one enabled event. If any are missing →
422with a descriptive message. - Changes account status to
NON_PROCESSABLEvia the standard account status service, publishing anACCOUNT_NON_PROCESSABLEintegration event. - 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 stayenabled = true. This frees the partial unique indexUNIQUE(event_id, code) WHERE enabled = trueso the original code can be reused by the rebilled charges. The original code is saved incharge_additional_data(EAV) for traceability. - Releases base charges — sets
invoiceAssigned = falseon the corresponding base-account charges so they become available for reassignment. - Flags the account as
probable_for_refund = trueinaccount_additional_data. - 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
| HTTP | Error key | Condition |
|---|---|---|
404 | error.credit-note.invoice-not-found | Invoice doesn't exist, isn't ASSIGNED, or is disabled. |
422 | error.credit-note.account-disabled | The account is disabled. |
422 | error.credit-note.already-non-processable | Account is already NON_PROCESSABLE — idempotent guard. |
422 | error.credit-note.no-charges | Account has no active charges. |
422 | error.credit-note.no-payer | Account has no payer assigned. |
422 | error.credit-note.no-services | Account 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"
}
| Field | Required | Description |
|---|---|---|
agreement_code | yes | The provider-payer agreement for the new invoice. |
invoice_number | yes | Your identifier for the new invoice. |
source_invoice_number | yes | The original invoice that was credit-noted. Used for traceability and validation. |
charge_codes | yes | Array of charge codes to reassign. Must all exist and be released (invoiceAssigned = false). |
settlement_number | no | Payer's settlement number, when applicable. |
batch_number | no | Batch 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
| HTTP | Error key | Condition |
|---|---|---|
404 | error.rebilling.source-invoice-not-found | Source invoice doesn't exist, isn't ASSIGNED, or is disabled. |
422 | error.rebilling.account-not-non-processable | Source account is not in NON_PROCESSABLE status — credit note wasn't applied first. |
422 | error.rebilling.source-account-disabled | Source account is disabled. |
422 | error.rebilling.charges-not-found | One or more charge codes don't exist for the provider. |
422 | error.rebilling.charges-not-available | One 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 returns422without 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
| Operation | Endpoint | Response |
|---|---|---|
| Process credit note | POST /v1/invoices/credit-note | 200 with credit note result |
| Start rebilling | POST /v1/invoices/rebilling | 202 with Location header |
| Check rebilling status | GET /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 returns422. - 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_numberin 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.
Related concepts
- 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.