> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Factor Invoice

> Sell an outstanding invoice for immediate ssUSD, at a discount, without waiting for the buyer to pay.

### Overview

Factoring converts an unpaid invoice into cash now. You receive the **advance amount** — the invoice
face value less the discount — and the funder collects from the buyer at maturity.

The discount rate you're offered is driven by the buyer's credit, not yours. Call
`GET /v1/finance/invoices/{invoice_id}/factoring-options` first to see the competing rates before
committing to one — see [Finance](/stateset-commerce-api-reference/finance#get-factoring-options).

<Warning>
  `recourse` decides who absorbs a buyer default. With `recourse: false` the funder takes the loss;
  with `true` you are liable to repay the advance. Non-recourse costs a higher discount rate — that
  spread *is* the price of the risk transfer. Set it deliberately.
</Warning>

### Body

<ParamField body="invoice_id" type="string" required>
  The invoice to factor. Must be outstanding and unpaid.
</ParamField>

<ParamField body="amount" type="string" required>
  Invoice face value, as a decimal string.
</ParamField>

<ParamField body="currency" type="string" required>
  Settlement currency — `USDC` or `ssUSD`.
</ParamField>

<ParamField body="discount_rate" type="number" required>
  The agreed rate as a decimal — `0.025` is 2.5%. Take this from the factoring options response
  rather than proposing your own.
</ParamField>

<ParamField body="buyer" type="object" required>
  Who owes the invoice. The funder prices on this.

  <Expandable title="properties">
    <ParamField body="id" type="string" required>
      The buyer's [DID](/stateset-commerce-api-reference/dids), e.g. `did:stateset:buyer:abc123`.
    </ParamField>

    <ParamField body="credit_rating" type="string">
      Rating, e.g. `AAA`.
    </ParamField>

    <ParamField body="payment_history" type="string">
      Qualitative history, e.g. `excellent`.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="terms" type="object" required>
  <Expandable title="properties">
    <ParamField body="net_days" type="number" required>
      Payment terms in days, e.g. `30`.
    </ParamField>

    <ParamField body="due_date" type="string" required>
      Invoice due date, `YYYY-MM-DD`.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="recourse" type="boolean">
  Whether you remain liable if the buyer defaults. Defaults to `false`.
</ParamField>

### Response

<ResponseField name="factoring_id" type="string" required>
  Identifier for the factoring position. Track it with
  `GET /v1/finance/factoring/{factoring_id}`.
</ResponseField>

<ResponseField name="invoice_id" type="string" required>
  The invoice that was factored.
</ResponseField>

<ResponseField name="status" type="string" required>
  `FUNDED` once the advance has settled.
</ResponseField>

<ResponseField name="advance_amount" type="string" required>
  What you receive — face value less the discount.
</ResponseField>

<ResponseField name="discount_amount" type="string" required>
  The fee retained by the funder.
</ResponseField>

<ResponseField name="discount_rate" type="number" required>
  The rate applied.
</ResponseField>

<ResponseField name="funded_at" type="string" required>
  When the advance settled.
</ResponseField>

<ResponseField name="maturity_date" type="string" required>
  When the buyer's payment is due.
</ResponseField>

<ResponseField name="transaction_hash" type="string" required>
  On-chain hash of the settlement.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://api.stateset.com/v1/finance/invoices/factor' \
    -H 'Authorization: Bearer <token>' \
    -H 'Content-Type: application/json' \
    -d '{
      "invoice_id": "inv_12345",
      "amount": "50000.00",
      "currency": "USDC",
      "discount_rate": 0.025,
      "buyer": {
        "id": "did:stateset:buyer:abc123",
        "credit_rating": "AAA",
        "payment_history": "excellent"
      },
      "terms": { "net_days": 30, "due_date": "2024-07-25" },
      "recourse": false
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "factoring_id": "fact_8y4mQr5oP2",
    "invoice_id": "inv_12345",
    "status": "FUNDED",
    "advance_amount": "48750.00",
    "discount_amount": "1250.00",
    "discount_rate": 0.025,
    "funded_at": "2024-06-25T12:05:00Z",
    "maturity_date": "2024-07-25T23:59:59Z",
    "transaction_hash": "0x742d35Cc6634C0532925a3b8D097C00D4dfece08"
  }
  ```
</ResponseExample>

### Related

* [Finance API](/stateset-commerce-api-reference/finance) — factoring, PO financing, and lending
* [Pay Invoice](/stateset-commerce-api-reference/invoices/pay)
* [Loan Request](/stateset-commerce-api-reference/loans/request) — borrow against collateral instead
