Overview
Schemas define the structure of your data objects in Pretectum. Each schema specifies:- Fields: The attributes that data objects contain (e.g., First Name, Email, Phone)
- Data Types: The type of data each field holds (string, number, date, etc.)
- Validation Rules: Requirements like mandatory fields and unique constraints
- Search Configuration: Which fields are indexed for searching
Why Schemas Matter
Understanding your schemas is essential for:- Effective Searching: Know which fields are searchable and their exact names
- Data Validation: Understand required fields and data types
- Building Integrations: Create forms and interfaces that match your data structure
- Query Optimization: Target searches to specific fields for better results
Before You Begin
To use the Schema APIs, you need:1
Get API Credentials
Obtain your
client_id and client_secret from your Pretectum tenant administrator.2
Obtain Access Token
Exchange your credentials for an access token using the authentication endpoint.
3
Get Business Area IDs
Retrieve business area IDs using the List Business Areas endpoint. Schema queries require a business area ID.
Listing Schemas in a Business Area
To get schemas, you first need the business area ID, then query for schemas within that area.Step 1: Get Business Area ID
Step 2: List Schemas
Understanding the Response
| Field | Description |
|---|---|
schemaId | Unique identifier for the schema |
name | Display name used for filtering in search operations |
description | Explanation of the schema’s purpose |
businessAreaId | The parent business area ID |
businessAreaName | The parent business area name |
active | Whether the schema is currently active |
state | Current state of the schema (e.g., draft, published) |
fieldsCount | Number of fields defined in the schema |
dataSetCount | Number of datasets using this schema |
version | Version number for tracking changes |
nextPageKey | Pagination token for fetching the next page (if present) |
Getting Schema Details
Retrieve complete schema information including field definitions:Example Response
Using Schemas for Search
Use schema and field information to construct effective search queries.Filtering by Schema Name
Searching by Field Names
Use the field names from the schema to construct field-specific queries:Complete Client Implementation
Here is a complete implementation that handles business areas, schemas, and searching:Building a Schema-Aware Search Interface
Create cascading dropdowns for business area and schema selection:Error Handling
Handle common errors when working with schemas:Best Practices
Cache Schema Data
Cache Schema Data
Schemas change infrequently. Cache responses to reduce API calls:
Use Schema Names for Search
Use Schema Names for Search
When filtering searches, use the schema
name, not the schemaId:Check Field Searchability
Check Field Searchability
Before building field-specific queries, verify the field is searchable:
Handle Pagination
Handle Pagination
Always check for
pageKey in schema list responses: