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

# Get invoices from the API

> Retrieve Billions invoices using your order reference.

Retrieve invoices from the Billions API using the `order_no` stored with your
order. This is useful for displaying payment status, reconciling local records,
or restoring an invoice after an uncertain create request.

For example, a create request may time out after Billions has created the
invoice but before your backend receives the response. Before creating another
invoice, query the API using the stable `order_no`.

<CodeGroup>
  ```ts TypeScript theme={null}
  const invoices = await api.getInvoicesByOrder('ORDER-1001');

  for (const invoice of invoices) {
    console.log(invoice.id, invoice.status, invoice.invoice_url);
  }
  ```

  ```php PHP theme={null}
  $invoices = $api->getInvoicesByOrderNo('ORDER-1001');

  foreach ($invoices as $invoice) {
      echo $invoice['id'] . ' ' . $invoice['status'] . PHP_EOL;
  }
  ```

  ```bash cURL theme={null}
  curl --request GET \
    --url https://api.billions.works/public/v1/invoices/byOrder/ORDER-1001 \
    --header "Content-Type: application/json" \
    --header "x-api-key: $BILLIONS_API_KEY"
  ```
</CodeGroup>

## Retrieval and recovery rules

1. Retry the same logical create attempt with the same idempotency key.
2. Query by `order_no` when reconciling your local order with Billions.
3. Match the amount, currency, and intended attempt before redirecting.
4. Create a new attempt only when the previous attempt is no longer usable.
