Filtering

Filter API responses to retrieve only the data you need.

Overview

Most list endpoints support filtering via query parameters. You can filter by specific field values, date ranges, and status values to narrow down results.

Basic Filtering

Pass field names as query parameters with the desired value:

bash
# Filter customers by status
curl "https://pxb.app/api/public/v1/customers?status=active" \
  -H "X-API-Key: your_api_key_here" \
  -H "X-Organization-ID: your_organization_id_here"

# Filter by multiple fields
curl "https://pxb.app/api/public/v1/customers?status=active&type=premium" \
  -H "X-API-Key: your_api_key_here" \
  -H "X-Organization-ID: your_organization_id_here"

Common Filter Parameters

ParameterTypeDescription
statusstringFilter by resource status (e.g., active, archived).
searchstringFull-text search across relevant fields.
createdAfterISO 8601Filter resources created after this date.
createdBeforeISO 8601Filter resources created before this date.
updatedAfterISO 8601Filter resources updated after this date.

Date Range Filtering

Filter by date ranges using ISO 8601 formatted dates:

bash
# Get customers created in January 2024
curl "https://pxb.app/api/public/v1/customers?createdAfter=2024-01-01T00:00:00Z&createdBefore=2024-02-01T00:00:00Z" \
  -H "X-API-Key: your_api_key_here" \
  -H "X-Organization-ID: your_organization_id_here"

# Get recently updated records
curl "https://pxb.app/api/public/v1/customers?updatedAfter=2024-03-01T00:00:00Z" \
  -H "X-API-Key: your_api_key_here" \
  -H "X-Organization-ID: your_organization_id_here"

Use the search parameter for full-text search across relevant fields:

bash
# Search customers by name or email
curl "https://pxb.app/api/public/v1/customers?search=smith" \
  -H "X-API-Key: your_api_key_here" \
  -H "X-Organization-ID: your_organization_id_here"

The search parameter typically searches across name, email, and other relevant text fields. Check individual endpoint documentation for specific searchable fields.

Combining Filters

Filters can be combined with pagination and sorting:

bash
curl "https://pxb.app/api/public/v1/customers?status=active&search=enterprise&sortBy=createdAt&sortOrder=desc&limit=20" \
  -H "X-API-Key: your_api_key_here" \
  -H "X-Organization-ID: your_organization_id_here"

Response Example

Filtered responses include only matching records:

json
{
  "message": "Customers retrieved successfully!",
  "content": {
    "customers": [
      {
        "id": "cust_abc123",
        "firstName": "Jane",
        "lastName": "Smith",
        "status": "active",
        "createdAt": "2024-01-15T10:30:00Z"
      }
    ],
    "pagination": {
      "total": 1,
      "limit": 20,
      "offset": 0,
      "hasMore": false
    }
  }
}

Notes

  • All filters are case-insensitive for text values.
  • Multiple values for the same filter create an OR condition.
  • Invalid filter values return a 400 Bad Request error with details.
  • The total in pagination reflects the filtered count, not the total records.
Copyright © Pixelbase Inc. - All rights reserved.