Create order
POST /v1/orders
Create a crypto purchase order and get a redirect URL to the purchase page.
HTTP request
https://fiat-api.changelly.com/v1/orders
Request
- Request
- Payload
- cURL
Header parameters
Name | Type | Required | Description |
---|---|---|---|
X-Api-Key | string | true | Your public API 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 |
---|---|---|---|
externalOrderId | string | false | Order ID provided by you. |
externalUserId | string | true | User ID provided by you. |
providerCode | string | true | The On-Ramp provider code. Possible values. |
currencyFrom | string | true | Ticker of the pay-in currency in uppercase. |
currencyTo | string | true | Ticker of the payout currency in uppercase. |
amountFrom | string | true | Amount of currency the user is going to pay. |
country | string | true | Country ISO 3166-1 code (Alpha-2). |
state | string | false | State ISO 3166-2 code. Is required if provided country is US . |
ip | string | false | User's IP address. |
walletAddress | string | true | Recipient wallet address. Here are 2 simple use cases of this parameter:
|
walletExtraId | string | false | Property required for wallet addresses of currencies that use an additional ID for transaction processing (XRP, XLM, EOS, BNB). |
paymentMethod | string | false | The payment method code. Possible values. |
userAgent | string | false | User Agent. |
metadata | object | false | Metadata object, which can contain any parameters you need. |
application/json
{
"externalOrderId": "71ahw34",
"externalUserId": "122hd",
"providerCode": "moonpay",
"currencyFrom": "USD",
"currencyTo": "ETH",
"amountFrom": "150",
"country": "EE",
"walletAddress": "0x8cfbd31371e9bec8c82ae101e25bd9394c03a227",
"paymentMethod": "card"
}
curl --location --request POST
'https://fiat-api.changelly.com/v1/orders'
--header 'X-Api-Key: {{apiKey}}'
--header 'X-Api-Signature: {{signature}}'
--data-raw '{
"externalOrderId": "71ahw34",
"externalUserId": "122hd",
"providerCode": "moonpay",
"currencyFrom": "USD",
"currencyTo": "ETH",
"amountFrom": "150",
"country": "EE",
"walletAddress": "0x8cfbd31371e9bec8c82ae101e25bd9394c03a227",
"paymentMethod": "card"
}'
Response
Sample response
note
If any of the optional parameters are not provided in the request, they will be returned with the null
value in the response.
application/json
{
"redirectUrl": "https://buy.moonpay.com/?CurrencyCode=eth&baseCurrencyCode=usd¤cyCode=eth&baseCurrencyAmount=150&externalTransactionId=71ahw34&walletAddress=0x8cfbd31371e9bec8c82ae101e25bd9394c03a227",
"orderId": "5154302e-3stl-75p4",
"externalUserId": "122hd",
"externalOrderId": "71ahw34",
"providerCode": "moonpay",
"currencyFrom": "USD",
"currencyTo": "ETH",
"amountFrom": "150",
"country": "EE",
"state": null,
"ip": null,
"walletAddress": "0x8cfbd31371e9bec8c82ae101e25bd9394c03a227",
"walletExtraId": null,
"paymentMethod": "card",
"userAgent": null,
"metadata": null,
"createdAt": "2019-07-22T10:10:09.000"
}
Response params
Name | Type | Required | Description |
---|---|---|---|
redirectUrl | string | true | URL to the provider's purchase page. |
orderId | string | true | Internal order ID provided by Fiat API. |
externalUserId | string | true | User ID provided by you. |
externalOrderId | string | true | Order ID provided by you. |
providerCode | string | true | The On-Ramp provider code. Possible values. |
currencyFrom | string | true | Ticker of the pay-in currency in uppercase. |
currencyTo | string | true | Ticker of the payout currency in uppercase. |
amountFrom | string | true | Amount of currency the user is going to pay. |
country | string | true | Country ISO 3166-1 code (Alpha-2). |
state | string | false | State ISO 3166-2 code. Is required if provided country is US . |
ip | string | true | User's IP address. |
walletAddress | string | true | Recipient wallet address. |
walletExtraId | string | true | Property required for wallet addresses of currencies that use an additional ID for transaction processing (XRP, XLM, EOS, BNB). |
paymentMethod | string | true | The payment method code. Possible values. |
userAgent | string | true | User Agent. |
metadata | object | true | Metadata object, which can contain any parameters you need:
|
createdAt | date-time | true | Time in ISO 8601 format. |
Error schema
Name | Type | Required | Description |
---|---|---|---|
errorType | string | true | Error type. |
errorMessage | string | true | Error message. |
errorDetails | array of objects | true | If the error contains no details, errorDetails equals null . |
Possible error types:
Type | Description |
---|---|
validation | Validation error. |
timeout | Request to the provider was not completed in the allotted time. |
unavailable | Request failed at the provider's end. |
limits | Specified pay-in amount is less than the minimum or more than the maximum value for the fiat currency. |
country | Specified country is not supported by the provider. |
state | Offer requested for the United States, but the state parameter is not provided. |
currency | Specified currency pair is not supported by the provider. |
paymentMethod | Specified payment method is not supported by the provider. |
invalidOffer | On-Ramp provider returned an invalid offer. |
unsupportedExchangePair | On-Ramp provider does not support provided exchange pair. |
unsupportedCommissionRate | On-Ramp provider does not support commission rate. |
initialize | Failed to save transaction. |
errorDetails
item schema
Name | Type | Required | Description |
---|---|---|---|
cause | string | true | Error cause. For example, it can equal min or max for the limits error type. |
value | string | true | Error value. For example, it can equal the min or max supported value for the limits error type. |
Error codes
Code | Message |
---|---|
400 | BadRequest |
401 | Unauthorized |
429 | TooManyRequests |
500 | InternalServerError |
- 400
- 401
- 429
- 500
BadRequest
{
"errorType": "limits",
"errorMessage": "Limits error",
"errorDetails": [
{
"cause": "min",
"value": "20"
}
]
}
Unauthorized
{
"errorType": "unauthorized",
"errorMessage": "Unauthorized",
"errorDetails": null
}
TooManyRequests
{
"errorType": "tooManyRequests",
"errorMessage": "Too many requests",
"errorDetails": null
}
InternalServerError
{
"errorType": "internalServerError",
"errorMessage": "Internal Server Error",
"errorDetails": null
}