> ## 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 an invoice

> Endpoint POST /pay/v01/redirect/checkout-invoice/create — parameters, full example, and response.

This endpoint creates a new payment invoice and returns a link to the LigdiCash payment page. It is the first step of the hosted payin flow.

```
POST https://app.ligdicash.com/pay/v01/redirect/checkout-invoice/create
```

## Headers

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

<ParamField header="Authorization" type="string" required>
  Your API TOKEN prefixed with `Bearer `. Example: `Bearer eyJ0eXAiOiJKV1Qi...`
</ParamField>

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

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

## Body

<ParamField body="commande" type="object" required>
  Root object of the request.

  <Expandable title="commande fields" defaultOpen={true}>
    <ParamField body="invoice" type="object" required>
      Invoice details.

      <Expandable title="invoice fields" defaultOpen={true}>
        <ParamField body="items" type="array" required>
          List of items. Can be empty (`[]`) — in that case, only `total_amount` is taken into account.

          <Expandable title="Fields of an item" defaultOpen={true}>
            <ParamField body="name" type="string" required>Item name.</ParamField>
            <ParamField body="description" type="string">Item 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>Line total (`unit_price × quantity`) in XOF.</ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="total_amount" type="integer" required>Total amount in XOF (integer, no decimals). If `items` is empty, this field alone defines the amount to collect.</ParamField>
        <ParamField body="devise" type="string" required>Currency. Always `XOF`.</ParamField>
        <ParamField body="description" type="string" required>Order description, displayed on the payment page.</ParamField>
        <ParamField body="customer" type="string" required>Must always be empty (`""`). If a number is provided, LigdiCash filters the page to only show matching operators.</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. Leave empty (`""`) if not used. Equivalent of `transaction_id` in `custom_data`.</ParamField>
        <ParamField body="otp" type="string">Always empty (`""`) for hosted payin.</ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="store" type="object" required>
      Information about your store.

      <Expandable title="store fields" defaultOpen={true}>
        <ParamField body="name" type="string" required>Name of your store or application, displayed on the payment page.</ParamField>
        <ParamField body="website_url" type="string" required>URL of your website.</ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="actions" type="object" required>
      Return and notification URLs.

      <Expandable title="actions fields" defaultOpen={true}>
        <ParamField body="cancel_url" type="string" required>URL where LigdiCash redirects the customer if they cancel the payment.</ParamField>
        <ParamField body="return_url" type="string" required>URL where LigdiCash redirects the customer after a successful payment.</ParamField>
        <ParamField body="callback_url" type="string" required>URL of your backend endpoint for status notifications. Must be publicly accessible.</ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="custom_data" type="object">
      Free-form object for your metadata. LigdiCash returns it to you in the callback. Use it to pass your `transaction_id`.
    </ParamField>
  </Expandable>
</ParamField>

## Request example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://app.ligdicash.com/pay/v01/redirect/checkout-invoice/create \
    -H "Apikey: {API_KEY}" \
    -H "Authorization: Bearer {API_TOKEN}" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -d '{
      "commande": {
        "invoice": {
          "items": [
            {
              "name": "Pro Subscription",
              "description": "Premium access for 1 month",
              "quantity": 1,
              "unit_price": 5000,
              "total_price": 5000
            }
          ],
          "total_amount": 5000,
          "devise": "XOF",
          "description": "Pro Subscription — January 2025",
          "customer": "",
          "customer_firstname": "Amadou",
          "customer_lastname": "Diallo",
          "customer_email": "amadou@example.com",
          "external_id": "",
          "otp": ""
        },
        "store": {
          "name": "MyApp",
          "website_url": "https://myapp.com"
        },
        "actions": {
          "cancel_url": "https://myapp.com/payment/cancel",
          "return_url": "https://myapp.com/payment/success",
          "callback_url": "https://myapp.com/api/callback/ligdicash"
        },
        "custom_data": {
          "transaction_id": "ORD-2025-00042"
        }
      }
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    "https://app.ligdicash.com/pay/v01/redirect/checkout-invoice/create",
    {
      method: "POST",
      headers: {
        Apikey: process.env.LIGDICASH_API_KEY,
        Authorization: `Bearer ${process.env.LIGDICASH_API_TOKEN}`,
        Accept: "application/json",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        commande: {
          invoice: {
            items: [
              {
                name: "Pro Subscription",
                description: "Premium access for 1 month",
                quantity: 1,
                unit_price: 5000,
                total_price: 5000,
              },
            ],
            total_amount: 5000,
            devise: "XOF",
            description: "Pro Subscription — January 2025",
            customer: "",
            customer_firstname: "Amadou",
            customer_lastname: "Diallo",
            customer_email: "amadou@example.com",
            external_id: "",
            otp: "",
          },
          store: { name: "MyApp", website_url: "https://myapp.com" },
          actions: {
            cancel_url: "https://myapp.com/payment/cancel",
            return_url: "https://myapp.com/payment/success",
            callback_url: "https://myapp.com/api/callback/ligdicash",
          },
          custom_data: { transaction_id: "ORD-2025-00042" },
        },
      }),
    }
  );

  const data = await response.json();
  ```

  ```php PHP theme={null}
  $payload = [
    "commande" => [
      "invoice" => [
        "items" => [[
          "name" => "Pro Subscription",
          "description" => "Premium access for 1 month",
          "quantity" => 1,
          "unit_price" => 5000,
          "total_price" => 5000,
        ]],
        "total_amount" => 5000,
        "devise" => "XOF",
        "description" => "Pro Subscription — January 2025",
        "customer" => "",
        "customer_firstname" => "Amadou",
        "customer_lastname" => "Diallo",
        "customer_email" => "amadou@example.com",
        "external_id" => "",
        "otp" => "",
      ],
      "store" => ["name" => "MyApp", "website_url" => "https://myapp.com"],
      "actions" => [
        "cancel_url" => "https://myapp.com/payment/cancel",
        "return_url" => "https://myapp.com/payment/success",
        "callback_url" => "https://myapp.com/api/callback/ligdicash",
      ],
      "custom_data" => ["transaction_id" => "ORD-2025-00042"],
    ],
  ];

  $ch = curl_init("https://app.ligdicash.com/pay/v01/redirect/checkout-invoice/create");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Apikey: " . $_ENV["LIGDICASH_API_KEY"],
    "Authorization: Bearer " . $_ENV["LIGDICASH_API_TOKEN"],
    "Accept: application/json",
    "Content-Type: application/json",
  ]);

  $data = json_decode(curl_exec($ch), true);
  curl_close($ch);
  ```
</CodeGroup>

## Response

<ResponseField name="response_code" type="string">
  `"00"` if the invoice was created successfully, `"01"` on error.
</ResponseField>

<ResponseField name="token" type="string">
  Identifier of the transaction on the LigdiCash side. To be stored in your database — required to call `confirm`.
</ResponseField>

<ResponseField name="response_text" type="string">
  On success: the URL of the payment page to open for the customer. On failure: the error sub-code in the form `Echec (CodeXX)`.
</ResponseField>

<ResponseField name="wiki" type="string">
  URL to the documentation of error codes for this endpoint. To consult when `response_code` is `"01"`.
</ResponseField>

## Response example

<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>

## Related pages

* [Redirect the customer](/en/payment-api/hosted-payin/redirect-customer) — how to open `response_text`
* [Common pitfalls](/en/payment-api/hosted-payin/common-pitfalls) — empty `customer`, blocked iframe
* [The transaction\_id pattern](/en/concepts/transaction-id-pattern) — best practices for `custom_data`
