Superuser Management
For changing the team directly through API, the key holder must be an superuser for the deployment.
User CREATE
API key holder must be an superuser for the deployment.
Sapling accounts can be created directly through this API.
Caution should be taken around how passwords are generated or stored.
Request Parameters
import requests
key = '<api-key>'
url = 'https://api.sapling.ai/api/v1/create_user'
data = {
'key': key,
'email': '<user_email>',
'first_name': '<first_name>',
'last_name': '<last_name>',
'password': '<password>',
}
try:
resp = requests.post(url, json=data)
if 200 <= resp.status_code < 300:
print('Success')
else:
resp_json = resp.json()
print('Error: ', resp_json)
except Exception as e:
print('Error: ', e)
https://api.sapling.ai/api/v1/create_user
HTTP method: POST
key: String
32-character API key
email: String
Email of user to create an account for
password: String
Password of new user account. Minimum length of 8 characters. Always salt and hash user created passwords when storing.
first_name: String
First or given name of user
last_name: String
Last or family name of user
email_confirmed: Optional Boolean
Defaults to false. If true, user account will be created with full account privileges. If false or not specified, an email will be send with a unique link to the email specified, and the account owner will need to verify their email.
Response Parameters
HTTP status code 201.
User DELETE
API key holder must be an superuser for the deployment.
Request Parameters
import requests
key = '<api-key>'
url = 'https://api.sapling.ai/api/v1/delete_user'
data = {
'key': key,
'email': '<user_email>',
}
try:
resp = requests.post(url, json=data)
if 200 <= resp.status_code < 300:
print('Success')
else:
resp_json = resp.json()
print('Error: ', resp_json)
except Exception as e:
print('Error: ', e)
https://api.sapling.ai/api/v1/delete_user
HTTP method: POST
key: String
32-character API key
email: String
Email of user to delete from deployment
Response Parameters
Empty, HTTP status code 204.
Non-team Users GET
API key holder must be an superuser for the deployment.
Request Parameters
import requests
key = '<api-key>'
url = f'https://api.sapling.ai/api/v1/user/nonteam?key={key}'
try:
resp = requests.get(url)
if 200 <= resp.status_code < 300:
print('Success')
else:
resp_json = resp.json()
print('Error: ', resp_json)
except Exception as e:
print('Error: ', e)
https://api.sapling.ai/api/v1/user/nonteam?key=<key>
HTTP method: GET
key: String
32-character API key
Response Parameters
JSON array of User Entries not yet associated with a team, under key “users”
Non-Team User Entry Structure:
{
"login_email": <str>,
"first_name": <str>,
"last_name": <str>,
"created_at": <str, date> // e.g. "Wed, 07 Oct 2020 21:15:47 GMT"
}
User Count
API key holder must be an superuser for the deployment.
Request Parameters
import requests
key = '<api-key>'
url = f'https://api.sapling.ai/api/v1/user/count?key={key}'
try:
resp = requests.get(url)
resp_json = resp.json()
if 200 <= resp.status_code < 300:
print('Counts: ', resp_json)
else:
print('Error: ', resp_json)
except Exception as e:
print('Error: ', e)
https://api.sapling.ai/api/v1/user/count?key=<key>
HTTP method: GET
<key>: String
32-character API key
Response Parameters
user_count: Integer
Count of total users on deployment
team_user_count: Integer
Count of users assigned to a team