Skip to content

admin

Admin endpoint handlers.

AdminEndpoint

Bases: BaseEndpoint

Handle admin-specific API endpoints.

Provide methods for accounts, organizations (their limits and credits), and platform statistics. All methods require admin role.

adjust_organization_credits(org_id, adjustment) async

Add to or deduct from an organization's purchased credits.

A deduction never takes credits held for running analyses, so less than requested may be deducted.

Parameters:

Name Type Description Default
org_id UUID | str

The organization id.

required
adjustment CreditAdjustment

The signed amount and the reason, kept on the ledger.

required

Returns:

Type Description
AdminOrganizationDetailOut

The organization with its new balance

Raises:

Type Description
NotFoundError

If the organization does not exist

ForbiddenError

If not an admin user

Example
org = await client.admin.adjust_organization_credits(
    org_id, CreditAdjustment(amount=50, reason="Pilot study")
)
print(org.credits.purchased.available)

approve_capability_request(request_id) async

Approve a request for a capability, which turns the capability on.

Refused unless the organization's owner has accepted the latest published site agreement, or the platform operates the organization.

Parameters:

Name Type Description Default
request_id UUID | str

The request id.

required

approve_credit_request(request_id, approval=None) async

Approve a grant or extension request, as asked or with changes.

Approving a grant request makes the grant; approving an extension moves the grant's expiry. The requester is emailed the decision.

Parameters:

Name Type Description Default
request_id UUID | str

The request id.

required
approval AdminCreditRequestApprove | None

A different amount or term, and a note for administrators; the request's own when omitted.

None

approve_runner(runner_id, fingerprint) async

Approve a pending runner, with the fingerprint read on its host.

The runner prints its key's fingerprint when it enrols. Compare it with the one on the host, not one passed along by someone else: the platform refuses an approval whose fingerprint differs from the enrolled key's.

Parameters:

Name Type Description Default
runner_id UUID | str

The runner to approve.

required
fingerprint str

The whole fingerprint, SHA256:….

required

Returns:

Type Description
RunnerOut

The runner, now active.

Raises:

Type Description
YouSleepClientError

If the fingerprint differs or the runner is not pending (409)

NotFoundError

If the runner does not exist

ForbiddenError

If not an admin user

approve_user(user_id) async

Approve a pending request-access account so its owner can log in.

Idempotent — approving an already-approved account is a no-op. To decline a request instead, use :meth:reject_user.

Parameters:

Name Type Description Default
user_id UUID | str

UUID of the pending user to approve

required

Returns:

Type Description
AdminUserOut

The approved user (approved_at now set)

Raises:

Type Description
NotFoundError

If user does not exist

ForbiddenError

If not an admin user

Example
for u in (await client.admin.list_users(pending=True)).users:
    await client.admin.approve_user(u.id)

cancel_analyses(request) async

Cancel analyses across accounts, one bounded page per call.

Address them by explicit ids, by a filter (an account, a set of live states, or both) with the count seen on the listing, or by all with that count. A live-set selector whose count moved since it was previewed is refused with a conflict. Each call handles at most the server's per-request cap; loop on summary.remaining.

Parameters:

Name Type Description Default
request AdminCancelAnalysesRequest

The selector and, for a live set, the expected count

required

Returns:

Type Description
AdminCancelAnalysesResponse

Per-item results and the page summary, including what remains

Raises:

Type Description
ConflictError

If a live set's count moved since it was previewed

ForbiddenError

If not an admin user

Example
page = await client.admin.list_analyses(user_id=user_id,
    status_any=[AnalysisStatus.PENDING])
request = AdminCancelAnalysesRequest(
    selector={"filter": {"user_id": user_id,
                         "status_any": [AnalysisStatus.PENDING]}},
    expected_count=page.total,
)
result = await client.admin.cancel_analyses(request)
while result.summary.remaining and result.summary.cancelled:
    request.expected_count = result.summary.remaining
    result = await client.admin.cancel_analyses(request)

