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

# Create a hosted payin invoice

> Creates a hosted payment invoice and returns the URL of the LigdiCash payment page.

## Headers

<ParamField header="Apikey" type="string" required>
  API key of the LigdiCash project.
</ParamField>

<ParamField header="Authorization" type="string" required>
  `Bearer {API_TOKEN}`
</ParamField>

<ParamField header="Accept" type="string" required>
  `application/json`
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

## Body

<ParamField body="commande" type="object" required>
  <Expandable title="commande" defaultOpen>
    <ParamField body="invoice" type="object" required>
      <Expandable title="invoice" defaultOpen>
        <ParamField body="items" type="array" required>
          Order items. Can be `[]` — in that case, only `total_amount` is used.

          <Expandable title="item">
            <ParamField body="name" type="string" required>Item name.</ParamField>
            <ParamField body="description" type="string">Description.</ParamField>
            <ParamField body="quantity" type="integer" required>Quantity.</ParamField>
            <ParamField body="unit_price" type="integer" required>Unit price in XOF.</ParamField>
            <ParamField body="total_price" type="integer" required>`unit_price × quantity` in XOF.</ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="total_amount" type="integer" required>Total amount in XOF (integer).</ParamField>
        <ParamField body="devise" type="string" required>Always `"XOF"`.</ParamField>
        <ParamField body="description" type="string" required>Description shown on the payment page.</ParamField>
        <ParamField body="customer" type="string" required>Always `""`. A non-empty number filters the operators displayed.</ParamField>
        <ParamField body="customer_firstname" type="string">Customer first name.</ParamField>
        <ParamField body="customer_lastname" type="string">Customer last name.</ParamField>
        <ParamField body="customer_email" type="string">Customer email.</ParamField>
        <ParamField body="external_id" type="string">Alternative merchant identifier. `""` if unused.</ParamField>
        <ParamField body="otp" type="string">Always `""`.</ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="store" type="object" required>
      <Expandable title="store" defaultOpen>
        <ParamField body="name" type="string" required>Store name shown on the payment page.</ParamField>
        <ParamField body="website_url" type="string" required>Merchant site URL.</ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="actions" type="object" required>
      <Expandable title="actions" defaultOpen>
        <ParamField body="cancel_url" type="string" required>Redirect URL if the customer cancels.</ParamField>
        <ParamField body="return_url" type="string" required>Redirect URL after a successful payment.</ParamField>
        <ParamField body="callback_url" type="string" required>Backend notification URL. Must be publicly accessible.</ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="custom_data" type="object">Free-form metadata returned in the callback. Recommended: include a unique `transaction_id`.</ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="response_code" type="string">
  `"00"` = success, `"01"` = error.
</ResponseField>

<ResponseField name="token" type="string">
  Transaction token. **Store it immediately** — required to call `confirm`.
</ResponseField>

<ResponseField name="response_text" type="string">
  Success: URL of the payment page to open for the customer. Failure: sub-code `Echec (CodeXX)`.
</ResponseField>

<ResponseField name="wiki" type="string">
  URL to the sub-codes documentation for this endpoint.
</ResponseField>

<CodeGroup>
  ```json Success theme={null}
  {
    "response_code": "00",
    "token": "eyJ0eXAiOiJKV1Qi...",
    "response_text": "https://app.ligdicash.com/pay/invoice/eyJ0eXAiOiJKV1Qi...",
    "wiki": "https://client.ligdicash.com/wiki/createInvoice"
  }
  ```

  ```json Failure theme={null}
  {
    "response_code": "01",
    "token": "",
    "response_text": "Echec (Code00)",
    "wiki": "https://client.ligdicash.com/wiki/createInvoice"
  }
  ```
</CodeGroup>

## Error codes

Wiki: `https://client.ligdicash.com/wiki/createInvoice` — see [Sub-codes per endpoint](/en/errors/sub-codes#createinvoice).

## Related guide

[Create an invoice](/en/payment-api/hosted-payin/create-invoice) — full examples and pitfalls to avoid.
