List users
List users
Returns a list of users in the specified zone.
Note: cursor pagination, search, and sort are not yet enabled for all zones. Where they are not enabled, the response returns all users in the zone (capped at 100) in items, with after_cursor and before_cursor set to null and total_count of 0; filter[email] and filter[identifier] are still applied, while the pagination, search, and sort parameters below are accepted but ignored.
Use cursor pagination via after/before. Sort: comma-separated field list; prefix with - for descending. Use expand[]=total_count to include the matching row count, expand[]=session_count to include per-user session counts, expand[]=grant_count to include per-user delegated-grant counts, expand[]=role-assignments to include each user's structured role grants, expand[]=credentials to include each user's authentication credentials (each with its provider_id), and expand[]=credentials.provider to additionally inline the full identity provider on each federation credential. Filter by exact email via filter[email] and by exact identifier via filter[identifier]; search via query[email] / query[subject] / query[] (substring match, OR'd across repeated values). query[] matches against email and federation credential subject. Pass filter[id] (repeatable, max 100) to restrict results to a known set of users — mutually exclusive with after/before (returns 400 if combined). When filter[id] is set, limit is ignored and the response contains every requested user that exists in the zone, in a single page. IDs not in the zone are silently omitted.
Parameters
Cursor for forward pagination
Cursor for backward pagination
Maximum number of items to return
Comma-separated sort fields. Prefix with - for descending. Allowed: created_at, email, authenticated_at
Returns
List users
import os
from keycardai_api import KeycardAPI
client = KeycardAPI(
api_key=os.environ.get("KEYCARD_API_API_KEY"), # This is the default and can be omitted
)
users = client.zones.users.list(
zone_id="zoneId",
)
print(users.items){
"items": [
{
"id": "id",
"created_at": "2019-12-27T18:11:19.117Z",
"email": "dev@stainless.com",
"email_verified": true,
"identifier": "identifier",
"organization_id": "organization_id",
"status": "active",
"updated_at": "2019-12-27T18:11:19.117Z",
"zone_id": "zone_id",
"authenticated_at": "authenticated_at",
"credentials": [
{
"created_at": "2019-12-27T18:11:19.117Z",
"provider_id": "provider_id",
"type": "federation",
"updated_at": "2019-12-27T18:11:19.117Z",
"issuer": "issuer",
"provider": {
"id": "id",
"created_at": "2019-12-27T18:11:19.117Z",
"identifier": "x",
"name": "x",
"organization_id": "organization_id",
"owner_type": "platform",
"slug": "slug",
"updated_at": "2019-12-27T18:11:19.117Z",
"zone_id": "zone_id",
"client_id": "client_id",
"client_secret_set": true,
"description": "description",
"metadata": {
"icon_url": "https://example.com"
},
"protocols": {
"oauth2": {
"issuer": "https://example.com",
"authorization_endpoint": "https://example.com",
"authorization_parameters": {
"foo": "string"
},
"authorization_resource_enabled": true,
"authorization_resource_parameter": "authorization_resource_parameter",
"code_challenge_methods_supported": [
"string"
],
"jwks_uri": "https://example.com",
"registration_endpoint": "https://example.com",
"scope_parameter": "scope_parameter",
"scope_separator": "scope_separator",
"scopes_supported": [
"string"
],
"token_endpoint": "https://example.com",
"token_response_access_token_pointer": "token_response_access_token_pointer"
},
"openid": {
"scopes": [
"string"
],
"single_logout_enabled": true,
"user_identifier_claim": "user_identifier_claim",
"userinfo_endpoint": "https://example.com"
}
},
"type": "external"
},
"subject": "subject"
}
],
"grant_count": 0,
"issuer": "issuer",
"provider_id": "provider_id",
"role_assignments": [
{
"role_id": "role_id",
"role_identifier": "role_identifier",
"role_owner_type": "platform",
"scope": {
"id": "id",
"type": "type"
}
}
],
"session_count": 0,
"subject": "subject"
}
],
"pagination": {
"after_cursor": "x",
"before_cursor": "x",
"total_count": 0
}
}Returns Examples
{
"items": [
{
"id": "id",
"created_at": "2019-12-27T18:11:19.117Z",
"email": "dev@stainless.com",
"email_verified": true,
"identifier": "identifier",
"organization_id": "organization_id",
"status": "active",
"updated_at": "2019-12-27T18:11:19.117Z",
"zone_id": "zone_id",
"authenticated_at": "authenticated_at",
"credentials": [
{
"created_at": "2019-12-27T18:11:19.117Z",
"provider_id": "provider_id",
"type": "federation",
"updated_at": "2019-12-27T18:11:19.117Z",
"issuer": "issuer",
"provider": {
"id": "id",
"created_at": "2019-12-27T18:11:19.117Z",
"identifier": "x",
"name": "x",
"organization_id": "organization_id",
"owner_type": "platform",
"slug": "slug",
"updated_at": "2019-12-27T18:11:19.117Z",
"zone_id": "zone_id",
"client_id": "client_id",
"client_secret_set": true,
"description": "description",
"metadata": {
"icon_url": "https://example.com"
},
"protocols": {
"oauth2": {
"issuer": "https://example.com",
"authorization_endpoint": "https://example.com",
"authorization_parameters": {
"foo": "string"
},
"authorization_resource_enabled": true,
"authorization_resource_parameter": "authorization_resource_parameter",
"code_challenge_methods_supported": [
"string"
],
"jwks_uri": "https://example.com",
"registration_endpoint": "https://example.com",
"scope_parameter": "scope_parameter",
"scope_separator": "scope_separator",
"scopes_supported": [
"string"
],
"token_endpoint": "https://example.com",
"token_response_access_token_pointer": "token_response_access_token_pointer"
},
"openid": {
"scopes": [
"string"
],
"single_logout_enabled": true,
"user_identifier_claim": "user_identifier_claim",
"userinfo_endpoint": "https://example.com"
}
},
"type": "external"
},
"subject": "subject"
}
],
"grant_count": 0,
"issuer": "issuer",
"provider_id": "provider_id",
"role_assignments": [
{
"role_id": "role_id",
"role_identifier": "role_identifier",
"role_owner_type": "platform",
"scope": {
"id": "id",
"type": "type"
}
}
],
"session_count": 0,
"subject": "subject"
}
],
"pagination": {
"after_cursor": "x",
"before_cursor": "x",
"total_count": 0
}
}