Skip to main content

TenantsApi

Struct TenantsApi 

Source
pub struct TenantsApi { /* private fields */ }
Expand description

Tenant management and API keys

Implementations§

Source§

impl TenantsApi

Source

pub async fn accept_invite_from_picker( &self, tenant_id: &str, invite_id: &str, body: &AcceptInviteFromPickerRequest, ) -> Result<AcceptInviteFromPickerResponse>

Accept a pending invite from the tenant picker

The tenant is in the PATH, and that is the whole reason this route exists beside POST /api/v1/users/invites/{inviteId}/accept. The older route resolves the invite against the caller’s active tenant, which cannot work here: the caller is not a member of the inviting tenant yet — making them one is what the call is for. Without a tenant-in-path route the picker’s Accept button can never succeed for a cross-tenant invite.

Semantics are otherwise identical to the older route: the same atomic create-user + email index + membership index + invite.status = accepted write.

Four refusals, and they are different questions: 403 the invite is addressed to another email, or the token does not match; 409 the invite is not pending (already accepted, revoked, declined) or the email already belongs to a member; 410 the invite has expired; 404 no such invite, or the caller has no user record.

POST /api/v1/me/invites/{tenantId}/{inviteId}/accept

Source

pub async fn create_api_key( &self, body: &CreateAPIKeyRequest, ) -> Result<APIKeyResponse>

Create a new API key

POST /api/v1/tenants/me/keys

Required scopes: tenants:write.

Source

pub async fn create_my_tenant( &self, body: &CreateMyTenantRequest, ) -> Result<CreateMyTenantResponse>

Create a new tenant with the caller as owner

Provisions a brand-new tenant on the free plan (or enterprise for super-admin). The caller becomes the founding owner. Onboarding wizard auto-runs on /browser to provision the Head Agent.

POST /api/v1/me/tenants/create

Source

pub async fn decline_invite_from_picker( &self, tenant_id: &str, invite_id: &str, ) -> Result<DeclineInviteFromPickerResponse>

Decline a pending invite

Deliberately distinct from an admin’s revoke, so the audit trail and the Members page can tell “the invitee said no” from “an admin pulled it”. The caller’s email must match the invite’s — without that check anyone with a current session could decline someone else’s invites.

No token is required here, unlike accept: declining grants nothing.

POST /api/v1/me/invites/{tenantId}/{inviteId}/decline

Source

pub async fn get_current_tenant(&self) -> Result<Tenant>

Get current tenant

Returns the calling tenant’s profile. Any authenticated key passes — no scope required.

GET /api/v1/tenants/me

Required scopes: api_keys:read.

Source

pub async fn get_my_head_agent_template( &self, ) -> Result<GetMyHeadAgentTemplateResponse>

Tiered Head Agent template for the onboarding wizard

Returns Basic/Standard/Full tier metadata for the current tenant under the Variant-A SPEC-driven contract. Each tier names the @platform/* SPECs the wizard installs (via install_specs) plus an auto_approve_tools HITL list. Availability is a plan-rank check (required_plan); locked tiers ship empty install_specs.

GET /api/v1/me/head-agent-template

Source

pub async fn get_tenant_domain_health( &self, ) -> Result<GetTenantDomainHealthResponse>

DNS and certificate state for this tenant’s custom domain

Two different 404s, and a client should tell them apart: no such tenant, and a tenant with no custom domain configured. The second is the ordinary state of most tenants and is not an error condition — a UI that renders both as a failure will report a fault to every customer who has not set up a vanity domain.

Records written before the lifecycle schema are lifted on read, so dns and cert are present here even for a domain added under the old flat fields.

GET /api/v1/tenants/me/domain/health

Required scopes: api_keys:read.

Source

pub async fn leave_tenant(&self, tenant_id: &str) -> Result<LeaveTenantResponse>

Leave a tenant

Removes the caller’s own membership. The user-record cascade matches an admin-driven removal.

Two refusals, both 409, and both name a specific thing to do first. The caller is the only ACTIVE owner: transfer ownership before leaving. Or the caller is the only veto-holding ambassador: rotate the founder ambassador via /api/v1/governance/ambassadors first. The second check is skipped entirely when governance is not enabled, so its absence is not a promise that no such constraint exists.

DELETE /api/v1/me/memberships/{tenantId}

Source

pub async fn list_api_keys(&self) -> Result<ListAPIKeysResponse>

List API keys

GET /api/v1/tenants/me/keys

Required scopes: api_keys:read.

Source

pub async fn list_my_tenants(&self) -> Result<ListMyTenantsResponse>

List the caller’s tenant memberships + pending invites

Returns every tenant the calling user is a member of, plus any pending invites addressed to their email. Used by the Netflix-style picker (/browser/tenants).

GET /api/v1/me/tenants

Source

pub async fn locate_my_agent( &self, agent_id: &str, ) -> Result<LocateMyAgentResponse>

Find which tenant owns the given agent across caller’s memberships

Used by the chat layout fallback when the URL points at an agent under a different active tenant. Returns the owning tenant_id in one round-trip; the alternative was N client-side probes that surfaced expected 404s in the browser console.

GET /api/v1/me/agents/{agentId}/locate

Source

pub async fn patch( &self, body: &Map<String, Value>, ) -> Result<Map<String, Value>>

Partial update tenant

Partial update of tenant settings. Requires the tenants:write scope and role owner.

PATCH /api/v1/tenants/me

Required scopes: tenants:write.

Source

pub async fn revoke_api_key(&self, key_id: &str) -> Result<RevokeAPIKeyResponse>

Revoke an API key

DELETE /api/v1/tenants/me/keys/{keyId}

Required scopes: tenants:write.

Source

pub async fn update(&self, body: &UpdateTenantRequest) -> Result<Value>

Update current tenant settings

PUT /api/v1/tenants/me

Required scopes: tenants:write.

Source

pub async fn verify_tenant_domain( &self, body: &Map<String, Value>, ) -> Result<VerifyTenantDomainResponse>

Verify domain

POST /api/v1/tenants/me/domain/verify

Required scopes: tenants:write.

Trait Implementations§

Source§

impl Clone for TenantsApi

Source§

fn clone(&self) -> TenantsApi

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TenantsApi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more