# API For Sub-Accounts

## List sub accounts

> Returns a list of sub accounts.

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"servers":[{"url":"https://sandbox.9proxy.com"}],"security":[{"api_key":[]}],"components":{"securitySchemes":{"api_key":{"type":"apiKey","name":"api-key","in":"query"}},"schemas":{"ResponseListSubAccount":{"type":"object","description":"Returns the list of sub accounts for the user.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"result":{"type":"object","description":"Response data.","properties":{"items":{"type":"array","description":"Array of sub accounts.","items":{"$ref":"#/components/schemas/SubAccountInfo"}},"total_items":{"type":"integer","description":"Total number of items."},"total_pages":{"type":"integer","description":"Total number of pages."}}}}},"SubAccountInfo":{"type":"object","description":"Information about a sub account.","properties":{"id":{"type":"integer","description":"ID of the sub account."},"username":{"type":"string","description":"Username of the sub account."},"note":{"type":["string","null"],"description":"Note for the sub account."},"number_of_ips":{"type":"integer","description":"Number of IPs allocated to the sub account."},"traffic_data":{"type":"integer","description":"Amount of traffic allocated to the sub account (in bytes)."},"status":{"$ref":"#/components/schemas/SubAccountStatus","description":"Current status of the sub account."},"created_at":{"type":"integer","description":"Timestamp when the sub account was created."},"setting":{"type":"object","properties":{"auto_add_ips":{"type":"integer","description":"Enable or disable automatic IP allocation from the main account."},"auto_add_when_number_ips":{"type":"integer","description":"Threshold for automatically adding IPs to the sub account."},"number_ips_auto_add":{"type":"integer","description":"Number of IPs to automatically add when auto-add is triggered."},"auto_disable_at":{"type":["integer","null"],"description":"Timestamp when the sub account will be automatically disabled."},"auto_add_traffic":{"type":"integer","description":"Enable or disable automatic traffic allocation from the main account."},"auto_add_when_traffic_bellow":{"type":"integer","description":"Threshold for automatically adding traffic to the sub account."},"amount_traffic_auto_add":{"type":"integer","description":"Amount of traffic to automatically add when auto-add is triggered (in bytes)."},"traffic_plan_use_auto_add":{"type":["integer","null"],"description":"ID of the traffic plan used for automatic traffic allocation."}}}}},"SubAccountStatus":{"type":"integer","description":"Sub account status.\n1 = Enabled\n2 = Disabled"},"ResponseBadRequestError":{"type":"object","description":"Response returned when the request is invalid.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"errors":{"type":"array","description":"List of error messages.","items":{"type":"string"}}}},"ResponseForbiddenError":{"type":"object","description":"Response returned when authentication fails.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"errors":{"type":"array","description":"List of error messages.","items":{"type":"string"}}}}}},"paths":{"/client/v1/subs/get-list":{"get":{"summary":"List sub accounts","description":"Returns a list of sub accounts.","parameters":[{"schema":{"type":"integer"},"name":"limit","in":"query","required":false,"description":"Maximum number of items returned. Default: 30."},{"schema":{"type":"integer"},"name":"page","in":"query","required":false,"description":"Page number of the requested data. Default: 1."},{"schema":{"type":"string"},"name":"sort_by","in":"query","required":false,"description":"Field used for sorting: id, username, created_at, number_of_ips. Default: id."},{"schema":{"type":"string"},"name":"order_by","in":"query","required":false,"description":"Sorting order: desc or asc. Default: desc."},{"schema":{"type":"string"},"name":"username","in":"query","required":false,"description":"Filter by sub account username."},{"schema":{"type":"integer"},"name":"status","in":"query","required":false,"description":"Filter by sub account status: 1 = enabled, 2 = disabled."},{"schema":{"type":"string"},"name":"keyword","in":"query","required":false,"description":"Search sub accounts by keyword."}],"responses":{"200":{"description":"Successful response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseListSubAccount"}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseBadRequestError"}}}},"403":{"description":"Authentication error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseForbiddenError"}}}}}}}}}
```

## Create a sub account

> Creates a new sub account.

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"servers":[{"url":"https://sandbox.9proxy.com"}],"security":[{"api_key":[]}],"components":{"securitySchemes":{"api_key":{"type":"apiKey","name":"api-key","in":"query"}},"schemas":{"ResponseCreateSubAccount":{"type":"object","description":"Returns the newly created sub account.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"result":{"type":"object","description":"New sub account information.","$ref":"#/components/schemas/SubAccountInfo"}}},"SubAccountInfo":{"type":"object","description":"Information about a sub account.","properties":{"id":{"type":"integer","description":"ID of the sub account."},"username":{"type":"string","description":"Username of the sub account."},"note":{"type":["string","null"],"description":"Note for the sub account."},"number_of_ips":{"type":"integer","description":"Number of IPs allocated to the sub account."},"traffic_data":{"type":"integer","description":"Amount of traffic allocated to the sub account (in bytes)."},"status":{"$ref":"#/components/schemas/SubAccountStatus","description":"Current status of the sub account."},"created_at":{"type":"integer","description":"Timestamp when the sub account was created."},"setting":{"type":"object","properties":{"auto_add_ips":{"type":"integer","description":"Enable or disable automatic IP allocation from the main account."},"auto_add_when_number_ips":{"type":"integer","description":"Threshold for automatically adding IPs to the sub account."},"number_ips_auto_add":{"type":"integer","description":"Number of IPs to automatically add when auto-add is triggered."},"auto_disable_at":{"type":["integer","null"],"description":"Timestamp when the sub account will be automatically disabled."},"auto_add_traffic":{"type":"integer","description":"Enable or disable automatic traffic allocation from the main account."},"auto_add_when_traffic_bellow":{"type":"integer","description":"Threshold for automatically adding traffic to the sub account."},"amount_traffic_auto_add":{"type":"integer","description":"Amount of traffic to automatically add when auto-add is triggered (in bytes)."},"traffic_plan_use_auto_add":{"type":["integer","null"],"description":"ID of the traffic plan used for automatic traffic allocation."}}}}},"SubAccountStatus":{"type":"integer","description":"Sub account status.\n1 = Enabled\n2 = Disabled"},"ResponseBadRequestError":{"type":"object","description":"Response returned when the request is invalid.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"errors":{"type":"array","description":"List of error messages.","items":{"type":"string"}}}},"ResponseForbiddenError":{"type":"object","description":"Response returned when authentication fails.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"errors":{"type":"array","description":"List of error messages.","items":{"type":"string"}}}}}},"paths":{"/client/v1/subs/create":{"post":{"summary":"Create a sub account","description":"Creates a new sub account.","responses":{"200":{"description":"Successful response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseCreateSubAccount"}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseBadRequestError"}}}},"403":{"description":"Authentication error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseForbiddenError"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"number_of_ips":{"type":"integer","description":"Number of IPs allocated to the sub account."},"auto_add_ips":{"type":"integer","description":"Enable or disable automatic IP allocation from the main account. 0 = disabled, 1 = enabled."},"auto_add_when_number_ips":{"type":"integer","description":"Threshold for automatically adding IPs. When the sub account IP balance drops below this value, the main account will add IPs automatically."},"number_ips_auto_add":{"type":"integer","description":"Number of IPs to automatically add when auto-add is triggered."},"auto_disable_at":{"type":"integer","description":"Timestamp when the sub account will be automatically disabled."},"amount_traffic":{"type":"integer","description":"Traffic amount allocated to the sub account (in bytes)."},"traffic_plan_id":{"type":"integer","description":"ID of the traffic plan used for allocation."},"auto_add_traffic":{"type":"integer","description":"Enable or disable automatic traffic allocation. 0 = disabled, 1 = enabled."},"auto_add_when_traffic_bellow":{"type":"integer","description":"Threshold for automatically adding traffic. When the sub account traffic balance drops below this value, the main account will add traffic automatically."},"amount_traffic_auto_add":{"type":"integer","description":"Amount of traffic to automatically add when auto-add is triggered (in bytes)."},"traffic_plan_use_auto_add":{"type":"integer","description":"ID of the traffic plan used when automatically adding traffic to the sub account."},"password":{"type":"string","description":"Password for the sub account."},"note":{"type":"string","description":"Note for the sub account."}},"required":["password"]}}}}}}}}
```

## Update a sub account

> Updates an existing sub account.

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"servers":[{"url":"https://sandbox.9proxy.com"}],"security":[{"api_key":[]}],"components":{"securitySchemes":{"api_key":{"type":"apiKey","name":"api-key","in":"query"}},"schemas":{"ResponseUpdateSubAccount":{"type":"object","description":"Returns the update status of the sub account.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"result":{"type":"object","properties":{"updated":{"type":"boolean"}}}}},"ResponseBadRequestError":{"type":"object","description":"Response returned when the request is invalid.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"errors":{"type":"array","description":"List of error messages.","items":{"type":"string"}}}},"ResponseForbiddenError":{"type":"object","description":"Response returned when authentication fails.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"errors":{"type":"array","description":"List of error messages.","items":{"type":"string"}}}}}},"paths":{"/client/v1/subs/update":{"put":{"summary":"Update a sub account","description":"Updates an existing sub account.","responses":{"200":{"description":"Successful response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseUpdateSubAccount"}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseBadRequestError"}}}},"403":{"description":"Authentication error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseForbiddenError"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"sub_id":{"type":"integer","description":"ID of the sub account."},"password":{"type":"string","description":"New password for the sub account."},"note":{"type":"string","description":"Note for the sub account."},"auto_add_ips":{"type":"integer","description":"Enable or disable automatic IP allocation from the main account. 0 = disabled, 1 = enabled."},"auto_add_when_number_ips":{"type":"integer","description":"Threshold for automatically adding IPs. When the sub account IP balance drops below this value, the main account will add IPs automatically."},"number_ips_auto_add":{"type":"integer","description":"Number of IPs to automatically add when auto-add is triggered."},"auto_disable_at":{"type":"integer","description":"Timestamp when the sub account will be automatically disabled."},"auto_add_traffic":{"type":"integer","description":"Enable or disable automatic traffic allocation. 0 = disabled, 1 = enabled."},"auto_add_when_traffic_bellow":{"type":"integer","description":"Threshold for automatically adding traffic. When the sub account traffic balance drops below this value, the main account will add traffic automatically."},"amount_traffic_auto_add":{"type":"integer","description":"Amount of traffic to automatically add when auto-add is triggered (in bytes)."},"traffic_plan_use_auto_add":{"type":"integer","description":"ID of the traffic plan used when automatically adding traffic to the sub account."}},"required":["sub_id"]}}}}}}}}
```

## Delete sub accounts

> Deletes one or more sub accounts.

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"servers":[{"url":"https://sandbox.9proxy.com"}],"security":[{"api_key":[]}],"components":{"securitySchemes":{"api_key":{"type":"apiKey","name":"api-key","in":"query"}},"schemas":{"ResponseDeleteSubAccount":{"type":"object","description":"Returns the deletion status of the sub account.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"result":{"type":"object","properties":{"deleted":{"type":"boolean"}}}}},"ResponseBadRequestError":{"type":"object","description":"Response returned when the request is invalid.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"errors":{"type":"array","description":"List of error messages.","items":{"type":"string"}}}},"ResponseForbiddenError":{"type":"object","description":"Response returned when authentication fails.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"errors":{"type":"array","description":"List of error messages.","items":{"type":"string"}}}}}},"paths":{"/client/v1/subs/bulk-delete":{"delete":{"summary":"Delete sub accounts","description":"Deletes one or more sub accounts.","responses":{"200":{"description":"Successful response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseDeleteSubAccount"}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseBadRequestError"}}}},"403":{"description":"Authentication error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseForbiddenError"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"integer","description":"ID of the sub account."}}},"required":["ids"]}}}}}}}}
```

