Skip to main content

Admin Customer — Python SDK

End-customer (bizUser) lifecycle: list, create, delete.

Overview​

The admin Customer resource manages end-customers (the bizUser layer — the actual paying users under the admin's tenant), distinct from admin operators themselves. For partner_admin, the scope is the admin's own tenant; for sys_admin, scope is broader per backend policy.

Accessed via admin.customer.

Available Operations​

MethodDescription
list()List end-customers under the admin's scope
create()Create a new end-customer
delete()Delete an end-customer by id

list​

List end-customers under the current admin's scope, paginated. Supports fuzzy search by user_name.

Example Usage​

result = admin.customer.list(page_num=1, page_size=20)
print(f"total: {result['total']}")
for it in result["list"]:
print(it["id"], it["userName"], it["email"])

Search by name:

result = admin.customer.list(user_name="acme", page_num=1, page_size=10)

Parameters​

ParameterTypeRequiredDefaultDescription
page_numintNo1Page number, starting from 1
page_sizeintNo10Items per page
user_namestrNo--Fuzzy search by userName

Response​

Returns a dict with total, list, totalPages, currentPage, pageSize. Each item exposes id, userName, email, phone, timezone, createdAtUtc, updatedAtUtc, userType, parentId, etc.

Errors​

CodeExceptionWhen
2007PermissionErrorAdmin lacks Customer Management permission
3001AuthenticationErrorSession expired and refresh failed

create​

Create a new end-customer under the current admin's tenant. Returns True on success; the created id is not echoed — recover it via list() with the matching user_name if needed.

Example Usage​

ok = admin.customer.create(
user_name="acme-user-1",
password="StrongPass!",
email="user1@acme.example",
)
print(ok) # True

Recover the created id:

result = admin.customer.list(user_name="acme-user-1", page_num=1, page_size=1)
new_id = result["list"][0]["id"]

Parameters​

ParameterTypeRequiredDefaultDescription
user_namestrYes--New customer userName (must be unique in scope)
passwordstrYes--Initial password (server-side bcrypt-hashed)
emailstrNo--Contact email
phonestrNo--Contact phone
timezonestrNoAsia/ShanghaiIANA timezone

Response​

Returns bool — True on success. On failure raises the appropriate exception.

Errors​

CodeExceptionWhen
1001ValidationErrorMissing required field, weak password, or bad email format
2007PermissionErrorAdmin lacks Customer Management permission
3001AuthenticationErrorSession expired and refresh failed
Server 4xxWltErrorDuplicate user_name in the tenant scope

delete​

Delete an end-customer by id.

Example Usage​

ok = admin.customer.delete(user_id=42)
print(ok) # True

# Verify no residue
remaining = admin.customer.list(user_name="acme-user-1", page_num=1, page_size=10)
assert len(remaining["list"]) == 0

Parameters​

ParameterTypeRequiredDefaultDescription
user_idintYes--End-customer id to delete

Response​

Returns bool — True on success.

Errors​

CodeExceptionWhen
1001ValidationErrorInvalid user_id
2007PermissionErrorAdmin lacks Customer Management permission
3001AuthenticationErrorSession expired and refresh failed
Server 4xxWltErrorCustomer does not exist or is out of scope

Typical lifecycle​

The full create → verify → delete → verify pattern (useful for provisioning scripts and integration tests):

temp = "provisioning-test"
ok = admin.customer.create(user_name=temp, password="StrongPass!", email="t@example.com")
found = admin.customer.list(user_name=temp, page_num=1, page_size=1)
new_id = found["list"][0]["id"]

# ... do work under `new_id` ...

admin.customer.delete(user_id=new_id)
after = admin.customer.list(user_name=temp, page_num=1, page_size=10)
assert len(after["list"]) == 0