OData Query Guide
How to use OData-style query parameters such as $filter, $select, skip, and
limit with the Rhesis backend API.
Basic Concepts
OData (Open Data Protocol) is a REST-based protocol for querying and updating data. In Rhesis, you can use OData filters with the $filter query parameter.
URL Format
Authentication
All requests require a Bearer token:
Common query parameters
Use the following parameters together to shape list responses:
| Parameter | Purpose | Example |
|---|---|---|
$filter | Filter rows with OData expressions | $filter=status/name eq 'Active' |
$select | Return only selected top-level fields (id is always included) | $select=name,score_type,threshold |
sort_by | Choose sort field | sort_by=created_at |
sort_order | Set sort direction (asc or desc) | sort_order=desc |
skip | Offset for pagination | skip=20 |
limit | Max rows returned by REST list endpoints | limit=50 |
Comparison Operators
Equality Operators
Equal (eq)
Not Equal (ne)
Comparison Operators
Greater Than (gt)
Less Than (lt)
Greater Than or Equal (ge)
Less Than or Equal (le)
String Functions
All string functions use function-style syntax: function(field, value)
Contains
Starts With
Ends With
Case Conversion
To Lower Case (tolower)
To Upper Case (toupper)
Navigation Properties
Navigate through relationships using the / operator: relationship/field
Behavior Navigation
Status Navigation
Prompt Navigation
Topic Navigation
Category Navigation
Logical Operators
AND Operator
OR Operator
NOT Operator
Complex Expressions with Parentheses
Advanced Features
Sorting
Use sort_by and sort_order parameters:
Pagination
Use skip and limit parameters:
Field Selection with $select
Use $select to return only the fields you need from list endpoints.
id is always included by the backend even when omitted from $select.
$select works across all standard list endpoints generated through the backend routers
(tests, behaviors, categories, topics, test_sets, test_runs, test_results,
metrics, projects, sources, and related list routes).
MCP server-managed pagination
When list operations are called through MCP tools (instead of direct REST), some tools define
a server-managed page_size in mcp_tools.yaml.
In those cases:
- the MCP tool schema hides
limitfrom the model - the server applies a fixed page size with peek-ahead (
limit = page_size + 1) - list responses are wrapped with
_paginationmetadata
For direct REST API calls, limit and skip remain fully client-controlled.
Combining Parameters
Field Selection
Use $select to return only the fields a list view or tool call needs. The backend accepts a
comma-separated list of serialized response fields and always includes id so each entity remains
addressable.
$select filters serialized response objects after the query runs. It reduces payload size for
list responses, but it does not change which rows match $filter.
Complete Examples
Example 1: Case-Insensitive Behavior Search
Example 2: Complex Multi-Condition Filter
Example 3: Advanced Search with Sorting
Example 4: Navigation with String Functions
Best Practices
1. Use Case-Insensitive Searches
For user-friendly searches, always use tolower() or toupper():
2. Use Navigation Properties for Related Data
Instead of multiple API calls, use navigation:
3. Use Parentheses for Complex Logic
Make complex expressions clear with parentheses:
4. Combine Filtering with Pagination
Always use pagination for potentially large result sets:
5. URL Encoding
Remember to URL-encode your queries:
Error Handling
Common Errors
Invalid Field Names
Parse Errors
Invalid Syntax Use function-style syntax for string operations:
Available Endpoints
The following endpoints support OData filtering:
/tests- Test entities/behaviors- Behavior entities/topics- Topic entities/categories- Category entities/test-sets- Test set entities/test-runs- Test run entities/test-results- Test result entities/prompts- Prompt entities/metrics- Metric entities/projects- Project entities
Each endpoint supports the navigation properties defined in its model relationships.