> For the complete documentation index, see [llms.txt](https://docs.trybit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trybit.com/pt/referencia-da-api-v2/create-invoice.md).

# Criação de fatura

O método permite criar uma fatura para um cliente usando uma solicitação POST.

Para criar uma fatura, precisa de enviar uma requisição POST.

### O que o método permite fazer

* Cria uma fatura única
* Retorna um link de pagamento ou detalhes de pagamento
* Permite-lhe passar dados adicionais

### Endpoint

<mark style="color:verde;">`POST`</mark> `https://api.trybit.com/v2/invoice/create`

### Cabeçalhos

| Nome                                               | Tipo   | Exemplo                             | Descrição            |
| -------------------------------------------------- | ------ | ----------------------------------- | -------------------- |
| Autorização<mark style="color:vermelho;">\*</mark> | string | Token eyJ0eXAiOiJK<...>4npi1ksS8tSY | Chave API do projeto |

### Corpo da requisição

Parâmetros principais

| Nome                                            | Tipo   | Exemplo           | Descrição                                                                                                                                                                                                                                                                                                                 |
| ----------------------------------------------- | ------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| shop\_id<mark style="color:vermelho;">\*</mark> | string | NGpD44<...>KXRdQ  | Identificador único da loja da conta pessoal                                                                                                                                                                                                                                                                              |
| amount<mark style="color:vermelho;">\*</mark>   | float  | 100               | Montante do pagamento em USD                                                                                                                                                                                                                                                                                              |
| currency                                        | string | USD               | <p>Moedas de conversão disponíveis:</p><p></p><p>USD, EUR, GBP, JPY, CNY, RUB, INR, AUD, CAD, SGD, HKD, TRY, AED, THB, MYR, PHP, IDR, VND, KZT, UAH, BYN, UZS, KGS, AMD, AZN, ARS, BOB, BRL, GYD, COP, PYG, PEN, SRD, UYU, CLP, BZD, GTQ, HNL, CRC, MXN, NIO, PAB, DOP, HTG. </p><p></p><p>A moeda predefinida é USD.</p> |
| order\_id                                       | string | ORDER\_93223      | Número de fatura personalizado no sistema externo                                                                                                                                                                                                                                                                         |
| email                                           | string | <email@gmail.com> | Endereço de email do pagador                                                                                                                                                                                                                                                                                              |

Parâmetros opcionais

**add\_fields** — um objeto para passar dados adicionais

| Nome        | Tipo | Exemplo                                                                     | Descrição             |
| ----------- | ---- | --------------------------------------------------------------------------- | --------------------- |
| add\_fields | dict | <p>{time\_to\_pay: {</p><p> "hours": 24, "minutes": 0</p><p> },</p><p>}</p> | Parâmetros adicionais |

{% hint style="warning" %}
Os parâmetros opcionais devem ser passados dentro do **add\_fields** objeto.
{% endhint %}

<table data-full-width="false"><thead><tr><th width="215">Nome</th><th width="175.8984375">Tipo</th><th width="193.6492919921875">Exemplo</th><th width="196">Descrição</th></tr></thead><tbody><tr><td>time_to_pay</td><td>dict</td><td>{ "hours": 24, "minutes": 0 }</td><td>Validade da fatura</td></tr><tr><td>available_currencies</td><td>list[string]</td><td>[ "USDT_TRC20", "ETH", "BTC" ]</td><td><p>Moedas de pagamento disponíveis:<br></p><p>BTC, LTC, TRX, SOL, TON, BNB, ETH, ETH_ARB, ETH_BASE, ETH_OPT, USDT_ARB, USDT_BSC, USDT_ERC20, USDT_OPT, USDT_SOL, USDT_TON, USDT_TRC20, USDC_ARB, USDC_BASE, USDC_BSC, USDC_ERC20, USDC_OPT, USDC_SOL, DAI_ARB, DAI_BASE, DAI_BSC, DAI_ERC20, DAI_OPT, USDD_TRC20, PYUSD_ERC20, PYUSD_SOL, XAUT_ERC20, XAUT_TON, ARB_ARB, OP_OPT, PEPE_BSC, PEPE_ERC20, SHIB_BSC, SHIB_ERC20, TRUMP_SOL</p></td></tr><tr><td>criptomoeda</td><td>string</td><td>ETH</td><td><p>Selecionar a moeda de pagamento em nome do utilizador.<br></p><p>Se uma moeda for especificada, a página de pagamento apresentará os detalhes de pagamento sem uma opção de seleção de moeda.<br></p><p>O endereço e o montante também serão devolvidos na resposta da API.</p></td></tr></tbody></table>

### Exemplos de pedido

Estes exemplos mostram como enviar um pedido para criar uma fatura. Note que deve fornecer a sua chave API no `Autorização` cabeçalho para autorizar o pedido com êxito.

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

```bash
curl -X POST \\
     -H "Authorization: Token <API KEY>" \\
     -H "Content-Type: application/json" \\
     -d '{"amount": 100, "shop_id": <SHOP_ID>, "currency": "USD"}' \\
     "https://api.trybit.com/v2/invoice/create"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.trybit.com/v2/invoice/create"
headers = {
    "Authorization": "Token <API KEY>",
    "Content-Type": "application/json"
}

data = {
    "amount": 100,
    "shop_id": "xBAivfPIbskwuEWj",
    "currency": "USD"
}

response = requests.post(url, headers=headers, json=data)

if response.status_code == 200:
    print("Sucesso:", response.json())
else:
    print("Falha:", response.status_code, response.text)
```

{% endtab %}

{% tab title="JavaScript " %}
{% code title="Fetch.js:" %}

```javascript
const url = 'https://api.trybit.com/v2/invoice/create';
const headers = new Headers({
    'Authorization': 'Token <API KEY>',
    'Content-Type': 'application/json'
});
const data = {
    amount: 100,
    shop_id: 'xBAivfPIbskwuEWj',
    currency: 'USD'
};

fetch(url, {
    method: 'POST',
    headers,
    body: JSON.stringify(data)
})
.then(response => {
    if (response.ok) {
        return response.json();
    } else {
        return Promise.reject('Erro de criação');
    }
})
.then(data => {
    console.log('Sucesso:', data);
})
.catch(error => {
    console.error('Falha:', error);
});
```

{% endcode %}

{% code title="Ajax.js:" %}

```javascript
$.ajax({
    url: 'https://api.trybit.com/v2/invoice/create',
    method: 'POST',
    headers: {
        'Authorization': 'Token <API KEY>',
        'Content-Type': 'application/json'
    },
    data: JSON.stringify({
        amount: 100,
        shop_id: 'xBAivfPIbskwuEWj',
        currency: 'USD'
    }),
    success: function(data) {
        console.log('Sucesso:', data);
    },
    error: function(error) {
        console.error('Falha:', error);
    }
});
```

{% endcode %}

{% code title="Axios.js:" %}

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

const url = 'https://api.trybit.com/v2/invoice/create';
const headers = {
    'Authorization': 'Token <API KEY>',
    'Content-Type': 'application/json'
};
const data = {
    amount: 100,
    shop_id: 'xBAivfPIbskwuEWj',
    currency: 'USD'
};

axios.post(url, data, { headers })
    .then(response => {
        console.log('Sucesso:', response.data);
    })
    .catch(error => {
        console.error('Falha:', error);
    });
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code title="cURL:" %}

