# Generate Invoice

This endpoint enables you to generate a new invoice and obtain a payment URL for completing the transaction. By providing the required parameters in your request, you can specify the invoice amount and customize various options for the payment process.

## POST /payment/invoice

>

```json
{"openapi":"3.0.0","info":{"title":"Payments","version":"1.0.0"},"servers":[{"url":"https://api.oxapay.com/v1"}],"security":[],"paths":{"/payment/invoice":{"post":{"operationId":"generateInvoice","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["amount"],"properties":{"amount":{"type":"number","format":"decimal","description":"The amount for the payment. If the currency field is not filled, the amount should be specified in dollars. If the `currency` field is filled, the amount should correspond to the specified currency."},"currency":{"type":"string","description":"Specify the currency symbol if you want the invoice amount calculated with a specific currency. You can also generate invoices in fiat currencies."},"lifetime":{"type":"integer","description":"Set the expiration time for the payment link in minutes.","minimum":15,"maximum":2880,"default":60},"fee_paid_by_payer":{"type":"number","format":"decimal","description":"Specify whether the payer will cover the invoice commission. 1 indicates that the payer will pay the fee, while 0 indicates that the merchant will pay the fee.","minimum":0,"maximum":1,"default":"Merchant setting"},"under_paid_coverage":{"type":"number","format":"decimal","description":"Specify the acceptable inaccuracy in payment. Determines the maximum acceptable difference between the requested and paid amount.","minimum":0,"maximum":60,"default":"Merchant setting"},"to_currency":{"type":"string","description":"The currency symbol of the cryptocurrency you want to convert to. You can only convert paid crypto currencies to USDT."},"auto_withdrawal":{"type":"boolean","description":"1 indicates that the received currency will be sent to the address specified in your Address List on the Settings page and 0 indicates that the amount will be credited to your OxaPay balance."},"mixed_payment":{"type":"boolean","description":"Specify whether the payer can cover the remaining amount with another currency if they pay less than the invoice amount. 1 allows the user to pay the remainder with a different coin, while 0 doesn't allow it.","default":"Merchant setting"},"callback_url":{"type":"string","description":"The URL where payment information will be sent. Use this to receive notifications about the payment status."},"return_url":{"type":"string","description":"The URL where the payer will be redirected after a successful payment."},"email":{"type":"string","description":"Provide the payer's email address for reporting purposes."},"order_id":{"type":"string","description":"Specify a unique order ID for reference in your system."},"thanks_message":{"type":"string","description":"A thanks message that brief note displayed to the payer after a successful payment."},"description":{"type":"string","description":"Provide order details or any additional information that will be shown in different reports."},"sandbox":{"type":"boolean","description":"The sandbox field is a boolean that specifies whether the API request should operate in sandbox mode (test environment). Set it to true for testing and false for live transactions."}}}}}},"responses":{"200":{"description":"Successful operation","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"track_id":{"type":"string","description":"Unique identifier for the payment session in the OxaPay gateway. It is used to track the payment status, query details, and generate reports."},"payment_url":{"type":"string","description":"The URL of the payment page linked to the track ID. This link is shared with the payer to complete the payment process."},"expired_at":{"type":"integer","description":"The expiration timestamp (UNIX epoch) of the payment link. After this time, the link becomes invalid."},"date":{"type":"integer","description":"The creation timestamp (UNIX epoch) of the payment session."}}},"message":{"type":"string","description":"A message containing additional information about the result of the request."},"error":{"type":"object","description":"An object that provides details about any errors that occurred.","nullable":true,"properties":{"type":{"type":"string","description":"Type of the error"},"key":{"type":"string","description":"Key related to the error"},"message":{"type":"string","description":"Error message"}}},"status":{"type":"integer","description":"The status of the request response. Typically provided as a numeric code (e.g., 200 for success or other codes for errors)."},"version":{"type":"string","description":"The version of the API being used."}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{}},"message":{"type":"string","description":"A message containing additional information about the result of the request."},"error":{"type":"object","description":"An object that provides details about any errors that occurred.","nullable":true,"properties":{"type":{"type":"string","description":"Type of the error"},"key":{"type":"string","description":"Key related to the error"},"message":{"type":"string","description":"Error message"}}},"status":{"type":"integer","description":"The status of the request response. Typically provided as a numeric code (e.g., 200 for success or other codes for errors)."},"version":{"type":"string","description":"The version of the API being used."}}}}}}},"tags":["Invoice"],"parameters":[{"in":"header","name":"merchant_api_key","required":true,"schema":{"type":"string"},"description":"Your Merchant API Key for authentication and authorization."},{"in":"header","name":"Content-Type","required":true,"schema":{"type":"string","default":"application/json"}}]}}}}
```