clear_control(name) async

Clear a control's override; the configured value applies again at once.

Parameters:

Name Type Description Default
name PlatformControlName | str

The control

required

Returns:

Type Description
PlatformControlOut

The control as it now reads

Raises:

Type Description
ForbiddenError

If not an admin user

create_demo_dataset(dataset) async

Register a new demo dataset (or replace an existing one by name).

Parameters:

Name Type Description Default
dataset AdminDemoDatasetCreate

Demo dataset definition including studies and S3 keys

required

Returns:

Type Description
AdminDemoDatasetOut

The created/updated demo dataset with study and recording counts

Raises:

Type Description
ForbiddenError

If not an admin user

create_enrolment_token(pool_id) async

Create a single-use token a runner enrols into a pool with.

The token is in this answer only and is never shown again. Give it to the runner's installer, who passes it on standard input.

Parameters:

Name Type Description Default
pool_id UUID | str

The pool the runner joins.

required

Returns:

Type Description
EnrolmentTokenOut

The token and when it expires.

Raises:

Type Description
NotFoundError

If the pool does not exist

ForbiddenError

If not an admin user

create_user(user) async

Provision a new user.

Parameters:

Name Type Description Default
user AdminUserCreate

User creation data (email, password, subscription level, etc.)

required

Returns:

Type Description
AdminUserOut

The newly created user

Raises:

Type Description
ValidationError

If user data is invalid

ForbiddenError

If not an admin user

Example
new_user = await client.admin.create_user(
    AdminUserCreate(
        email="researcher@example.com",
        password="SecurePass123!",
        credits=100,
    )
)
print(f"Created user {new_user.id}")

decline_capability_request(request_id, decline) async

Decline a request for a capability, with the reason the organization is shown.

Parameters:

Name Type Description Default
request_id UUID | str

The request id.

required
decline AdminCapabilityRequestDecline

The reason.

required

decline_credit_request(request_id, decline) async

Decline a grant or extension request with a reason the requester is sent.

Parameters:

Name Type Description Default
request_id UUID | str

The request id.

required
decline AdminCreditRequestDecline

The reason, a note for administrators, and whether to email the requester.

required

delete_demo_dataset(dataset_id) async

Delete a demo dataset catalog entry. Does not delete S3 files.

Parameters:

Name Type Description Default
dataset_id UUID | str

UUID of the demo dataset to delete

required

Returns:

Type Description
MessageResponse

Message confirming deletion

Raises:

Type Description
NotFoundError

If dataset does not exist

ForbiddenError

If not an admin user

delete_project(project_id) async

Delete any account's project, with everything in it, in the background.

The deletion runs as the project's owner would run it and is written to the audit trail under your account. A second call while one is still running starts nothing new.

Parameters:

Name Type Description Default
project_id UUID | str

UUID of the project

required

Returns:

Type Description
MessageResponse

Message saying the deletion started, or is already running

Raises:

Type Description
NotFoundError

If the project does not exist

ForbiddenError

If not an admin user

delete_user(user_id) async

Delete a user.

Parameters:

Name Type Description Default
user_id UUID | str

UUID of the user to delete

required

Returns:

Type Description
MessageResponse

Message confirming deletion

Raises:

Type Description
NotFoundError

If user does not exist

ForbiddenError

If not an admin, or if attempting to delete own account

Example
result = await client.admin.delete_user(user_id)
print(result.message)  # "User deleted successfully."

export_audit_events(filters=None, *, org_id=None, actor=None, email=None) async

Return the audit trail as CSV text, oldest first, under the same filters.

get_health() async

Read the API's health, dependency by dependency.

The public health check reports only the overall status; this is the breakdown behind it. The call answers even when a dependency is down, so read the fields rather than expecting an error.

Returns:

Type Description
AdminHealthDetail

The overall status and one field per dependency

Raises:

Type Description
ForbiddenError

If not an admin user

Example
health = await client.admin.get_health()
if health.status != "ok":
    print(health.postgres, health.redis, health.runners)

get_organization(org_id) async

Return one organization with its members, as the operators see it.

Parameters:

Name Type Description Default
org_id UUID | str

The organization id.

required

Raises:

Type Description
NotFoundError

If the organization does not exist

ForbiddenError

If not an admin user

get_organization_credit_totals(org_id) async

Get an organization's all-time net credit movement per ledger reason.

Signed sums keyed by the CreditReason wire value (grants positive, charges negative): what the organization received and spent, by kind.

Parameters:

Name Type Description Default
org_id UUID | str

The organization id

required

Returns:

Type Description
dict[str, int]

Mapping of reason -> net credits, e.g. {"grant": 300, "charge": -120}

Raises:

Type Description
NotFoundError

If the organization does not exist

ForbiddenError

If not an admin user

get_platform_stats() async

Get platform-wide statistics.

Returns:

Type Description
PlatformStats

Statistics including user counts, resource counts,

PlatformStats

and subscription level breakdown

Raises:

Type Description
ForbiddenError

If not an admin user

Example
stats = await client.admin.get_platform_stats()
print(f"Total users: {stats.total_users}")
print(f"Active: {stats.active_users}, Disabled: {stats.disabled_users}")
print(f"Recordings: {stats.total_recordings}")

get_storage_reconciliation() async

Read the last storage reconciliation report.

The reconciliation compares each data bucket's objects with the storage records that reference them, both ways. It runs on a schedule, and :meth:run_storage_reconciliation starts one now.

Returns:

Type Description
StorageReconciliationReport | None

The last report, or None when no report is stored: none has run

StorageReconciliationReport | None

yet, or the last one has expired

Raises:

Type Description
ForbiddenError

If not an admin user

Example
report = await client.admin.get_storage_reconciliation()
if report is not None and report.missing_total:
    for name, bucket in report.buckets.items():
        print(name, bucket.missing, bucket.missing_sample)

get_user(user_id) async

Get detailed information about a specific user.

Parameters:

Name Type Description Default
user_id UUID | str

UUID of the user to retrieve

required

Returns:

Type Description
AdminUserOut

The account's details, permissions and admin fields

Raises:

Type Description
NotFoundError

If user does not exist

ForbiddenError

If not an admin user

Example
user = await client.admin.get_user("550e8400-e29b-41d4-a716-446655440000")
print(f"{user.email}: disabled={user.disabled}")

get_user_organization(user_id) async

Return the organization an account belongs to, as that member sees it.

Every account belongs to exactly one organization; this is how an operator finds its id and the member's role before acting on it.

Parameters:

Name Type Description Default
user_id UUID | str

UUID of the account

required

Raises:

Type Description
NotFoundError

If the account does not exist

ForbiddenError

If not an admin user

get_user_usage(user_id) async

Get resource usage statistics for a specific user.

Parameters:

Name Type Description Default
user_id UUID | str

UUID of the user to retrieve usage for

required

Returns:

Type Description
ResourceUsage

Resource usage including projects, studies, recordings,

ResourceUsage

analyses, reports, analysis hours, and storage

Raises:

Type Description
NotFoundError

If user does not exist

ForbiddenError

If not an admin user

Example
usage = await client.admin.get_user_usage(user_id)
print(f"Projects: {usage.projects.active}/{usage.projects.all_time}")
print(f"Storage: {usage.storage.active} bytes")

grant_credits(org_id, grant) async

Grant an organization research credits directly.

Parameters:

Name Type Description Default
org_id UUID | str

The organization id.

required
grant AdminGrantCreate

The amount, the term (none for a grant that never expires) and the reason, kept with the grant.

required

Returns:

Type Description
CreditGrant

The new grant.

