Create fixed rate transaction
POST createFixTransaction
info
The amountExpectedTo
parameter value should be understood as a payout amount to the user before withholding the networkFee
. To calculate the exact payout amount, deduct the networkFee
value from amountExpectedTo
HTTP request
https://api.changelly.com/v2/#createFixTransaction
Request
- Request
- Payload
- cURL
Header parameters
Name | Type | Required | Description |
---|---|---|---|
X-Api-Key | string | true | Your API key (SHA256 from Public Key) |
X-Api-Signature | string | true | The query's serialized body signed by your private key according to the RSA-SHA256 method. |
Body parameters
Name | Type | Required | Description |
---|---|---|---|
jsonrpc | string | true | JSON-RPC version. |
id | string | true | Client's custom ID. |
method | string | true | API method name. |
params | object | true | Request parameters. Important! Although amountFrom and amountTo are optional parameters, it is required to set one of them. If you provide none or both, the request will result in error. |
params
object:
Name | Type | Required | Description |
---|---|---|---|
from | string | true | Payin currency ticker (in lowercase). |
to | string | true | Payout currency ticker (in lowercase). |
rateId | string | true | Rate ID that you get from getFixRate/getFixRateForAmount requests. |
address | string | true | Recipient address. |
amountFrom | string | false | Amount of currency that user is going to send. |
amountTo | string | false | Amount user wants to receive. |
extraId | string | false | Additional ID for address for currencies that use additional ID for transaction processing. |
refundAddress | string | true | Address of the wallet to refund in case of any technical issues during the exchange. The currency of the wallet must match with the from currency. |
refundExtraId | string | false | extraId for refundAddress . |
fromAddress | string | false | Address of the wallet from which the user will send payin. |
fromExtraId | string | false | extraId for fromAddress . |
userMetadata | string | false | Escaped JSON. You can use userMetadata to include any additional parameters for customization purposes. To use this feature, please contact us at [email protected]. |
Example 1
application/json
{
"jsonrpc": "2.0",
"id": "test",
"method": "createFixTransaction",
"params": {
"from": "eth",
"to": "xrp",
"address": "rwpMvf*************PQqWDwQyHUW",
"extraId": "209****48",
"amountFrom": "0.2",
"rateId": "f3dd48106a63b*********b7ab5413d32c7b96301a7e83",
"refundAddress": "0x576ea9d3**********3d3fd5f1499a0"
}
}
Example with userMetadata
application/json
{
"jsonrpc": "2.0",
"id": "test",
"method": "createFixTransaction",
"params": {
"from": "eth",
"to": "xrp",
"address": "rwpMvf*************PQqWDwQyHUW",
"extraId": "209****48",
"amountFrom": "0.2",
"rateId": "f3dd48106a63b*********b7ab5413d32c7b96301a7e83",
"refundAddress": "0x576ea9d3**********3d3fd5f1499a0",
"userMetadata": "{\"param1\": 50, \"param2\": \"string\", \"param3\": \"50.5189\"}"
}
}
curl --location --request POST 'https://api.changelly.com/v2' \
--header 'X-Api-Key: {{apiKey}}' \
--header 'X-Api-Signature: {{sign}}' \
--data-raw '{
"id": "test",
"jsonrpc": "2.0",
"method": "createFixTransaction",
"params": {
"from": "btc",
"to": "eth",
"address": "0xee*******5E3DFc214",
"amountFrom": "1",
"rateId": "f3dd48106a63b*********b7ab5413d32c7b96301a7e82",
"refundAddress": "1Bvjij5653y9****BGPuQBPzTZpb"
}
}'
Response
- Example
- Success
- Errors
Sample response
application/json
{
"jsonrpc": "2.0",
"id": "test",
"result": {
"id": "149a****m90",
"type": "fixed",
"status": "new",
"payTill": "2022-10-31T16:41:55.000000271+00:00",
"currencyFrom": "btc",
"currencyTo": "eth",
"payinExtraId": null,
"payoutExtraId": null,
"refundAddress": "1Bvjij5653y9r********QBPzTZpb",
"amountExpectedFrom": "1.00000000",
"amountExpectedTo": "32.277489930000000000",
"payinAddress": "3EkyEjzs********vZ95AyTM",
"payoutAddress": "0xeee031413*******B8Cf5E3DFc214",
"createdAt": 1664894262000000,
"networkFee": "0.000515"
}
}
Response params
Name | Type | Description |
---|---|---|
jsonrpc | string | JSON-RPC version. |
id | string | Client's custom ID. |
result | object | Result. |
result
schema:
Name | Type | Description |
---|---|---|
id | string | Transaction ID. Could be used in getStatus method. |
type | string | Type of transaction. Always fixed in this method. |
payinAddress | string | Address for a user to send coins to. |
payinExtraId | string | Extra ID for payinAddress in case it is required. Note: If the payinExtraId parameter is returned in the response and is not null, it is required for user to send the funds to the payinAddress specifying extraId . Otherwise, the transactions will not be processed and the user will need to get a refund through technical support. |
payoutAddress | string | Address where the exchange result will be sent to. |
payoutExtraId | string | Extra ID for payoutAddress in case it is required. |
refundAddress | string | Address of the wallet to refund in case of any technical issues during the exchange. The currency of the wallet must match with the from currency. |
refundExtraId | string | Extra ID for refundAddress . |
amountExpectedFrom | number | The amountFrom value from createFixTransaction request. |
amountExpectedTo | string | The amountTo value from getFixRateForAmount response. This is the estimated payout amount of currency before withholding the network fee. |
status | string | Transaction status. Will always be new when transaction is created. If you reference the same transaction using the getStatus or getTransactions method, you'll get the waiting status as an equivalent to new . |
payTill | string | Indicates time until which user needs to make the payment. |
currencyTo | string | Payout currency ticker. |
currencyFrom | string | Payin currency ticker. |
createdAt | integer | Time in timestamp format (microseconds) when the transaction was created. |
networkFee | string | Commission taken by the network from the amount sent to the user. Displayed in payout currency. |
warning
The result schema parameter trackUrl
was deprecated on 06.01.2024.
Error schema
Name | Type | Description |
---|---|---|
jsonrpc | string | JSON-RPC version. |
id | string | Client's custom ID. |
error | object | Possible errors. |
»code | integer | Error code. |
»message | string | Error message. |
Error codes
Code | Message | Description |
---|---|---|
-32600 | Invalid amount: maximal amount is {max_amount} | The attempt to exchange more currency than a maximal amount. |
-32602 | Invalid currency: {currency} temporary disabled | This currency is currently disabled. |
-32602 | Invalid currency: {currency} temporary disabled for fix rate transactions | This currency is currently disabled for fix-rate transactions. |
-32602 | Invalid currency: {currency} is temporary disabled on API as output currency | This currency is currently disabled on API as an output currency. |
-32602 | Invalid currency: {currency} is temporary disabled on API as input currency | This currency is currently disabled on API as an input currency. |
-32602 | Invalid currency: {currency} not found | This currency is not listed on Changelly or the ticker is invalid. |
-32602 | Parameter {param} is invalid | You've specified an invalid parameter. |
-32602 | Error: Invalid address | You've specified an invalid payout address. |
-32602 | Error: Invalid refund address | You've specified an invalid refund address. |
-32602 | Error: rateId was expired or already used. Use method getFixRateForAmount to generate new rateId | New rateId has to be generated. |
-32603 | Internal Error or Error | Most likely, the problem is on our side. Further investigation is required. |