```php
<?php
$url = "https://api.trybit.com/v2/invoice/create";
$headers = array(
    "Authorization: Token <API KEY>",
    "Content-Type: application/json"
);

$data = array(
    "amount" => 100,
    "shop_id" => "xBAivfPIbskwuEWj",
    "currency" => "USD"
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if($http_code == 200){
    echo "Sucesso: " . $response;
} else {
    echo "Falha: " . $http_code . " " . $response;
}

curl_close($ch);
?>
```

{% endcode %}

{% code title="File\_get\_contents:" %}

```php
<?php
$url = "https://api.trybit.com/v2/invoice/create";
$headers = array(
    "http" => array(
        "header" => "Authorization: Token <API KEY>\r\n" .
                    "Content-Type: application/json\r\n",
        "method" => "POST",
        "content" => json_encode(array(
            "amount" => 100,
            "shop_id" => "xBAivfPIbskwuEWj",
            "currency" => "USD"
        )),
    ),
);

$context  = stream_context_create($headers);
$response = file_get_contents($url, false, $context);
$http_code = $http_response_header[0];

if(strpos($http_code, "200")){
    echo "Sucesso: " . $response;
} else {
    echo "Falha: " . $http_code . " " . $response;
}
?>
```

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

### Exemplos de resposta

Um pedido bem-sucedido devolve uma resposta com o estado `sucesso` e um `resultado` objeto.

