Update User Subscription
curl --request POST \
--url https://api.example.com/cabinet/admin/users/{user_id}/subscription \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"action": "<string>",
"days": 1825,
"end_date": "2023-11-07T05:31:56Z",
"tariff_id": 123,
"traffic_limit_gb": 1,
"traffic_used_gb": 1,
"autopay_enabled": true,
"traffic_gb": 2,
"traffic_purchase_id": 123,
"is_trial": true,
"device_limit": 2
}
'import requests
url = "https://api.example.com/cabinet/admin/users/{user_id}/subscription"
payload = {
"action": "<string>",
"days": 1825,
"end_date": "2023-11-07T05:31:56Z",
"tariff_id": 123,
"traffic_limit_gb": 1,
"traffic_used_gb": 1,
"autopay_enabled": True,
"traffic_gb": 2,
"traffic_purchase_id": 123,
"is_trial": True,
"device_limit": 2
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
action: '<string>',
days: 1825,
end_date: '2023-11-07T05:31:56Z',
tariff_id: 123,
traffic_limit_gb: 1,
traffic_used_gb: 1,
autopay_enabled: true,
traffic_gb: 2,
traffic_purchase_id: 123,
is_trial: true,
device_limit: 2
})
};
fetch('https://api.example.com/cabinet/admin/users/{user_id}/subscription', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/cabinet/admin/users/{user_id}/subscription",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'action' => '<string>',
'days' => 1825,
'end_date' => '2023-11-07T05:31:56Z',
'tariff_id' => 123,
'traffic_limit_gb' => 1,
'traffic_used_gb' => 1,
'autopay_enabled' => true,
'traffic_gb' => 2,
'traffic_purchase_id' => 123,
'is_trial' => true,
'device_limit' => 2
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/cabinet/admin/users/{user_id}/subscription"
payload := strings.NewReader("{\n \"action\": \"<string>\",\n \"days\": 1825,\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"tariff_id\": 123,\n \"traffic_limit_gb\": 1,\n \"traffic_used_gb\": 1,\n \"autopay_enabled\": true,\n \"traffic_gb\": 2,\n \"traffic_purchase_id\": 123,\n \"is_trial\": true,\n \"device_limit\": 2\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/cabinet/admin/users/{user_id}/subscription")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"action\": \"<string>\",\n \"days\": 1825,\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"tariff_id\": 123,\n \"traffic_limit_gb\": 1,\n \"traffic_used_gb\": 1,\n \"autopay_enabled\": true,\n \"traffic_gb\": 2,\n \"traffic_purchase_id\": 123,\n \"is_trial\": true,\n \"device_limit\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/cabinet/admin/users/{user_id}/subscription")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": \"<string>\",\n \"days\": 1825,\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"tariff_id\": 123,\n \"traffic_limit_gb\": 1,\n \"traffic_used_gb\": 1,\n \"autopay_enabled\": true,\n \"traffic_gb\": 2,\n \"traffic_purchase_id\": 123,\n \"is_trial\": true,\n \"device_limit\": 2\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"subscription": {
"id": 123,
"status": "<string>",
"is_trial": true,
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z",
"traffic_limit_gb": 0,
"traffic_used_gb": 0,
"device_limit": 1,
"tariff_id": 123,
"tariff_name": "<string>",
"autopay_enabled": false,
"is_active": false,
"days_remaining": 0,
"purchased_traffic_gb": 0,
"traffic_purchases": []
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Cabinet Admin Users
Update User Subscription
Update user subscription.
Actions:
- extend: Extend subscription by X days
- set_end_date: Set specific end date
- change_tariff: Change subscription tariff
- set_traffic: Set traffic limit and/or used traffic
- toggle_autopay: Enable/disable autopay
- cancel: Cancel subscription (set status to expired)
- activate: Activate subscription
- create: Create new subscription if not exists
POST
/
cabinet
/
admin
/
users
/
{user_id}
/
subscription
Update User Subscription
curl --request POST \
--url https://api.example.com/cabinet/admin/users/{user_id}/subscription \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"action": "<string>",
"days": 1825,
"end_date": "2023-11-07T05:31:56Z",
"tariff_id": 123,
"traffic_limit_gb": 1,
"traffic_used_gb": 1,
"autopay_enabled": true,
"traffic_gb": 2,
"traffic_purchase_id": 123,
"is_trial": true,
"device_limit": 2
}
'import requests
url = "https://api.example.com/cabinet/admin/users/{user_id}/subscription"
payload = {
"action": "<string>",
"days": 1825,
"end_date": "2023-11-07T05:31:56Z",
"tariff_id": 123,
"traffic_limit_gb": 1,
"traffic_used_gb": 1,
"autopay_enabled": True,
"traffic_gb": 2,
"traffic_purchase_id": 123,
"is_trial": True,
"device_limit": 2
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
action: '<string>',
days: 1825,
end_date: '2023-11-07T05:31:56Z',
tariff_id: 123,
traffic_limit_gb: 1,
traffic_used_gb: 1,
autopay_enabled: true,
traffic_gb: 2,
traffic_purchase_id: 123,
is_trial: true,
device_limit: 2
})
};
fetch('https://api.example.com/cabinet/admin/users/{user_id}/subscription', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/cabinet/admin/users/{user_id}/subscription",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'action' => '<string>',
'days' => 1825,
'end_date' => '2023-11-07T05:31:56Z',
'tariff_id' => 123,
'traffic_limit_gb' => 1,
'traffic_used_gb' => 1,
'autopay_enabled' => true,
'traffic_gb' => 2,
'traffic_purchase_id' => 123,
'is_trial' => true,
'device_limit' => 2
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/cabinet/admin/users/{user_id}/subscription"
payload := strings.NewReader("{\n \"action\": \"<string>\",\n \"days\": 1825,\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"tariff_id\": 123,\n \"traffic_limit_gb\": 1,\n \"traffic_used_gb\": 1,\n \"autopay_enabled\": true,\n \"traffic_gb\": 2,\n \"traffic_purchase_id\": 123,\n \"is_trial\": true,\n \"device_limit\": 2\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/cabinet/admin/users/{user_id}/subscription")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"action\": \"<string>\",\n \"days\": 1825,\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"tariff_id\": 123,\n \"traffic_limit_gb\": 1,\n \"traffic_used_gb\": 1,\n \"autopay_enabled\": true,\n \"traffic_gb\": 2,\n \"traffic_purchase_id\": 123,\n \"is_trial\": true,\n \"device_limit\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/cabinet/admin/users/{user_id}/subscription")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": \"<string>\",\n \"days\": 1825,\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"tariff_id\": 123,\n \"traffic_limit_gb\": 1,\n \"traffic_used_gb\": 1,\n \"autopay_enabled\": true,\n \"traffic_gb\": 2,\n \"traffic_purchase_id\": 123,\n \"is_trial\": true,\n \"device_limit\": 2\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"subscription": {
"id": 123,
"status": "<string>",
"is_trial": true,
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z",
"traffic_limit_gb": 0,
"traffic_used_gb": 0,
"device_limit": 1,
"tariff_id": 123,
"tariff_name": "<string>",
"autopay_enabled": false,
"is_active": false,
"days_remaining": 0,
"purchased_traffic_gb": 0,
"traffic_purchases": []
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Body
application/json
Request to update user subscription.
Action: extend, shorten, set_end_date, change_tariff, set_traffic, toggle_autopay, cancel
Days to extend
Required range:
1 <= x <= 3650New end date
New tariff ID
New traffic limit in GB
Required range:
x >= 0Set traffic used in GB
Required range:
x >= 0Enable/disable autopay
Traffic GB to add
Required range:
x >= 1Traffic purchase ID to remove
Is trial subscription
Device limit
Required range:
x >= 1⌘I
