# Create Invoice

## Create invoice

Invoice can be created in two methods manual or using API this instruction is show how to create API using APIs

{% tabs %}
{% tab title="Curl" %}

```sh
curl -X POST https://api.nebulox.io/api/invoice/create \
-H "Content-Type: application/json" \
-d '{
  "apiKey": "YOUR_API_KEY",
  "price": "100",
  "orderId": "YOUR_ORDER_ID",
  "baseCurrency": "usd",
  "coinSymbol": "BTC",
  "networkName": "Bitcoin",
  "amount": "0.0025"
}'
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

axios.post('https://api.nebulox.io/api/invoice/create', {
    apiKey: 'YOUR_API_KEY',
    price: '100',
    orderId: 'YOUR_ORDER_ID',
    baseCurrency: 'usd',
    coinSymbol: 'BTC',
    networkName: 'Bitcoin'
    amount:'0.0025'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.error(error);
  });
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$apiUrl = 'https://api.nebulox.io/api/invoice/create';
$data = array(
    'apiKey' => 'YOUR_API_KEY',
    'price' => '100',
    'orderId' => 'YOUR_ORDER_ID',
    'baseCurrency' => 'usd',
    'coinSymbol' => 'BTC',
    'networkName' => 'Bitcoin',
    'amount' => '0.0025'
);

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

$response = curl_exec($ch);

if(curl_errno($ch)){
    echo 'Curl error: ' . curl_error($ch);
}

curl_close($ch);

echo $response;
?>

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = 'https://api.nebulox.io/api/invoice/create'
data = {
    'apiKey': 'YOUR_API_KEY',
    'price': '100',
    'orderId': 'YOUR_ORDER_ID',
    'baseCurrency': 'usd',
    'coinSymbol': 'BTC',
    'networkName': 'Bitcoin',
    'amount': '0.0025'
}

headers = {'Content-Type': 'application/json'}

try:
    response = requests.post(url, data=json.dumps(data), headers=headers)
    response.raise_for_status()
    print(response.json())
except requests.exceptions.RequestException as e:
    print(f"Error: {e}")
```

{% endtab %}
{% endtabs %}

## Make your first request

To make your first request, send an authenticated request to the create invoice endpoint. This will create an invoice, which is nice.

## Creating invoice

## Create Invoice.

<mark style="color:green;">`POST`</mark> `https://api.nebulox.io/api/invoice/create`

This method creates an invoice with the specified parameters

#### Request Body

| Name                                      | Type   | Description                                                         |
| ----------------------------------------- | ------ | ------------------------------------------------------------------- |
| apikey<mark style="color:red;">\*</mark>  | string | The genrated API key                                                |
| price<mark style="color:red;">\*</mark>   | number | the price amount in fiat                                            |
| orderId<mark style="color:red;">\*</mark> | string | Merchant's order unique identifier. It will be used to track order. |
| baseCurrency                              | string | your base currency                                                  |
| coinSymbol                                | string | Your order payment coin                                             |
| networkName                               | string | Your order payment network                                          |
| amount<mark style="color:red;">\*</mark>  | number | Order's amount.                                                     |

{% tabs %}
{% tab title="201: Created " %}
{% code fullWidth="false" %}

```json
{
  "message": "Operation was successful.",
  "result": {
      "price": 10,
      "orderId": "Nebulox-1234",
      "status": "PENDING",
      "gatewayId": "41c6fe17-b72f-4923-9da2-dc7a91173e73",
      "userId": "d6646cf8-0b65-4d7d-ab2b-02e8dcd1ede3",
      "addressId": null,
      "amount": 0.0025,
      "coinId": null,
      "networkId": null,
      "info": null,
      "id": "5c5a7933-51ad-4542-b0b6-9157552e8230",
      "created_at": "2023-02-13T12:18:00.672Z",
      "updated_at": "2023-02-13T12:18:00.672Z",
      "url": "https://nebulox.io/invoice/5c5a7933-51ad-4542-b0b6-9157552e8230"
  },
  "meta": {}
}
```

{% endcode %}
{% endtab %}

{% tab title="406: Not Acceptable " %}

```json
{
    "message": "This gateway is not active",
    "result": [],
    "meta": {}
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}

* **`baseCurrency`** must be in \[EUR, USD].
* **`coinSymbol`** must be in \[BTC,LTC,USDT,TRX,DOGE].
* **`networkName`** must be in \[Bitcoin,Litecoin,Tron,Dogecoin].
* The **`price`** field should remain blank if you enter a value for the **`amount`**.
* The **`amount`** field should remain blank if you enter a value for the **`Price`**.
* If you enter a value for the **`amount`** field you must fill the **`coinSymbol`** too.
  {% endhint %}


---

# 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://docs.nebulox.io/reference/api-reference/create-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.