## The SubAccountInfo object

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"components":{"schemas":{"SubAccountInfo":{"type":"object","description":"Information about a sub account.","properties":{"id":{"type":"integer","description":"ID of the sub account."},"username":{"type":"string","description":"Username of the sub account."},"note":{"type":["string","null"],"description":"Note for the sub account."},"number_of_ips":{"type":"integer","description":"Number of IPs allocated to the sub account."},"traffic_data":{"type":"integer","description":"Amount of traffic allocated to the sub account (in bytes)."},"status":{"$ref":"#/components/schemas/SubAccountStatus","description":"Current status of the sub account."},"created_at":{"type":"integer","description":"Timestamp when the sub account was created."},"setting":{"type":"object","properties":{"auto_add_ips":{"type":"integer","description":"Enable or disable automatic IP allocation from the main account."},"auto_add_when_number_ips":{"type":"integer","description":"Threshold for automatically adding IPs to the sub account."},"number_ips_auto_add":{"type":"integer","description":"Number of IPs to automatically add when auto-add is triggered."},"auto_disable_at":{"type":["integer","null"],"description":"Timestamp when the sub account will be automatically disabled."},"auto_add_traffic":{"type":"integer","description":"Enable or disable automatic traffic allocation from the main account."},"auto_add_when_traffic_bellow":{"type":"integer","description":"Threshold for automatically adding traffic to the sub account."},"amount_traffic_auto_add":{"type":"integer","description":"Amount of traffic to automatically add when auto-add is triggered (in bytes)."},"traffic_plan_use_auto_add":{"type":["integer","null"],"description":"ID of the traffic plan used for automatic traffic allocation."}}}}},"SubAccountStatus":{"type":"integer","description":"Sub account status.\n1 = Enabled\n2 = Disabled"}}}}
```

## The SubAccountStatus object

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"components":{"schemas":{"SubAccountStatus":{"type":"integer","description":"Sub account status.\n1 = Enabled\n2 = Disabled"}}}}
```

