A language-agnostic guide for implementing secure, scalable team and organization management using SSOJet APIs.
The user is already authenticated using SSOJet OIDC (Authorization Code flow).
This skill guides developers to implement secure, scalable team and organization management using SSOJet APIs, following best coding practices and working across any language or framework (Next.js, Golang, .NET, Node.js, etc.).
Enable developers to build B2B SaaS team management by correctly handling:
Language-agnostic
Separation of concerns
Token safety
Explicit tenant context
Client Identification
client_id as a query parameter.?client_id=<management_client_id>Use Client Credentials Grant with sys_owner scope.
{
"client_id": "<client_id>",
"client_secret": "<client_secret>",
"grant_type": "client_credentials",
"scope": "sys_owner"
}
Best practices
POST /api/v1/oauth2/token/api/v1 prefix (e.g., https://api.ssojet.com/api/v1).From the user’s OIDC access token, extract:
sub → user IDDo not assume tenant membership from the token alone.
To get all organizations the user belongs to, call:
GET /users/{userId}/tenants
API Reference: List User Tenants
"Returns a complete list of all tenants the user is a member of, along with their associated roles and context within each tenant."
Rules
This is the critical "fork in the road" for B2B apps.
tenant_id in the frontend session/cookie.Call Create Tenant API (POST /tenants).
{
"name": "string",
"display_name": "string",
"domains": [ "string" ]
}
API Reference: Create Tenant
Call Add User to Tenant API (POST /tenants/{id}/users).
{
"user_ids": ["current_user_id"]
}
API Reference: Add Users to Tenant
Call List All Roles API (GET /roles) to find the Owner role ID.
API Reference: List All Roles
Call Assign User Roles API (POST /tenants/{id}/users/{uid}/roles).
{
"role_ids": ["owner_role_id"]
}
API Reference: Assign User Roles
Auto-select the new tenant and proceed to the dashboard.
Your system must support:
Recommended request context
user_id
selected_tenant_id
role_in_tenant
To list all users in a selected tenant, use the endpoint that matches your authentication context:
Use the JWT obtained during the OIDC login flow. This endpoint returns roles specific to the tenant context.
GET/auth/tenants/{tenantId}/usersAuthorization: Bearer {User_Access_Token}Use this if you are performing administrative tasks without a user context.
GET/tenants/{tenantId}/usersAuthorization: Bearer {Management_Token}Display Requirements:
To provide a complete "Team Members" view, combine data from two sources:
is_active: true.GET /tenants/{id}/invitations?status=pending using the Management Token.Implementation Note: Standardize both responses into a shared model for the UI.
Provide a backend endpoint that:
invitee: { email: "..." }inviter: { user_id: "...", email: "..." } (Required)role_ids: ["..."]send_invitation_email: trueexpire_in_minutes: 10080 (7 days)POST /tenants/{tenantid}/invitations
API Reference: Invite Team Member
"Generates a new onboarding invitation for a user to join the tenant workspace. This process creates a secure invitation token, associates it with the tenant, and dispatches an invitation email."
Allow only authorized roles to remove members. The removal logic depends on the member's status:
To remove an active user from the tenant, use the bulk delete endpoint:
DELETE/tenants/{tenantid}/users{
"user_ids": ["userId"]
}
To cancel or remove a pending invitation, use the invitation delete endpoint:
DELETE/tenants/{tenantid}/invitations?invitation_id={invitationId}Best practices
Use the Roles API to:
GET /roles
API Reference: List All Roles
"Retrieves a list of all defined roles within the system."
To ensure a professional B2B experience, follow these UI patterns:
The agent must always:
The agent should:
❌ Calling management APIs from frontend ❌ Assuming a single tenant per user ❌ Trusting JWT tenant data blindly ❌ Hardcoding roles or tenant IDs
/users/{userId}/tenants/tenants/{tenantId}/usersSearch for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer