POST
https://api.cryptohopper.com/v1/subscription/order
Buys a subscription plan with the user's credits. Call it once without confirm to get a confirmation code, then call it again with that code in confirm to place and pay the order.
The first call returns data with message and confirm (the code to send back). Only plan_id 1, 2, 3 and 89 can be ordered; payment_term is year or month, anything else means month. discount_code is optional. The user profile must be complete and the credit balance must cover the total including tax. hopper_id is read but the new subscription is not assigned to that bot; use Assign subscription afterwards.
Example request
curl -X POST "https://api.cryptohopper.com/v1/subscription/order" \
-H "access-token: YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"plan_id":2,"payment_term":"month","confirm":"9e107d9d372bb6826bd81d3542a419d6"}'
const response = await fetch('https://api.cryptohopper.com/v1/subscription/order', {
method: 'POST',
headers: {
"access-token": "YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"plan_id": 2,
"payment_term": "month",
"confirm": "9e107d9d372bb6826bd81d3542a419d6"
})
});
const data = await response.json();
import requests
response = requests.post(
"https://api.cryptohopper.com/v1/subscription/order",
headers={
"access-token": "YOUR_ACCESS_TOKEN"
},
json={
"plan_id": 2,
"payment_term": "month",
"confirm": "9e107d9d372bb6826bd81d3542a419d6"
},
)
data = response.json()
$ch = curl_init('https://api.cryptohopper.com/v1/subscription/order');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'access-token: YOUR_ACCESS_TOKEN',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'plan_id' => 2,
'payment_term' => 'month',
'confirm' => '9e107d9d372bb6826bd81d3542a419d6',
]),
]);
$data = json_decode(curl_exec($ch), true);
Parameters
Headers
| Name | Type | Required | Description |
|---|---|---|---|
access-token |
string | Required | The OAuth access token of the user. |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
payment_term | string | Optional | One of: year, month. |
plan_id | integer | Required | |
confirm | string | Optional | |
discount_code | string | Optional | |
hopper_id | integer | Optional |
Response
{
"data": {
"message": "Your subscription has been ordered and paid.",
"subscription_id": 466001,
"plan_id": 2,
"payment_id": 501234
}
}