Creating invoice
POST /api/public/v1/invoices
Creates an invoice and returns the address the end user pays to, the amountCharged due in the chosen cryptocurrency, and expiresAt. amountBilled and billedCurrency are the price as you bill it; chargedCurrency and network are what the end user pays with; targetCurrency is the currency of the account that gets credited, your master account in that currency unless targetAccountId names a subaccount. The invoice and its exchange rate are valid for 20 minutes by default. hostedPageUrl points to a Txn-hosted payment page you can redirect the end user to instead of rendering the address yourself. Track the payment through invoice webhooks or Reading invoice; statuses are explained in Invoice status flow.
XRP Invoice Addresses Format:
For XRP invoices, addresses are returned in the following format:
rwCQVZLSMNY6DgMH61317qvH3nHYqm68PF?dt=xyzwhere xyz is a unique destination tag generated for each invoice.
A destination tag acts like a reference number in bank transfers, identifying the intended beneficiary of the transaction.
Displaying Invoice Deposit Addresses:
When showing the deposit address to your customers, separate the address and the destination tag, and ensure both are clearly viewable and copyable
cURL
curl -X "POST" "https://api.sandbox.txn.io/api/public/v1/invoices" \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer <api_key>' \
-d $'{
"data": {
"type": "invoices",
"attributes": {
"amountBilled": "10000",
"billedCurrency": "TRY",
"chargedCurrency": "USDT",
"network": "TTRX:USDT",
"targetCurrency": "EUR",
"targetAccountId": "13a85b45-8543-41c7-b963-394d4ea128ae",
"reference": "bc32c092-8979-4435-b176-ae1b790b1ca6",
"successRedirectUrl": "https://example.com/success",
"unsuccessRedirectUrl": "https://example.com/fail",
"paymentMethods": [
"on_chain"
]
}
}
}'Headers
Content-Type
application/vnd.api+json
Authorization
Bearer <api_key>
Request Body
data.type
string
Yes
Can only be invoices.
data.attributes.amountBilled
string
Yes
Invoice amount to display to end users. Determines the amount due after conversion.
data.attributes.billedCurrency
string
Yes
Invoice currency to display to end users. Refer to supported currencies.
data.attributes.chargedCurrency
string
Yes
Cryptocurrency that the customer must pay in. Refer to supported currencies.
data.attributes.targetCurrency
string
No
Specifies the account currency to which the invoice payment should be credited. Must be a tradable fiat or cryptocurrency listed on the Supported currencies page — display fiat currencies are not accepted. If omitted, defaults to the value of billedCurrency — in which case billedCurrency must itself be a tradable fiat or cryptocurrency, otherwise the request returns an error.
data.attributes.targetAccountId
string
No
Specifies the ID of the account to which the invoice payment should be credited. Can be a master or subaccount ID. If not present, the payment will be credited to your master account by default. Requires data.attributes.targetCurrency.
data.attributes.reference
string
No
The custom reference ID to tie the invoice to end-user who pays. This can be anything you choose. Must be a unique value for each invoice you create.
data.attributes.successRedirectUrl
string
No
URL you want your customer to be redirected from our hosted page to if the invoice completes.
data.attributes.unsuccessRedirectUrl
string
No
URL you want your customer to be redirected from our hosted page to if the invoice gets expired, cancelled or rejected.
data.attributes.paymentMethods
array
No
An array listing the supported payment methods for a particular invoice. The array currently accepts exactly one value (multi-method support is reserved for future use).
Allowed values:
"on_chain"- Generates a deposit wallet address for receiving an on-chain cryptocurrency transaction. Users can send crypto directly from their wallet."binance_pay"- Generates payment instructions for an off-chain payment via the Binance app, allowing users to complete the transaction within Binance."nft"- Generates payment instructions for purchasing an NFT. See the NFT invoice integration guide.
If omitted, defaults to ["on_chain"].
Response Body
data.id
string
Invoice ID.
data.type
string
Entity type returned. Always invoices.
data.attributes
object
Set of invoice attributes.
data.attributes.amountBilled
string
Invoice amount to display to end users. Determines the amount due after conversion.
data.attributes.amountCharged
string
Amount due. Determines the amount of cryptocurrency the end-user is required to pay.
data.attributes.targetAmount
string
Amount you will receive into your target currency account.
data.attributes.billedCurrency
string
Invoice currency to display to end users. Determines the currency due after conversion. Refer to supported currencies.
data.attributes.chargedCurrency
string
Cryptocurrency that the customer must pay in. Refer to supported currencies.
data.attributes.targetCurrency
string
Settlement currency. This is the currency you will receive in your account after the payment is processed.
data.attributes.chargedTargetRate
string
Charged currency to target currency exchange rate.
data.attributes.chargedTargetRateCurrency
string
Currency in which chargedTargetRate is quoted.
data.attributes.reference
string
The custom reference ID to tie the invoice to end-user who pays. This can be anything you choose.
data.attributes.statusContext
string
Indicates whether the end-user paid in full, underpaid, overpaid, or has not paid (unpaid) the invoice. Refer to Invoice status flow.
data.attributes.networkName
string
Network name to display.
data.attributes.paymentMethods
array
Invoice payment methods.
data.attributes.successRedirectUrl
string
URL your customer will be redirected from our hosted page to if the invoice completes.
data.attributes.unsuccessRedirectUrl
string
URL your customer will be redirected from our hosted page to if the invoice gets expired, cancelled or rejected.
data.attributes.exchangeRate
string
Invoice exchange rate valid for 20 minutes.
data.attributes.expiresAt
string
Invoice expiry date and time.
data.attributes.createdAt
string
Date and time invoice was created at.
data.attributes.hostedPageUrl
string
Invoice hosted page.
data.attributes.scAddress
string
Smart contract address configured for the NFT payment feature. Returns null if the feature is not enabled on the merchant account.
data.relationships.targetAccount
object
The settlement account the invoice is credited to. data.type is accounts; the account entity is returned in included[].
data.relationships.address
object
The invoice receiving address. data.type is addresses; the entity is returned in included[].
data.relationships.binanceOrder
object
Binance Pay order for the invoice. data.type is binanceOrders; the entity is returned in included[]. data is null unless paymentMethods includes binance_pay.
data.relationships.invoiceTransactions, data.relationships.coinDeposits, data.relationships.refundLinks
object
Not expanded (meta.included is false). The create response carries the invoice, its address and its target account only; Read invoice returns the settlement record, received payments and refund links.
included[].type(addresses)
object
The receiving address of the invoice (data.relationships.address).
included[].type(addresses).attributes.value
string
The address the end user must send the payment to. For XRP the destination tag is appended as ?dt=<tag>; display both parts, see the invoice integration guide.
included[].type(addresses).attributes.label
string
Address label. For invoice addresses this is the network name, e.g. Tron (TRC20).
included[].type(addresses).attributes.createdAt
string
When the address was created. Invoice addresses are allocated from a pool, so this can predate the invoice.
included[].type(addresses).relationships
object
account and network: not expanded (meta.included is false); use data.attributes.network and data.attributes.networkName.
included[].type(binanceOrders)
object
Binance Pay payment instructions. Present only when paymentMethods includes binance_pay.
included[].type(binanceOrders).attributes.deeplink
string
Link that opens the Binance app directly on a mobile device.
included[].type(binanceOrders).attributes.universalUrl
string
Link that works in both web and mobile browsers. Use it when you cannot tell the device type.
included[].type(binanceOrders).attributes.qrcodeLink
string
URL of a hosted QR code image to display.
included[].type(binanceOrders).attributes.qrContent
string
The content encoded in the QR code. Use it to render your own QR code.
included[].type(accounts)
object
The target account (data.relationships.targetAccount). Same fields as Reading account; the ones most relevant here are listed below.
included[].type(accounts).attributes.currencyCode
string
Account currency. Equals data.attributes.targetCurrency.
included[].type(accounts).attributes.label
string
Account label.
included[].type(accounts).attributes.master
boolean
true for the master account, false for a subaccount.
included[].type(accounts).attributes.balance
string
Account balance at the time of the request.
included[].type(accounts).attributes.currencyType
string
fiat or crypto.
included[].type(accounts).relationships
object
company, networks and txnBankCredentials: not expanded (meta.included is false).
Response
Amount too low.
Amount too high.
Duplicate reference.
Last updated