list_analyses(*, status_any=None, user_id=None, user_email=None, org_id=None, analysis_config_id=None, failure_code=None, since=None, until=None, include_deleted=False, offset=0, limit=50) async

List analyses across every account, newest first.

The operator's view of the queue and of recent outcomes: each row is the analysis as its owner sees it plus the owner's account and email, the credits charged or held, and the process exit code. Filters combine.

Parameters:

Name Type Description Default
status_any list[AnalysisStatus] | None

Only analyses in at least one of these states

None
user_id UUID | str | None

Only analyses owned by this account

None
user_email str | None

Only analyses owned by the account with exactly this email

None
org_id UUID | str | None

Only analyses of this organization

None
analysis_config_id str | None

Only analyses of this configuration (string identity); an unknown identity matches nothing

None
failure_code ErrorCode | None

Only failed analyses with this failure code

None
since datetime | None

Only analyses enqueued at or after this time

None
until datetime | None

Only analyses enqueued before this time

None
include_deleted bool

Also list soft-deleted analyses, with their deletion time

False
offset int

Pagination offset (default: 0)

0
limit int

Maximum analyses to return (default: 50, max: 200)

50

Returns:

Type Description
AdminAnalysisListResponse

One page and the total the filters match

Raises:

Type Description
ForbiddenError

If not an admin user

Example
waiting = await client.admin.list_analyses(
    status_any=[AnalysisStatus.PENDING, AnalysisStatus.ENQUEUED]
)
for row in waiting.analyses:
    print(row.user_email, row.analysis_config_name, row.enqueue_time)

list_analysis_configs() async

List every registered analysis and who it is offered to.

Includes private analyses of every organization and withdrawn ones, each with the reason a promotion would be refused, if it would be.

Raises:

Type Description
ForbiddenError

If not an admin user

list_audit_events(filters=None, *, user_id=None, org_id=None, action=None, actor=None, email=None, since=None, until=None, offset=0, limit=50) async

Read the whole audit trail, newest first.

Every privileged or automated action on an account or its data, as recorded. Read-only: nothing writes to the trail through the API.

Parameters:

Name Type Description Default
filters AuditFilters | None

The views' filters (event types, time window, person, item)

None
user_id UUID | str | None

Only events concerning this account

None
org_id UUID | str | None

Only events concerning this organization

None
action str | None

Only events recording this action (the vocabulary: client.status.audit_actions())

None
actor str | None

Only events by exactly this actor, e.g. admin:<user id>

None
email str | None

Only events concerning the account with this email — the one it has now, or the one it had before it was deleted

None
since datetime | None

Only events at or after this time

None
until datetime | None

Only events before this time

None
offset int

Pagination offset (default: 0)

0
limit int

Maximum events to return (default: 50, max: 200)

50

Returns:

Type Description
AuditEventListResponse

One page of events and the total the filters match

Raises:

Type Description
ForbiddenError

If not an admin user

list_capability_requests(status=None, limit=50, offset=0) async

Return requests for capabilities across organizations.

Parameters:

Name Type Description Default
status CapabilityRequestStatus | None

Only requests in this state; all when omitted.

None
limit int

Maximum requests to return.

50
offset int

Requests to skip.

0

Returns:

Type Description
AdminCapabilityRequestPage

The page: pending requests first, oldest first.

list_compute_pools(*, offset=0, limit=50) async

List the compute pools, with the lease period and queue timeout in force.

The platform's own pool is named platform and has no organization.

Parameters:

Name Type Description Default
offset int

Pagination offset (default: 0).

0
limit int

Maximum pools to return (default: 50, max: 200).

50

Returns:

Type Description
ComputePoolListResponse

One page of pools, with the total.

Raises:

Type Description
ForbiddenError

If not an admin user

list_controls() async

Read every operator control.

For each: the configured default, the live override if any, and the effective value.

Returns:

Type Description
PlatformControlsOut

Every known control

Raises:

Type Description
ForbiddenError

