Search and filter API keys¶
POST /api/v1/api-keys/search
Search API keys with flexible filtering, sorting, and pagination. Supports filtering by username (admin-only), subscription name, status, sorting by multiple fields, and pagination.
Authorization¶
Request body¶
Optional.
Content type: application/json
Schema: object
| Property | Type | Required | Description |
|---|---|---|---|
filters | object | No | |
filters.username | string | No | Filter by username (admin-only) |
filters.subscription | string | No | Filter by subscription. Matches the subscription id on the key |
filters.status | array of string | No | Filter by status (active, revoked, expired). Defaults to active only. Allowed values: |
sort | object | No | |
sort.by | string | No | Field to sort by Allowed values: |
sort.order | string | No | Sort order Allowed values: |
pagination | object | No | |
pagination.limit | integer | No | Default: Constraints: minimum 1; maximum 100 |
pagination.offset | integer | No | Default: Constraints: minimum 0 |
Example:
{
"filters": {
"status": ["active"]
},
"sort": {
"by": "created_at",
"order": "desc"
},
"pagination": {
"limit": 50,
"offset": 0
}
}
Responses¶
| Status | Description | Response body |
|---|---|---|
200 OK | OK response. |
|
400 Bad Request | Bad Request. Invalid search parameters. |
|
401 Unauthorized | Unauthorized response. | None |
500 Internal Server Error | Internal Server Error | None |
Example request¶
curl -X POST "/maas/api/v1/api-keys/search" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"filters": {
"status": ["active"]
},
"sort": {
"by": "created_at",
"order": "desc"
},
"pagination": {
"limit": 50,
"offset": 0
}
}'
Example response¶
200 OK, application/json
{
"object": "list",
"data": [
{
"id": "key_abc123",
"name": "my-production-key",
"creationDate": "2024-01-15T10:30:00Z",
"status": "active"
},
{
"id": "key_def456",
"name": "my-test-key",
"creationDate": "2024-01-14T09:15:00Z",
"expirationDate": "2024-04-14T09:15:00Z",
"status": "active"
}
],
"has_more": true
}