Prerequisites
Before using identity commands, ensure:- Kratos server is running
- Admin API endpoint is accessible
KRATOS_ADMIN_URLenvironment variable is set, or use the--endpointflag
Commands
list identities
List all identities in the system.kratos ls identities
Flags
The read consistency level. Can be
eventual or strong.- eventual - Faster response, may not include recently created/updated identities (replication lag ~5 seconds)
- strong - Guaranteed to include all identities, but slower
Token for pagination. Use the token from previous response to get the next page.
Number of items per page.
Output format:
json, yaml, json-pretty, or table.Admin API endpoint URL. Can also be set via
KRATOS_ADMIN_URL environment variable.Examples
Output example
get identity
Get one or more identities by their ID(s).Flags
Include third-party credentials in the response. Currently only
oidc is supported.Short flag: -iOutput format:
json, yaml, json-pretty, or table.Admin API endpoint URL.
Examples
To query identities by attributes like email address, use the
list command with jq to filter results, then pass the IDs to get identity.delete identity
Delete one or more identities by their ID(s).This operation is irreversible. Deleted identities cannot be recovered.
Flags
Output format:
json, yaml, json-pretty, or table.Admin API endpoint URL.
Examples
import identities
Import one or more identities from JSON files or STDIN.Description
Import identities into Kratos from JSON files or standard input. Files can contain a single identity or an array of identities.Use
validate identity to test the validity of identity files before importing.Flags
Output format for the imported identities.
Admin API endpoint URL.
Examples
Identity file format
The import command expects JSON files with the following structure:validate identity
Validate local identity files against the identity schema and API payload definition.Description
This command validates identity files before importing them. It checks:- The JSON structure against the API schema
- The identity traits against the configured identity schema
Flags
Admin API endpoint URL (required to fetch identity schemas).
Output format.
Examples
Success output
Error output
If validation fails, you’ll see detailed error messages:Advanced usage
Filtering with jq
Thelist identities command combined with jq provides powerful filtering capabilities:
Bulk operations
Error handling
All identity commands return appropriate exit codes:0- Success1- Failure (with error message)
See also
- Identity schema - Define identity data structures
- Admin API reference - Full API documentation
- Import and export guide - Migrate identities between environments