## The ResponseListSubAccount object

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"components":{"schemas":{"ResponseListSubAccount":{"type":"object","description":"Returns the list of sub accounts for the user.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"result":{"type":"object","description":"Response data.","properties":{"items":{"type":"array","description":"Array of sub accounts.","items":{"$ref":"#/components/schemas/SubAccountInfo"}},"total_items":{"type":"integer","description":"Total number of items."},"total_pages":{"type":"integer","description":"Total number of pages."}}}}},"SubAccountInfo":{"type":"object","description":"Information about a sub account.","properties":{"id":{"type":"integer","description":"ID of the sub account."},"username":{"type":"string","description":"Username of the sub account."},"note":{"type":["string","null"],"description":"Note for the sub account."},"number_of_ips":{"type":"integer","description":"Number of IPs allocated to the sub account."},"traffic_data":{"type":"integer","description":"Amount of traffic allocated to the sub account (in bytes)."},"status":{"$ref":"#/components/schemas/SubAccountStatus","description":"Current status of the sub account."},"created_at":{"type":"integer","description":"Timestamp when the sub account was created."},"setting":{"type":"object","properties":{"auto_add_ips":{"type":"integer","description":"Enable or disable automatic IP allocation from the main account."},"auto_add_when_number_ips":{"type":"integer","description":"Threshold for automatically adding IPs to the sub account."},"number_ips_auto_add":{"type":"integer","description":"Number of IPs to automatically add when auto-add is triggered."},"auto_disable_at":{"type":["integer","null"],"description":"Timestamp when the sub account will be automatically disabled."},"auto_add_traffic":{"type":"integer","description":"Enable or disable automatic traffic allocation from the main account."},"auto_add_when_traffic_bellow":{"type":"integer","description":"Threshold for automatically adding traffic to the sub account."},"amount_traffic_auto_add":{"type":"integer","description":"Amount of traffic to automatically add when auto-add is triggered (in bytes)."},"traffic_plan_use_auto_add":{"type":["integer","null"],"description":"ID of the traffic plan used for automatic traffic allocation."}}}}},"SubAccountStatus":{"type":"integer","description":"Sub account status.\n1 = Enabled\n2 = Disabled"}}}}
```

## The ResponseCreateSubAccount object

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"components":{"schemas":{"ResponseCreateSubAccount":{"type":"object","description":"Returns the newly created sub account.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"result":{"type":"object","description":"New sub account information.","$ref":"#/components/schemas/SubAccountInfo"}}},"SubAccountInfo":{"type":"object","description":"Information about a sub account.","properties":{"id":{"type":"integer","description":"ID of the sub account."},"username":{"type":"string","description":"Username of the sub account."},"note":{"type":["string","null"],"description":"Note for the sub account."},"number_of_ips":{"type":"integer","description":"Number of IPs allocated to the sub account."},"traffic_data":{"type":"integer","description":"Amount of traffic allocated to the sub account (in bytes)."},"status":{"$ref":"#/components/schemas/SubAccountStatus","description":"Current status of the sub account."},"created_at":{"type":"integer","description":"Timestamp when the sub account was created."},"setting":{"type":"object","properties":{"auto_add_ips":{"type":"integer","description":"Enable or disable automatic IP allocation from the main account."},"auto_add_when_number_ips":{"type":"integer","description":"Threshold for automatically adding IPs to the sub account."},"number_ips_auto_add":{"type":"integer","description":"Number of IPs to automatically add when auto-add is triggered."},"auto_disable_at":{"type":["integer","null"],"description":"Timestamp when the sub account will be automatically disabled."},"auto_add_traffic":{"type":"integer","description":"Enable or disable automatic traffic allocation from the main account."},"auto_add_when_traffic_bellow":{"type":"integer","description":"Threshold for automatically adding traffic to the sub account."},"amount_traffic_auto_add":{"type":"integer","description":"Amount of traffic to automatically add when auto-add is triggered (in bytes)."},"traffic_plan_use_auto_add":{"type":["integer","null"],"description":"ID of the traffic plan used for automatic traffic allocation."}}}}},"SubAccountStatus":{"type":"integer","description":"Sub account status.\n1 = Enabled\n2 = Disabled"}}}}
```

## The ResponseUpdateSubAccount object

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"components":{"schemas":{"ResponseUpdateSubAccount":{"type":"object","description":"Returns the update status of the sub account.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"result":{"type":"object","properties":{"updated":{"type":"boolean"}}}}}}}}
```

## The ResponseDeleteSubAccount object

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"components":{"schemas":{"ResponseDeleteSubAccount":{"type":"object","description":"Returns the deletion status of the sub account.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"result":{"type":"object","properties":{"deleted":{"type":"boolean"}}}}}}}}
```

## The ResponseForbiddenError object

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"components":{"schemas":{"ResponseForbiddenError":{"type":"object","description":"Response returned when authentication fails.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"errors":{"type":"array","description":"List of error messages.","items":{"type":"string"}}}}}}}
```

## The ResponseBadRequestError object

```json
{"openapi":"3.1.1","info":{"title":"Sub Account","version":"1.0"},"components":{"schemas":{"ResponseBadRequestError":{"type":"object","description":"Response returned when the request is invalid.","properties":{"success":{"type":"boolean","description":"Indicates whether the request was successful."},"message":{"type":"string","description":"Response message."},"errors":{"type":"array","description":"List of error messages.","items":{"type":"string"}}}}}}}
```
