# Create an invoice

### URI

&#x20;<mark style="color:blue;background-color:blue;">**POST**</mark>&#x20;

```
https://api.tryduplo.com/v1/merchants/invoice
```

### Parameters

#### Header

<table data-header-hidden><thead><tr><th width="249"></th><th></th></tr></thead><tbody><tr><td><strong>Authorization</strong><br><code>string</code></td><td>set value to <code>Bearer SECRET_KEY</code></td></tr></tbody></table>

#### Body Param

<table data-header-hidden><thead><tr><th width="250"></th><th></th></tr></thead><tbody><tr><td><strong>recipient_ref</strong><br><code>string</code> <mark style="color:red;"><code>required</code></mark></td><td>Recipient  reference</td></tr><tr><td><strong>due_date</strong><br><code>string</code> <mark style="color:red;"><code>required</code></mark></td><td>Invoice due dare</td></tr><tr><td><strong>items</strong><br><code>array</code> <mark style="color:red;"><code>required</code></mark></td><td><p>The items array specifies the content in the invoice e.g:</p><pre class="language-json"><code class="lang-json">"items": [
        {
            "name": "Bananas",
            "quantity": "50",
            "unit_price": "100"
        },
        {
            "name": "Apple",
            "quantity": "20",
            "unit_price": "100"
        }
    ]
</code></pre></td></tr><tr><td><strong>shipping_fee</strong><br><code>string</code> <mark style="color:red;"><code>required</code></mark></td><td>Shipping fee</td></tr><tr><td><strong>business_id</strong><br><code>string</code> <mark style="color:red;"><code>required</code></mark></td><td>Bussiness id</td></tr><tr><td><strong>discount</strong><br><code>object</code><mark style="color:red;"><code>required</code></mark></td><td><p>The discount contains the offered discount(s) for the invoice. e.g:</p><pre class="language-json"><code class="lang-json">"discount": {
        "type": "amount",
        "value": "500"
    }
</code></pre></td></tr><tr><td><strong>tax</strong><br><code>object</code><mark style="color:red;"><code>required</code></mark></td><td><p>Tax object. e.g:</p><pre class="language-json"><code class="lang-json">"tax": {
        "type": "percentage",
        "value": 10,
        "description": "sample description"
    }
</code></pre></td></tr><tr><td><strong>note</strong><br><code>string</code></td><td>Invoice notes</td></tr><tr><td><strong>status</strong><br><code>string</code></td><td>Invoice status, this can either be <code>invoice</code> or <code>draft</code>  the default value <code>invoice</code>  </td></tr><tr><td><strong>invoice_number</strong><br><code>string</code></td><td>Invoice number</td></tr></tbody></table>

### Sample request

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl --location --request POST 'https://api.tryduplo.com/v1/merchants/invoice' \
--header 'Authorization: Bearer dp_live_856879df3e6ecdb14a918e24bba6d480e0564a4eabfdba938fc23b820ac905e54bac25a71dbcdef66c97b8c72ca7e16cf03a576857261f2f35ca5024620b14268823a7d78922cfdd97cefc61050139fd92a7a0c5840e016050552ccadbbec642d2ff8d35a09225c7ec4fd1e347b' \
--header 'Content-Type: application/json' \
--data-raw '{
    "business_id": "45ee9f61-dd52-4f51-bccb-8ea711760", 
    "recipient": "cus_GnXkWlEOtw",
    "due_date": "2022-06-12",
    "items": [
        {
            "name": "Banana",
            "quantity": "50",
            "unit_price": "100"
        },
        {
            "name": "Apple",
            "quantity": "20",
            "unit_price": "100"
        }
    ],
    "shipping_fee": "100",
    "discount": {
        "type": "amount",
        "value": "500"
    },
    "tax": {
        "type": "percentage",
        "value": 10,
        "description": "sample description t"
    },
    "note": "sample note for creating this invoice for another test",
    "status": "invoice"
}'
```

{% endcode %}
{% endtab %}

{% tab title="Node" %}
{% code overflow="wrap" lineNumbers="true" %}

```javascript
var axios = require('axios');
var data = JSON.stringify({
  "business_id": "45ee9f61-dd52-4f51-bccb-8e5711760",
  "recipient": "cus_GnXkWKAlOtw",
  "due_date": "2022-06-12",
  "items": [
    {
      "name": "kofo Onalaja dr",
      "quantity": "50",
      "unit_price": "100"
    },
    {
      "name": "sample name 55",
      "quantity": "20",
      "unit_price": "100"
    }
  ],
  "shipping_fee": "100",
  "discount": {
    "type": "amount",
    "value": "500"
  },
  "tax": {
    "type": "percentage",
    "value": 10,
    "description": "sample description t"
  },
  "note": "sample note for creating this invoice for another test",
  "status": "invoice"
});

