How to set threshold, units and rollover in bandwidth after creating a site via api?

Hi everyone.

I am building a backend logic using nest.js, so I created a site via api called admin_add_site function.
Now I want to configure bandwidth with threshold, units and rollover, but I can’t find any apis to configure these values with my custom value.
When creating a site, threshold, units and rollover values set as default.
Here is an api document link.

https://api.apiscp.com/Bandwidth_Module.html

Please guide me how to update default value in bandwidth via api.
Thanks.

All Appliance Administrator methods are namespaced into the “admin” module, including EditDomain’s API counterpart.

I’m not sure diving headfirst into the API of this product without using the panel first is the right way to go about things. These are things that can be elucidated by looking at how the UI does it or referring back to documentation.

Thanks for your reply.
But how to verify or know which ones are Appliance Administrator methods?
That’s my problem.

command aliases_domain_exists' does not exist - #2 by msaladna or looking at $exportedFunctions property for each module. misc:i allows method introspection, which is the same thing as viewing API documentation.

I don’t understand exactly.

Admin_Module is allowed for apiscp panel’s admin user, and other modules are allowed for user role. Of course, admin can access to user role’s apis with session id.
Is this correct?

# cpcmd -ladmin:*
admin:
  - activate_license
  - activate_site
  - add_site
  - bless
  - collect
  - create_from_meta
  - deactivate_site
  - delete_site
  - edit_site
  - get_address_from_domain
  - get_domains
  - get_email
  - get_meta_from_domain
  - get_meta_from_site
  - get_plan
  - get_service_info
  - get_site_id_from_admin
  - get_site_id_from_domain
  - get_site_storage
  - get_storage
  - get_usage
  - hijack
  - kill_site
  - list_failed_webapps
  - list_plans
  - locate_webapps
  - prune_webapps
  - read_map
  - renew_license
  - reset_webapp_failure
  - set_email
  - suspend_site
  - update_webapps

# cpcmd -d site2 -ladmin:*
{  }

# cpcmd -lsite:*
site:
  - bless
 
# cpcmd -d site2 -lsite:*
site:
  - amnesty_active
  - get_account_quota
  - get_admin_email
  - get_bandwidth_rollover
  - get_bandwidth_usage
  - get_port_range
  - hijack
  - ip_address
  - kill_user
  - set_admin_email
  - storage_amnesty
  - user_service_enabled
  - wipe

I’d strongly encourage playing around with the CLI or even UI before diving into the API.

Ok, I will try with CLI first.
Thank you so much for your help.

Actually, if you do what you’re told, and work with the Panel, you’ll find the answers.
For example, in Nexus, if you enable SSH and Crontab, you’ll see a confirmation of the command that was run. You can then apply that via the API to accomplish the same task.

/usr/local/apnscp/bin/EditDomain --fd=%d --output=json -c 'auth,iprestrict'='DEFAULT' -c 'crontab,enabled'='1' -c 'ssh,enabled'='1' %s

1 Like

Ok, I tried to enable crontab and ssh in UI, so yes I can see success message with what command lines were run, which is good.
But how to run this via api?
I saw this api document.
https://api.apiscp.com/Crontab_Module.html

There is no function to enable crontab, actually this is what my problem is for now.
Please let me know how to convert or know which function I have to use for example.
Thanks.

See also Why can't I enable crontab via api? - #2 by msaladna

Please do not spillover topics into other topics. This is a speedrun to draw my ire.