Create order
POST /v1/sell/orders
Create a crypto sell order and get a redirect URL to the selling page.
HTTP request
https://fiat-api.changelly.com/v1/sell/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 | true | Order ID provided by you. |
externalUserId | string | true | User ID provided by you. |
providerCode | string | true | The Off-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. |
refundAddress | string | true | Recipient refund address |
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": "BTC",
"currencyTo": "EUR",
"amountFrom": 0.002,
"country": "IT"
}
curl --location --request POST
'https://fiat-api.changelly.com/v1/sell/orders'
--header 'X-Api-Key: {{apiKey}}'
--header 'X-Api-Signature: {{signature}}'
--data-raw '{
"externalOrderId": "71ahw34",
"externalUserId": "122hd",
"providerCode": "moonpay",
"currencyFrom": "BTC",
"currencyTo": "EUR",
"amountFrom": 0.002,
"country": "IT"
}'
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://web-api-v2.changelly.com/public/f2c/redirect/transactions/745e2b9d-0e86-49e9-a1db-e7060bde48c7/provider",
"orderId": "b38b83f0-1c76-4356-8ed5-60c1fcb2870c",
"externalUserId": "122hd",
"externalOrderId": "71ahw34",
"providerCode": "moonpay",
"currencyFrom": "BTC",
"currencyTo": "EUR",
"amountFrom": 0.002,
"country": "IT",
"state": null,
"ip": null,
"refundAddress": null,
"paymentMethod": "card",
"userAgent": null,
"metadata": null,
"createdAt": "2024-05-09T06:06:07.845Z"
}
Response params
Name | Type | Required | Description |
---|---|---|---|
redirectUrl | string | true | URL to the provider's selling 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 Off-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 | true | State ISO 3166-2 code. Is required if provided country is US . |
ip | string | true | User's IP address. |
refundAddress | string | true | Recipient refund address. |
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 | 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 | Off-Ramp provider returned an invalid offer. |
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
}