Filter Parameter
Use the filter query parameter to filter API responses. The format is:
filter=field1{operator}value1,field2{operator}value2
Supported Operators
| Operator | Description | Example |
|---|---|---|
= | Equals (case-insensitive for strings) | username=john |
> | Greater than | uid>1000 |
< | Less than | uid<5000 |
>= | Greater than or equal | gid>=100 |
<= | Less than or equal | created<=2024-01-01T00:00:00Z |
Field Types
Different field types have different behaviors:
- String fields: Case-insensitive matching. Supports wildcards with
* - Number fields: Numeric comparison
- Datetime fields: ISO 8601 format (
YYYY-MM-DDTHH:MM:SSZ) - Boolean fields: Use
TrueorFalse(case-sensitive)
Endpoints Supporting Filters
1. Users Endpoint (/api/v1/users/)
/api/v1/users/)Filter users by various fields.
Available Fields
String Fields:
username- Username (supports wildcards)email- Email address (supports wildcards)first_name- First name (supports wildcards)last_name- Last name (supports wildcards)github_username- GitHub username (supports wildcards)shell- Shell path (supports wildcards)
Number Fields:
uid- User IDgid- Group ID
Datetime Fields:
created- Account creation date
Boolean Fields:
is_eng_user- Whether user is an engineering useris_posix_user- Whether user is a POSIX useris_active- Whether user is active (checks both local and remote status)active- Alias foris_active
Examples
# Get users with username "john"
GET /api/v1/users/?filter=username=john
# Get users with UID greater than 1000
GET /api/v1/users/?filter=uid>1000
# Get active users created after a specific date
GET /api/v1/users/?filter=is_active=True,created>=2024-01-01T00:00:00Z
# Get users with email matching a pattern (wildcard)
GET /api/v1/users/?filter=email=*@example.com
# Combine multiple filters
GET /api/v1/users/?filter=username=john,uid>1000,is_active=True2. Groups Endpoint (/api/v1/groups/)
/api/v1/groups/)Filter groups by various fields.
Available Fields
String Fields:
name- Group name (supports wildcards)
Number Fields:
gid- Group ID
Boolean Fields:
is_posix_group- Whether group is a POSIX groupsynced- Whether group is synced from external source
Examples
# Get groups with name "admin"
GET /api/v1/groups/?filter=name=admin
# Get POSIX groups with GID greater than 100
GET /api/v1/groups/?filter=is_posix_group=True,gid>100
# Get synced groups
GET /api/v1/groups/?filter=synced=True
# Get groups with name matching a pattern
GET /api/v1/groups/?filter=name=*admin*3. Group Members Endpoint (/api/v1/groups/{groupname}/members/)
/api/v1/groups/{groupname}/members/)Filter group members by various fields.
Available Fields
String Fields:
username- Username of the member (supports wildcards)
Datetime Fields:
expires- Membership expiration date
Examples
# Get members with username "john"
GET /api/v1/groups/admins/members/?filter=username=john
# Get members whose membership expires after a specific date
GET /api/v1/groups/admins/members/?filter=expires>=2024-12-31T23:59:59Z
# Get members with username matching a pattern
GET /api/v1/groups/admins/members/?filter=username=*admin*4. Client Certificates Endpoint (/api/v1/eap_tls/client_certificates/)
/api/v1/eap_tls/client_certificates/)Filter client certificates by various fields.
Available Fields
String Fields:
cn- Common Name (supports wildcards)san- Subject Alternative Name (supports wildcards)serial- Certificate serial number (supports wildcards)radius_certificate_authority__serial- CA serial number (supports wildcards)
Datetime Fields:
expires- Certificate expiration datecreated- Certificate creation daterevoked_on- Certificate revocation date
Boolean Fields:
revoked- Whether certificate is revoked
Examples
# Get certificates with specific CN
GET /api/v1/eap_tls/client_certificates/[email protected]
# Get non-revoked certificates expiring after a date
GET /api/v1/eap_tls/client_certificates/?filter=revoked=False,expires>=2024-12-31T23:59:59Z
# Get certificates created before a date
GET /api/v1/eap_tls/client_certificates/?filter=created<=2024-01-01T00:00:00Z
# Get certificates with CN matching a pattern
GET /api/v1/eap_tls/client_certificates/?filter=cn=*@example.comWildcard Matching
String fields support wildcard matching using the * character. The * matches any sequence of characters.
Examples:
username=*admin*- Matches usernames containing "admin"email=*@example.com- Matches all emails from example.com domainname=test*- Matches names starting with "test"
Datetime Format
All datetime fields must use ISO 8601 format in UTC:
YYYY-MM-DDTHH:MM:SSZ
Examples:
2024-01-01T00:00:00Z- January 1, 2024, midnight UTC2024-12-31T23:59:59Z- December 31, 2024, 11:59:59 PM UTC
Boolean Values
Boolean fields accept only the string values True or False (case-sensitive).
Examples:
is_active=Trueis_posix_user=Falserevoked=False
Combining Filters
Multiple filters can be combined by separating them with commas. All filters are applied with AND logic (all conditions must be met).
Example:
GET /api/v1/users/?filter=username=john,uid>1000,is_active=TrueThis returns users where:
- Username equals "john" AND
- UID is greater than 1000 AND
- User is active
URL Encoding
When using filters in URLs, ensure proper URL encoding:
- Spaces should be encoded as
%20or+ - Special characters should be URL encoded
- Commas separating filters should not be encoded
Example:
# URL encoded version
GET /api/v1/users/?filter=username=john%20doe,uid>1000Combining with Pagination
Filters can be combined with pagination parameters:
GET /api/v1/users/?filter=is_active=True&page=1&limit=50Error Handling
If an invalid field or operator is used, the filter will be ignored. Only valid filters matching the endpoint's supported fields will be applied.
Notes
- String comparisons are case-insensitive when using the
=operator - Wildcard matching uses regex patterns (case-insensitive)
- Boolean fields for
is_activeandactivecheck bothis_active_localandis_active_remotewhen set toTrue - The
syncedfield checks for the presence ofexternal_id(True = synced, False = not synced)
