Sub-Users
The link provided below directs to a page that elaborates on the concept of a sub-user within our system.
It's important to note that almost every endpoint related to sub-users, with the notable exceptions of the index
and delete
endpoints, will return a Subuser resource upon a successful call.
{
"id": 5,
"hash": "01HQ5K3P97DY8EX9Y90YT1K6XA",
"username": "subuser_231",
"password": "asffqwv2f3w4214v",
"traffic_available": 0.25,
"traffic_used": 0
}
Note that you should not use the id
field. It is a legacy field that will be removed in the future.
When adding traffic to a sub-user through creation or updating, the traffic will be taken from the main account. Likewise, when you delete a sub-user or take traffic from a sub-user - it will be returned to the main user.
Create Sub-User
POST
/residential-subusers
Body Parameters
Name | Type | Description |
---|---|---|
username | String | username of the subuser |
password | String | password of the subuser |
traffic | Float | traffic (GB) that will be assigned to the subuser |
Example request:
curl -X POST https://resi-api.iproyal.com/v1/residential-subusers \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your_api_token>" \
-d '{
"username": "subuser123",
"password": "securepassword",
"traffic": 10.0
}'
<?php
$api_token = '<your_api_token>';
$url = 'https://resi-api.iproyal.com/v1/residential-subusers';
$data = [
'username' => 'subuser123',
'password' => 'securepassword',
'traffic' => 10.0
];
$payload = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
"Authorization: Bearer $api_token"
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>
import requests
api_token = '<your_api_token>'
url = 'https://resi-api.iproyal.com/v1/residential-subusers'
data = {
'username': 'subuser123',
'password': 'securepassword',
'traffic': 10.0
}
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {api_token}'
}
response = requests.post(url, json=data, headers=headers)
print(response.text)
const https = require('https');
const apiToken = '<your_api_token>';
const url = 'https://resi-api.iproyal.com/v1/residential-subusers';
const data = JSON.stringify({
username: 'subuser123',
password: 'securepassword',
traffic: 10.0
});
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiToken}`
}
};
const req = https.request(url, options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log(data);
});
});
req.on('error', (error) => {
console.error('Error:', error.message);
});
req.write(data);
req.end();
Get Sub-User
GET
/residential-subusers/{ hash }
Query Parameters
Name | Type | Description |
---|---|---|
| String | hash of the subuser |
Example request:
curl -X GET "https://resi-api.iproyal.com/v1/residential-subusers/<subuser_hash>" \
-H "Authorization: Bearer <your_api_token>"
<?php
$api_token = '<your_api_token>';
$url = "https://resi-api.iproyal.com/v1/residential-subusers/{hash}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer $api_token"
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>
import requests
api_token = '<your_api_token>'
hash = '<subuser_hash>'
url = f'https://resi-api.iproyal.com/v1/residential-subusers/{hash}'
headers = {
'Authorization': f'Bearer {api_token}'
}
response = requests.get(url, headers=headers)
print(response.text)
const https = require('https');
const api_token = '<your_api_token>';
const hash = '<subuser_hash>';
const url = `https://resi-api.iproyal.com/v1/residential-subusers/${hash}`;
const options = {
method: 'GET',
headers: {
'Authorization': `Bearer ${api_token}`
}
};
const req = https.request(url, options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log(data);
});
});
req.on('error', (error) => {
console.error('Error:', error.message);
});
req.end();
Get Sub-Users
GET
/residential-subusers
Query Parameters
Name | Type | Description |
---|---|---|
page | Integer | Number of the page |
per_page | Integer | Number of subusers per page |
search | String | Search that will be used to filter subusers by username |
Example request:
curl -X GET "https://resi-api.iproyal.com/v1/residential-subusers?page=1&per_page=10&search=username_search" \
-H "Authorization: Bearer <your_api_token>"
<?php
$api_token = '<your_api_token>';
$page = 1;
$per_page = 10;
$search = 'username_search';
$url = "https://resi-api.iproyal.com/v1/residential-subusers?page=$page&per_page=$per_page&search=$search";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer $api_token"
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>
import requests
api_token = '<your_api_token>'
page = 1
per_page = 10
search = 'username_search'
url = f'https://resi-api.iproyal.com/v1/residential-subusers?page={page}&per_page={per_page}&search={search}'
headers = {
'Authorization': f'Bearer {api_token}'
}
response = requests.get(url, headers=headers)
print(response.text)
const https = require('https');
const api_token = '<your_api_token>';
const page = 1;
const per_page = 10;
const search = 'username_search';
const url = `https://resi-api.iproyal.com/v1/residential-subusers?page=${page}&per_page=${per_page}&search=${search}`;
const options = {
method: 'GET',
headers: {
'Authorization': `Bearer ${api_token}`
}
};
const req = https.request(url, options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log(data);
});
});
req.on('error', (error) => {
console.error('Error:', error.message);
});
req.end();
Update Sub-User
UPDATE
/residential-subusers/{ hash }
Query Parameters
Name | Type | Description |
---|---|---|
hash | String | hash of the subuser |
Body Parameters
Name | Type | Description |
---|---|---|
username | String | username of the subuser |
password | String | password of the subuser |
traffic | Float | traffic (GB) that will be assigned to the subuser |
Example request:
curl -X PUT "https://resi-api.iproyal.com/v1/residential-subusers/<subuser_hash>" \
-H "Authorization: Bearer <your_api_token>" \
-H "Content-Type: application/json" \
-d '{
"username": "new_username",
"password": "new_password",
"traffic": 5.0
}'
<?php
$api_token = '<your_api_token>';
$hash = '<subuser_hash>';
$username = 'new_username';
$password = 'new_password';
$traffic = 5.0;
$url = "https://resi-api.iproyal.com/v1/residential-subusers/$hash";
$data = [
'username' => $username,
'password' => $password,
'traffic' => $traffic
];
$options = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'UPDATE',
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $api_token",
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode($data)
];
$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>
import requests
api_token = '<your_api_token>'
hash = '<subuser_hash>'
url = f'https://resi-api.iproyal.com/v1/residential-subusers/{hash}'
data = {
'username': 'new_username',
'password': 'new_password',
'traffic': 5.0
}
headers = {
'Authorization': f'Bearer {api_token}',
'Content-Type': 'application/json'
}
response = requests.put(url, json=data, headers=headers)
print(response.text)
const https = require('https');
const api_token = '<your_api_token>';
const hash = '<subuser_hash>';
const data = JSON.stringify({
username: 'new_username',
password: 'new_password',
traffic: 5.0
});
const options = {
hostname: 'resi-api.iproyal.com',
path: `/v1/residential-subusers/${hash}`,
method: 'UPDATE',
headers: {
'Authorization': `Bearer ${api_token}`,
'Content-Type': 'application/json',
'Content-Length': data.length
}
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
console.log(responseData);
});
});
req.on('error', (error) => {
console.error('Error:', error.message);
});
req.write(data);
req.end();
Delete Sub-User
DELETE
/residential-subusers/{ hash }
Query Parameters
Name | Type | Description |
---|---|---|
| String | hash of the subuser |
Example request:
curl -X DELETE "https://resi-api.iproyal.com/v1/residential-subusers/<subuser_hash>" \
-H "Authorization: Bearer <your_api_token>" \
-H "Content-Type: application/json"
<?php
$api_token = '<your_api_token>';
$hash = '<subuser_hash>';
$url = "https://resi-api.iproyal.com/v1/residential-subusers/$hash";
$options = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $api_token",
'Content-Type: application/json'
]
];
$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>
import requests
api_token = '<your_api_token>'
hash = '<subuser_hash>'
url = f'https://resi-api.iproyal.com/v1/residential-subusers/{hash}'
headers = {
'Authorization': f'Bearer {api_token}',
'Content-Type': 'application/json'
}
response = requests.delete(url, headers=headers)
print(response.status_code)
print(response.text)
const https = require('https');
const api_token = '<your_api_token>';
const hash = '<subuser_hash>';
const options = {
hostname: 'resi-api.iproyal.com',
path: `/v1/residential-subusers/${hash}`,
method: 'DELETE',
headers: {
'Authorization': `Bearer ${api_token}`,
'Content-Type': 'application/json'
}
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
console.log(responseData);
});
});
req.on('error', (error) => {
console.error('Error:', error.message);
});
req.end();
Add Traffic to Sub-User
POST
/residential-subusers/{ hash }/give-traffic
Query Parameters
Name | Type | Description |
---|---|---|
| String | hash of the subuser |
Body Parameters
Name | Type | Description |
---|---|---|
amount | Float | amount of traffic (GB) to give |
Example request:
curl -X POST "https://resi-api.iproyal.com/v1/residential-subusers/<subuser_hash>/give-traffic" \
-H "Authorization: Bearer <your_api_token>" \
-H "Content-Type: application/json" \
-d '{
"amount": 5.0
}'
<?php
$api_token = '<your_api_token>';
$hash = '<subuser_hash>';
$amount = 5.0;
$url = "https://resi-api.iproyal.com/v1/residential-subusers/$hash/give-traffic";
$data = [
'amount' => $amount
];
$options = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $api_token",
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode($data)
];
$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>
import requests
api_token = '<your_api_token>'
hash = '<subuser_hash>'
url = f'https://resi-api.iproyal.com/v1/residential-subusers/{hash}/give-traffic'
data = {
'amount': 5.0
}
headers = {
'Authorization': f'Bearer {api_token}',
'Content-Type': 'application/json'
}
response = requests.post(url, json=data, headers=headers)
print(response.status_code)
print(response.text)
const https = require('https');
const api_token = '<your_api_token>';
const hash = '<subuser_hash>';
const amount = 5.0;
const data = JSON.stringify({ amount });
const options = {
hostname: 'resi-api.iproyal.com',
path: `/v1/residential-subusers/${hash}/give-traffic`,
method: 'POST',
headers: {
'Authorization': `Bearer ${api_token}`,
'Content-Type': 'application/json',
'Content-Length': data.length
}
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
console.log(responseData);
});
});
req.on('error', (error) => {
console.error('Error:', error.message);
});
req.write(data);
req.end();
Take Traffic From Sub-User
POST
/residential-subusers/{ hash }/take-traffic
Query Parameters
Name | Type | Description |
---|---|---|
hash | String | hash of the subuser |
Body Parameters
Name | Type | Description |
---|---|---|
amount | Float | amount of traffic (GB) to give |
Example request:
curl -X POST "https://resi-api.iproyal.com/v1/residential-subusers/<subuser_hash>/take-traffic" \
-H "Authorization: Bearer <your_api_token>" \
-H "Content-Type: application/json" \
-d '{
"amount": 5.0
}'
<?php
$api_token = '<your_api_token>';
$hash = '<subuser_hash>';
$amount = 5.0;
$url = "https://resi-api.iproyal.com/v1/residential-subusers/$hash/take-traffic";
$data = [
'amount' => $amount
];
$options = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $api_token",
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode($data)
];
$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>
import requests
api_token = '<your_api_token>'
hash = '<subuser_hash>'
url = f'https://resi-api.iproyal.com/v1/residential-subusers/{hash}/take-traffic'
data = {
'amount': 5.0
}
headers = {
'Authorization': f'Bearer {api_token}',
'Content-Type': 'application/json'
}
response = requests.post(url, json=data, headers=headers)
print(response.status_code)
print(response.text)
const https = require('https');
const api_token = '<your_api_token>';
const hash = '<subuser_hash>';
const amount = 5.0;
const data = JSON.stringify({ amount });
const options = {
hostname: 'resi-api.iproyal.com',
path: `/v1/residential-subusers/${hash}/take-traffic`,
method: 'POST',
headers: {
'Authorization': `Bearer ${api_token}`,
'Content-Type': 'application/json',
'Content-Length': data.length
}
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
console.log(responseData);
});
});
req.on('error', (error) => {
console.error('Error:', error.message);
});
req.write(data);
req.end();
Last updated