{% tabs %}
{% tab title="200: OK – A fatura foi criada" %}

```json
{
    "status": "success",
    "result": {
        "uuid": "INV-89UX09KA",
        "created": "2026-01-27 09:03:58.958133",
        "address": "0xb07427fc721C23674c48233ffE93D3846ee58B63",
        "expiry_date": "2026-01-28 09:03:57.493361",
        "side_commission": "client",
        "side_commission_service": "merchant",
        "type_payments": "crypto",
        "amount": 0.034187,
        "amount_usd": 100.0,
        "amount_in_fiat": 100.0,
        "fee": 1.499999996212864e-06,
        "fee_usd": 0.0,
        "service_fee": 0.00065,
        "service_fee_usd": 1.9,
        "fiat_currency": "USD",
        "status": "created",
        "is_email_required": false,
        "link": "https://pay.trybit.com/89UX09KA",
        "invoice_id": null,
        "currency": {
            "id": 3,
            "code": "ETH",
            "fullcode": "ETH",
            "network": {
                "code": "ERC20",
                "id": 3,
                "icon": "https://cdn.trybit.com/img/network/ERC.svg",
                "fullname": "Ethereum"
            },
            "name": "Ethereum",
            "is_email_required": false,
            "stablecoin": false,
            "icon_base": "https://cdn.trybit.com/img/currency/ETH.svg",
            "icon_network": "https://cdn.trybit.com/img/currency/ETH.svg",
            "icon_qr": "https://cdn.trybit.com/img/stroke/ETH_STROKE.svg",
            "order": 9
        },
        "project": {
            "id": 1,
            "name": "Test",
            "fail": "https://test.com/failed-payment",
            "success": "https://test.com/successful-payment",
            "logo": "https://static.trybit.com/logo/L52hWwjt98uYtUF91765782359.174416.jpg"
        },
        "test_mode": false
    }
}
```

{% endtab %}
{% endtabs %}

### Parâmetros da resposta

O `resultado` objeto contém:

<table data-full-width="false"><thead><tr><th>Nome</th><th>Tipo</th><th width="198.35498046875">Exemplo</th><th>Descrição</th></tr></thead><tbody><tr><td>uuid</td><td>string</td><td>INV-89UX09KA</td><td>Identificador único da fatura com o prefixo INV</td></tr><tr><td>created</td><td>string</td><td>2026-01-01 12:00:00.000000</td><td>Hora de criação da fatura no formato UTC+0: YYYY-MM-DD HH:MI:SS.FFFFFF</td></tr><tr><td>address</td><td>string</td><td>0xb07427&#x3C;...>E93D3846ee58B63</td><td><p>Endereço de pagamento</p><p></p><p>Só será preenchido se for selecionada uma criptomoeda para pagamento.</p><p></p><p>Para selecionar a moeda em nome do cliente, especifique uma moeda suportada pelo projeto em <code>add_fields.cryptocurrency</code>.</p></td></tr><tr><td>expiry_date</td><td>string</td><td>2026-01-02 12:00:00.000000</td><td><p>Data de expiração da fatura no formato UTC+0: YYYY-MM-DD HH:MI:SS.FFFFFF.</p><p></p><p>Após o tempo de expiração, o estado da fatura mudará para <code>cancelada</code> se o pagamento não tiver sido recebido.</p></td></tr><tr><td>side_commission</td><td>string</td><td>cliente</td><td>Pagador da taxa de transferência</td></tr><tr><td>side_commission_cc</td><td>string</td><td>cliente</td><td>Pagador da taxa de serviço</td></tr><tr><td>amount</td><td>float</td><td>0.033366</td><td>Montante da fatura na criptomoeda selecionada</td></tr><tr><td>amount_usd</td><td>float</td><td>100.0</td><td>Montante da fatura em USD</td></tr><tr><td>amount_in_fiat</td><td>float</td><td>100.0</td><td>Montante da fatura na moeda de criação (depende do <code>currency</code> parâmetro)</td></tr><tr><td>fee</td><td>float</td><td>4.500000159168849e-06</td><td>Taxa de transferência da fatura</td></tr><tr><td>fee_usd</td><td>float</td><td>0.01</td><td>Taxa de transferência da fatura em USD</td></tr><tr><td>service_fee</td><td>float</td><td>0.000634</td><td>Taxa de serviço</td></tr><tr><td>service_fee_usd</td><td>float</td><td>1.9</td><td>Taxa de serviço em USD</td></tr><tr><td>fiat_currency</td><td>string</td><td>USD</td><td>Código da moeda fiduciária em que a fatura foi criada</td></tr><tr><td>status</td><td>string</td><td>created</td><td><p>Estado da fatura</p><p></p><p>Quando é enviada uma requisição de criação de fatura, o estado é sempre <code>created</code>.</p><p></p><p>Outros estados possíveis: <code>paid</code> (paga), <code>partial</code> (parcialmente paga), <code>overpaid</code> (paga em excesso), e <code>cancelada</code> (cancelada).</p></td></tr><tr><td>is_email_required</td><td>bool</td><td>false</td><td>Parâmetro para exigir o email do pagador na fatura</td></tr><tr><td>link</td><td>string</td><td>pay.trybit.com/89UX09KA</td><td>Ligação para a página da fatura</td></tr><tr><td>currency</td><td>dict</td><td><p>"currency": {</p><p>            "id": 3,</p><p>            "code": "ETH",</p><p>            "fullcode": "ETH",</p><p>            "network": {</p><p>                "code": "ERC20",</p><p>                "id": 3,</p><p>                "icon": "https://cdn.trybit.com/img/network/ERC.svg",</p><p>                "fullname": "Ethereum"</p><p>            },</p><p>            "name": "Ethereum",</p><p>            "is_email_required": false,</p><p>            "stablecoin": false,</p><p>            "icon_base": "https://cdn.trybit.com/img/currency/ETH.svg",</p><p>            "icon_network": "https://cdn.trybit.com/img/currency/ETH.svg",</p><p>            "icon_qr": "https://cdn.trybit.com/img/stroke/ETH_STROKE.svg",</p><p>            "order": 9</p><p>        }</p></td><td><p>Objeto da criptomoeda selecionada na fatura.</p><p></p><p>Também contém o <code>network</code> objeto — informação sobre a rede da moeda selecionada.</p></td></tr><tr><td>project</td><td>dict</td><td><p>"project": {</p><p>            "id": 0,</p><p>            "name": "MyShop",</p><p>            "fail": "https://test.com/failed-payment",</p><p>            "success": "https://test.com/successful-payment",</p><p>            "logo": "https://static.trybit.com/logo/logo.jpg"</p><p>        }v</p></td><td>Objeto que contém informação do projeto</td></tr><tr><td>test_mode</td><td>bool</td><td>false</td><td>Assinatura da fatura de teste</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.trybit.com/pt/referencia-da-api-v2/create-invoice.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