If not an admin user

list_credit_requests(status=None, limit=50, offset=0) async

Return grant and extension requests across organizations.

Parameters:

Name Type Description Default
status CreditRequestStatus | None

Only requests in this state; all when omitted.

None
limit int

Maximum requests to return.

50
offset int

Requests to skip.

0

Returns:

Type Description
AdminCreditRequestPage

The page: pending requests first, oldest first.

list_demo_datasets() async

List all registered demo datasets.

Returns:

Type Description
list[AdminDemoDatasetOut]

List of demo datasets with study and recording counts

Raises:

Type Description
ForbiddenError

If not an admin user

list_organizations(*, search=None, include_retired=False, offset=0, limit=50) async

List organizations with their owner, seats, projects, storage and credits.

Parameters:

Name Type Description Default
search str | None

Filter by organization name or owner email substring (case-insensitive).

None
include_retired bool

Also list organizations that were retired (soft-deleted); off by default.

False
offset int

Pagination offset (default: 0).

0
limit int

Maximum organizations to return (default: 50, max: 200).

50

Returns:

Type Description
AdminOrganizationListResponse

One page of organizations, newest first, with the total.

Raises:

Type Description
ForbiddenError

If not an admin user

list_run_records(*, kind=None, analysis_id=None, runner_id=None, offset=0, limit=50) async

List where jobs ran and on what, as their runners attested it, newest first.

A record is written when the platform accepts a job's result, for every kind of job: its subject, the runner and pool, the runner's version, the image digest it ran, the inputs it read and the output it uploaded, its peak memory and its run length.

Parameters:

Name Type Description Default
kind LeaseKind | None

Only this kind of job's records.

None
analysis_id UUID | str | None

Only this analysis's records.

None
runner_id UUID | str | None

Only this runner's records.

None
offset int

Pagination offset (default: 0).

0
limit int

Maximum records to return (default: 50, max: 200).

50

Returns:

Type Description
RunRecordListResponse

One page of run records, with the total.

Raises:

Type Description
ForbiddenError

If not an admin user

list_runners(*, pool_id=None, offset=0, limit=50) async

List runners, newest first.

Parameters:

Name Type Description Default
pool_id UUID | str | None

Only this pool's runners.

None
offset int

Pagination offset (default: 0).

0
limit int

Maximum runners to return (default: 50, max: 200).

50

Returns:

Type Description
RunnerListResponse

One page of runners, with the total.

Raises:

Type Description
ForbiddenError

If not an admin user

list_site_exceptions(org_id, limit=50, offset=0) async

Return an organization's exception records, newest first.

An exception lets the organization run an analysis its configuration keeps on the platform at its site. Records only grow: a revocation is a record of its own, and the latest per analysis is its state.

Parameters:

Name Type Description Default
org_id UUID | str

The organization id.

required
limit int

Maximum records to return.

50
offset int

Records to skip from the newest.

0

list_user_api_keys(user_id) async

List another account's API keys — never the secret.

Parameters:

Name Type Description Default
user_id UUID | str

UUID of the account

required

Returns:

Type Description
list[ApiKeyOut]

The account's keys, newest first

Raises:

Type Description
NotFoundError

If the account does not exist

ForbiddenError

If not an admin

list_users(*, search=None, disabled=None, pending=None, organization_id=None, offset=0, limit=50, sort=None) async

List users with optional filtering, ordering and pagination.

Parameters:

Name Type Description Default
search str | None

Filter by email substring (case-insensitive)

None
disabled bool | None

Filter by disabled status

None
pending bool | None

Filter by request-access approval. True returns only accounts awaiting approval (the approval queue).

None
organization_id UUID | str | None

Only the members of this organization.

None
offset int

Pagination offset (default: 0)

0
limit int

Maximum number of users to return (default: 50, max: 200)

50
sort AdminUserSort | None

Ordering — newest first by default, most recent sign-in first (never signed in last), or by email