var config = {
  method: 'post',
  url: 'https://api.tryduplo.com/v1/merchants/invoice',
  headers: { 
    'Authorization': 'Bearer dp_live_856879df3e6ecdb14a918e24bba6d480e4eabfdba938fc23b820ac905e54bac25a71dbcdef66c97b8c72ca7e16cf03a576857261f2f16f5335ca5024620b14268823a7d78922cfdd97cefc61050139fd92a7a0c5840e016050552ccadbbec642d2ff8d35a09225c7ec4fd1e347b', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code overflow="wrap" lineNumbers="true" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.tryduplo.com/v1/merchants/invoice',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "business_id": "45e9f61-dd52-4f51-bccb-8e59a711760", 
    "recipient": "cus_GnXkWKEOtw",
    "due_date": "2022-06-12",
    "items": [
        {
            "name": "kofo Onalaja dr",
            "quantity": "50",
            "unit_price": "100"
        },
        {
            "name": "sample name 55",
            "quantity": "20",
            "unit_price": "100"
        }
    ],
    "shipping_fee": "100",
    "discount": {
        "type": "amount",
        "value": "500"
    },
    "tax": {
        "type": "percentage",
        "value": 10,
        "description": "sample description t"
    },
    "note": "sample note for creating this invoice for another test",
    "status": "invoice"
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer dp_live_856879df3e6ecdb14a918e24bba6d480e0564a4eabfdba938fc23b820ac905e54bac25a71dbcdef66c97b8c72ca7e16cf03a576857261f2f16f5335ca5024620b14268823a7d78922cfdd97cefc61050139fd92a7a0c5840e0160cadbbec642d2ff8d35a09225c7ec4fd1e347b',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endcode %}
{% endtab %}
{% endtabs %}

### Duplo Response

```json
{
    "data": {
        "id": "c1f9df9b-8dd3-4b43-aee9-ecc55257a2",
        "invoice_number": "7868993647",
        "title": "Invoice for Mwenda Deno",
        "recipient": "wal_ZKmo7StVZMrZ",
        "due_date": "2022-05-25T00:00:00.000Z",
        "items": [
            {
                "name": "Bananna",
                "total": 7510.5,
                "quantity": 15,
                "unit_price": 500.7
            },
            {
                "name": "Apple",
                "total": 3118.6,
                "quantity": 31,
                "unit_price": 100.6
            }
        ],
        "shipping_fee": 670.9,
        "discount": {
            "type": "amount",
            "value": 400.5
        },
        "tax": {
            "type": "percentage",
            "value": 10.2,
            "description": "sample description"
        },
        "note": "sample note",
        "status": "draft",
        "public_id": "oXFpXwUQIwoF8zOabzKLjEHv4kZTydNb",
        "account": {
            "provider": {
                "id": "wema",
                "default": true,
                "prefixes": [
                    "222",
                    "919",
                    "888"
                ],
                "bank_code": "111",
                "bank_name": "Wema Bank",
                "is_prefix": true,
                "credentials": {}
            },
            "account_ref": "act_MR1sJ8bh2YlK",
            "account_number": "8880000363"
        },
        "payment": null,
        "created_at": "2022-05-25T15:19:05.650Z",
        "update_at": "2022-05-25T15:19:05.651Z",
        "business_id": "80efed51-96fc-43c7-9075-9f78877d26bc"
    },
    "errors": {},
    "message": "Request successful"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.tryduplo.com/duplo-api-documentation/payment-apis/collect-payments/invoices/create-an-invoice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
