# Create an invoice

### Attributes

<table><thead><tr><th>Attribute</th><th width="150">Type</th><th width="183">Description</th><th>Required</th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody><tr><td>external_id</td><td>string</td><td><p>ID of your choice (typically the unique identifier of an invoice in your system).</p><p></p><p>example: INV001/V/2022</p></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>amount</td><td>number</td><td>Amount on the invoice</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>description</td><td>string</td><td>Description of invoice</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></tbody></table>

for more information,[here](https://developers.xendit.co/api-reference/#create-invoice)

<mark style="color:green;">`POST`</mark> `https://us-central1-appgregator.cloudfunctions.net/xendit/invoices/`

#### Query Parameters

| Name                                               | Type   | Description                  |
| -------------------------------------------------- | ------ | ---------------------------- |
| name<mark style="color:red;">\*</mark>             | String | ft-4                         |
| connection\_name<mark style="color:red;">\*</mark> | String | xendit-sanbox-1              |
| callback\_url<mark style="color:red;">\*</mark>    | String | https://example.com/callback |

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| x-api-key<mark style="color:red;">\*</mark> | String | U2Fsd...    |

{% tabs %}
{% tab title="201: Created " %}
```javascript
{
    "id": "62f00ac409accd62c85673c4",
    "external_id": "INV0048/VIII/2022",
    "user_id": "6279ce4495d10c9afc3171b8",
    "status": "PENDING",
    "merchant_name": "aplikasi keuangan",
    "merchant_profile_picture_url": "https://du8nwjtfkinx.cloudfront.net/xendit.png",
    "amount": 8500000,
    "description": "Invoice Demo #INV0048",
    "expiry_date": "2022-08-08T18:56:04.164Z",
    "invoice_url": "https://checkout-staging.xendit.co/web/62f00ac409accd62c85673c4",
    "available_banks": [
        {
            "bank_code": "MANDIRI",
            "collection_type": "POOL",
            "transfer_amount": 8500000,
            "bank_branch": "Virtual Account",
            "account_holder_name": "APLIKASI KEUANGAN",
            "identity_amount": 0
        },
        {
            "bank_code": "BRI",
            "collection_type": "POOL",
            "transfer_amount": 8500000,
            "bank_branch": "Virtual Account",
            "account_holder_name": "APLIKASI KEUANGAN",
            "identity_amount": 0
        },
        {
            "bank_code": "BNI",
            "collection_type": "POOL",
            "transfer_amount": 8500000,
            "bank_branch": "Virtual Account",
            "account_holder_name": "APLIKASI KEUANGAN",
            "identity_amount": 0
        },
        {
            "bank_code": "PERMATA",
            "collection_type": "POOL",
            "transfer_amount": 8500000,
            "bank_branch": "Virtual Account",
            "account_holder_name": "APLIKASI KEUANGAN",
            "identity_amount": 0
        },
        {
            "bank_code": "BCA",
            "collection_type": "POOL",
            "transfer_amount": 8500000,
            "bank_branch": "Virtual Account",
            "account_holder_name": "APLIKASI KEUANGAN",
            "identity_amount": 0
        }
    ],
    "available_retail_outlets": [
        {
            "retail_outlet_name": "ALFAMART"
        },
        {
            "retail_outlet_name": "INDOMARET"
        }
    ],
    "available_ewallets": [
        {
            "ewallet_type": "OVO"
        },
        {
            "ewallet_type": "DANA"
        },
        {
            "ewallet_type": "SHOPEEPAY"
        },
        {
            "ewallet_type": "LINKAJA"
        }
    ],
    "available_direct_debits": [
        {
            "direct_debit_type": "DD_BRI"
        }
    ],
    "available_paylaters": [],
    "should_exclude_credit_card": false,
    "should_send_email": false,
    "success_redirect_url": "https://projeq.id/?status=success&external_id=INV0035/VIII/2022",
    "failure_redirect_url": "https://projeq.id/?status=failure&external_id=INV0035/VIII/2022",
    "created": "2022-08-07T18:56:04.761Z",
    "updated": "2022-08-07T18:56:04.761Z",
    "currency": "IDR",
    "customer": {
        "given_names": "John",
        "surname": "Doe",
        "email": "johndoe@example.com",
        "mobile_number": "+6287774441111",
        "addresses": [
            {
                "city": "Jakarta Selatan",
                "country": "Indonesia",
                "postal_code": "12345",
                "state": "Daerah Khusus Ibukota Jakarta",
                "street_line1": "Jalan Makan",
                "street_line2": "Kecamatan Kebayoran Baru"
            }
        ]
    },
    "project_name": "ft-4",
    "connection_name": "xendit-sanbox-1",
    "callback_url": "http://localhost:5001/appgregator/us-central1/xendit/invoices/callback/success"
}
```
{% endtab %}
{% endtabs %}

<details>

<summary>Body JSON</summary>

```
{
  "external_id": "INV0048/VIII/2022",
  "amount": 8500000,
  "description": "Invoice Demo #INV0048",
  "invoice_duration": 86400,
  "success_redirect_url" : "https://projeq.id/?status=success&external_id=INV0035/VIII/2022",
  "failure_redirect_url" : "https://projeq.id/?status=failure&external_id=INV0035/VIII/2022",
  "customer": {
    "given_names": "John",
    "surname": "Doe",
    "email": "johndoe@example.com",
    "mobile_number": "+6287774441111",
    "addresses": [
      {
        "city": "Jakarta Selatan",
        "country": "Indonesia",
        "postal_code": "12345",
        "state": "Daerah Khusus Ibukota Jakarta",
        "street_line1": "Jalan Makan",
        "street_line2": "Kecamatan Kebayoran Baru"
      }
    ]
  }
}
```

</details>

{% tabs %}
{% tab title="cURL" %}
```shell
curl --location --request POST 'https://us-central1-appgregator.cloudfunctions.net/xendit/invoices?name=ft-4&connection_name=xendit-sanbox-1' \
--header 'x-api-key: U2Fsd...' \
--header 'Content-Type: application/json' \
--data-raw '{
  "external_id": "INV0055/VIII/2022",
  "amount": 8500000,
  "description": "Invoice Demo #INV0055",
  "invoice_duration": 86400,
  "success_redirect_url" : "https://projeq.id/?status=success&external_id=INV0035/VIII/2022",
  "failure_redirect_url" : "https://projeq.id/?status=failure&external_id=INV0035/VIII/2022",
  "customer": {
    "given_names": "John",
    "surname": "Doe",
    "email": "johndoe@example.com",
    "mobile_number": "+6287774441111",
    "addresses": [
      {
        "city": "Jakarta Selatan",
        "country": "Indonesia",
        "postal_code": "12345",
        "state": "Daerah Khusus Ibukota Jakarta",
        "street_line1": "Jalan Makan",
        "street_line2": "Kecamatan Kebayoran Baru"
      }
    ]
  }
}'
```
{% endtab %}

{% tab title="NodeJS - Axios" %}
```javascript
var axios = require('axios');
var data = JSON.stringify({
  "external_id": "INV0055/VIII/2022",
  "amount": 8500000,
  "description": "Invoice Demo #INV0055",
  "invoice_duration": 86400,
  "success_redirect_url": "https://projeq.id/?status=success&external_id=INV0035/VIII/2022",
  "failure_redirect_url": "https://projeq.id/?status=failure&external_id=INV0035/VIII/2022",
  "customer": {
    "given_names": "John",
    "surname": "Doe",
    "email": "johndoe@example.com",
    "mobile_number": "+6287774441111",
    "addresses": [
      {
        "city": "Jakarta Selatan",
        "country": "Indonesia",
        "postal_code": "12345",
        "state": "Daerah Khusus Ibukota Jakarta",
        "street_line1": "Jalan Makan",
        "street_line2": "Kecamatan Kebayoran Baru"
      }
    ]
  }
});

var config = {
  method: 'post',
  url: 'https://us-central1-appgregator.cloudfunctions.net/xendit/invoices?name=ft-4&connection_name=xendit-sanbox-1',
  headers: { 
    'x-api-key': 'U2Fsd...', 
    'Content-Type': 'application/json'
  },
  data : data
};

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

```
{% endtab %}

{% tab title="PHP - cURL" %}
```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://us-central1-appgregator.cloudfunctions.net/xendit/invoices?name=ft-4&connection_name=xendit-sanbox-1,
  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 =>'{
  "external_id": "INV0048/VIII/2022",
  "amount": 8500000,
  "description": "Invoice Demo #INV0048",
  "invoice_duration": 86400,
  "success_redirect_url" : "https://projeq.id/?status=success&external_id=INV0035/VIII/2022",
  "failure_redirect_url" : "https://projeq.id/?status=failure&external_id=INV0035/VIII/2022",
  "customer": {
    "given_names": "John",
    "surname": "Doe",
    "email": "johndoe@example.com",
    "mobile_number": "+6287774441111",
    "addresses": [
      {
        "city": "Jakarta Selatan",
        "country": "Indonesia",
        "postal_code": "12345",
        "state": "Daerah Khusus Ibukota Jakarta",
        "street_line1": "Jalan Makan",
        "street_line2": "Kecamatan Kebayoran Baru"
      }
    ]
  }
}',
  CURLOPT_HTTPHEADER => array(
    'x-api-key: U2Fsd...',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```
{% endtab %}
{% endtabs %}
