Skip to content

Search clients

Request

🔐 Required role: API_ADMIN

📖 Data dictionary: Client

Advanced client filtering with flexible where clauses and dynamic ordering

Uses standard limit/offset pagination via pageSize and page — see Pagination.

This query provides maximum flexibility for client data retrieval through custom where clause construction and dynamic ordering specifications. It's designed for complex business requirements that need sophisticated filtering logic.

Key Features:

  • Custom where clause construction for unlimited filtering combinations
  • Dynamic order_by specifications supporting multi-field sorting with custom directions
  • Advanced boolean logic combining multiple filter conditions with _and, _or, _not
  • Relationship-based filtering across connected entities (contacts, staff assignments)
  • Enterprise-grade filtering supporting complex business logic requirements
  • Support for nested queries and conditional logic patterns

Advanced Filtering Capabilities:

  • Boolean Logic: _and, _or, _not operators for complex condition combinations
  • Text Operations: _like, _ilike, _regex for pattern matching and search
  • Comparison Operators: _gt, _gte, _lt, _lte, _eq, _neq for numerical/date comparisons
  • Array Operations: _in, _nin for multi-value filtering and inclusion/exclusion
  • Null Handling: _is_null for empty value detection and filtering
  • Relationship Traversal: Filter on connected entities like contacts and staff
  • Date Ranges: Precision timestamp filtering for time-based analysis
  • Case Sensitivity: Both case-sensitive and case-insensitive text matching

Dynamic Ordering Options:

  • Multi-field Sorting: Order by multiple columns with individual sort directions
  • Relationship Sorting: Sort by connected entity fields (staff names, contact info)
  • Custom Directions: Mix ascending and descending order across different fields
  • Priority Ordering: Define primary, secondary, tertiary sort criteria
  • Date-based Sorting: createdAt, updatedAt for chronological ordering
  • Text Sorting: Alphabetical ordering with locale-aware collation
Security
(BearerAuth and CfAccessClientId and CfAccessClientSecret) or BearerAuth
Bodyapplication/json
pageSizeinteger, [ 1 .. 1000 ]

Limit — number of records to return (not a page count). Hasura maps this to limit. Defaults to 50 when omitted.

Default:50
Example:1
pageinteger, >= 0

Offset — number of records to skip. This is not a page index. Same contract as POST /gql/v1/clients. When page is at or beyond total.aggregate.count, clients is an empty array.

Default:0
Example:0
whereobject

Flexible where clause for complex filtering

Example:
{ "_and": [ { … }, { … }, { … }, { … } ] }
orderByArray of objects

Dynamic ordering specifications with multiple fields

Example:
[ { "name": "asc" }, { "createdAt": "desc" } ]
curl -i -X POST \
  https://api.sandbox.aiwyn.app/gql/v1/clients/search \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>' \
  -H 'CF-Access-Client-Id: YOUR_API_KEY_HERE' \
  -H 'CF-Access-Client-Secret: YOUR_API_KEY_HERE' \
  -H 'Content-Type: application/json' \
  -d '{
    "pageSize": 1,
    "page": 0,
    "where": {
      "_and": [
        {
          "_or": [
            {
              "name": {
                "_ilike": "%tech%"
              }
            },
            {
              "clientRef": {
                "_ilike": "%45%"
              }
            }
          ]
        },
        {
          "active": {
            "_eq": true
          }
        },
        {
          "createdAt": {
            "_gte": "1900-01-01T00:00:00Z"
          }
        },
        {
          "partnerStaffId": {
            "_in": [
              5,
              6,
              7,
              8
            ]
          }
        }
      ]
    },
    "orderBy": [
      {
        "name": "asc"
      },
      {
        "createdAt": "desc"
      }
    ]
  }'

Responses

Successfully retrieved filtered clients with dynamic ordering

Bodyapplication/json
clientsArray of objects(Client)required

Same client shape as POST /gql/v1/clients

totalobjectrequired
Response
{ "clients": [ { … } ], "total": { "aggregate": { … } } }