None

Returns:

Type Description
AdminUserListResponse

Paginated user list with total count

Raises:

Type Description
ForbiddenError

If not an admin user

Example
# The approval queue
result = await client.admin.list_users(pending=True)
print(f"{result.total} accounts awaiting approval")

queue() async

Read the queue in one call.

Live counts by status, the oldest wait, and the accounts holding the most live analyses.

Returns:

Type Description
AdminQueueSummary

The queue summary, with the time it was sampled

Raises:

Type Description
ForbiddenError

If not an admin user

record_site_exception(org_id, exception) async

Let an organization run a platform-only analysis at its site, until an expiry.

It covers every version of the analysis. Recording one for an analysis that already has one in force replaces it.

Parameters:

Name Type Description Default
org_id UUID | str

The organization id.

required
exception SiteExceptionCreate

The analysis, the agreement it rests on, and the expiry.

required

Returns:

Type Description
SiteExceptionOut

The record.

reject_user(user_id, rejection) async

Decline a pending access request and tell the applicant why.

The reason is chosen from a fixed list, and the applicant is emailed it in the platform's own wording unless notify is false. The reviewer's note is kept in the audit record and is never sent. The account is disabled at once and erased in the background, which frees the address, so an applicant declined for a fixable reason can apply again.

Only a pending account can be declined. An approved account is a conflict; disable or delete it with :meth:update_user or :meth:delete_user instead.

Parameters:

Name Type Description Default
user_id UUID | str

UUID of the pending user to decline

required
rejection AdminUserReject

The reason, the reviewer's note and whether to notify

required

Returns:

Type Description
AdminUserOut

The account as it stands at the moment of the decision

Raises:

Type Description
NotFoundError

If user does not exist

ForbiddenError

If not an admin user

YouSleepClientError

If the account has already been approved (409)

Example
from yousleep_common.models import AdminUserReject
from yousleep_common.types import RegistrationRejectionReason

await client.admin.reject_user(
    user_id,
    AdminUserReject(
        reason=RegistrationRejectionReason.PURPOSE_UNCLEAR,
        note="No description of the intended research.",
    ),
)

release_runner(runner_id) async

Release a quarantined runner, so it leases work again.

Parameters:

Name Type Description Default
runner_id UUID | str

The runner to release.

required

Returns:

Type Description
RunnerOut

The runner.

Raises:

Type Description
NotFoundError

If the runner does not exist

ForbiddenError

If not an admin user

revoke_runner(runner_id) async

Revoke a runner; it is refused from its next request on.

Parameters:

Name Type Description Default
runner_id UUID | str

The runner to revoke.

required

Returns:

Type Description
RunnerOut

The runner, now revoked.

Raises:

Type Description
NotFoundError

If the runner does not exist

ForbiddenError

If not an admin user

revoke_site_exception(org_id, analysis_config_id, revoke) async

End an organization's exception for an analysis before it expires.

Analyses already queued at the site are then failed when a runner would take them.

Parameters:

Name Type Description Default
org_id UUID | str

The organization id.

required
analysis_config_id str

The analysis, by its machine-readable id.

required
revoke SiteExceptionRevoke

Why it ends.

required

Returns:

Type Description
SiteExceptionOut

The revocation record.

revoke_user_api_key(user_id, key_id) async

Revoke another account's API key; recorded against the administrator.

Parameters:

Name Type Description Default
user_id UUID | str

UUID of the account

required
key_id UUID | str

UUID of the key

required

Returns:

Type Description
MessageResponse

A confirmation message

Raises:

Type Description
NotFoundError

If the account or the key does not exist

ForbiddenError

If not an admin

run_storage_reconciliation() async

Start a storage reconciliation now, in the background.

Read the result with :meth:get_storage_reconciliation once it has finished.

Returns:

Type Description
MessageResponse

Message saying the reconciliation was queued

Raises:

Type Description
ForbiddenError

If not an admin user

set_control(name, update) async

Set a control's override, replacing any existing one.

The override applies immediately, must carry a reason, and must expire within the server's maximum override length; setting it again with a later expiry is how it is extended.

Parameters:

Name Type Description Default
name PlatformControlName | str

The control

required
update PlatformControlUpdate

The value, the reason and the expiry

required

Returns:

Type Description
PlatformControlOut

The control as it now reads

Raises:

Type Description
ValidationError

If the expiry lies outside the allowed window

ForbiddenError

If not an admin user

set_entitlement(org_id, capability, change) async

Turn one of an organization's capabilities on or off.

On needs the owner's acceptance of the latest published site agreement, unless the platform operates the organization. Off stops new work at the organization's site; nothing already there is touched.

Parameters:

Name Type Description Default
org_id UUID | str

The organization id.

required
capability SiteCapability | str

The capability to change, or its value.

required
change AdminEntitlementChange

On or off, and why.

required

Returns:

Type Description
OrganizationCapabilities

The organization's capabilities after the change.

transfer_organization_ownership(org_id, request) async

Hand an organization to one of its members (administrator).

The recovery path when an organization's owner is unreachable. The current owner becomes an admin; both are told by email.

Parameters:

Name Type Description Default
org_id UUID | str

UUID of the organization

required
request AdminOwnershipTransfer

The member who becomes the owner

required

Raises:

Type Description
NotFoundError

If the organization or member does not exist

ForbiddenError

If not an admin user

update_analysis_config(analysis_config_id, update) async

Assign an analysis to an organization, promote it, or withdraw it.

Parameters:

Name Type Description Default
analysis_config_id str

The analysis configuration's id

required
update AdminAnalysisConfigUpdate

Only the fields provided change

required

Raises:

Type Description
NotFoundError

If no analysis has this id

YouSleepClientError

If the change is not allowed (409), with the reason

ForbiddenError

If not an admin user

Example
await client.admin.update_analysis_config(
    "yasa-sleep-staging-v1", AdminAnalysisConfigUpdate(owner_org_id=org.id)
)

update_organization(org_id, update) async

Set or clear an organization's limits and settings (only provided fields change).

The settings are whether the platform operates the organization, whether its analyses run at its site, and its own site-compute factor.

Parameters:

Name Type Description Default
org_id UUID | str

The organization id.

required
update AdminOrganizationUpdate

The overrides to set; an explicit None clears one back to the configured default.

required

Returns:

Type Description
AdminOrganizationDetailOut

The organization with the limits now in force

Raises:

Type Description
NotFoundError

If the organization does not exist

ValidationError

If a study limit passes the platform's ceiling

ForbiddenError

If not an admin user

Example
org = await client.admin.update_organization(
    org_id, AdminOrganizationUpdate(study_limit=2000, seat_limit=None)
)
print(org.effective_study_limit, org.effective_seat_limit)

update_user(user_id, update) async

Update a user's properties.

Parameters:

Name Type Description Default
user_id UUID | str

UUID of the user to update

required
update AdminUserUpdate

Fields to update (only provided fields are changed)

required

Returns:

Type Description
AdminUserOut

The updated user

Raises:

Type Description
NotFoundError

If user does not exist

ForbiddenError

If not an admin, or if attempting self-demotion/self-disable

Example
updated = await client.admin.update_user(
    user_id,
    AdminUserUpdate(position="Sleep technologist"),
)
print(f"Updated: {updated.position}")

verify_user_email(user_id) async

Mark a user's email address as verified, in place of the emailed link.

Idempotent: verifying an already-verified address is a no-op.

Parameters:

Name Type Description Default
user_id UUID | str

UUID of the user

required

Returns:

Type Description
AdminUserOut

The user, with email_confirmed_at set

Raises:

Type Description
NotFoundError

If user does not exist

ForbiddenError

If not an admin user