Contract reference
Entity Service API
Entity Service operations generated from the canonical Pikbase documentation package.
@gsb-core/mcp-docs:getDocs Introduction
The GSB Entity Service API provides a comprehensive set of operations for managing entity data and definitions within the GSB platform. It allows you to create, read, update, and delete entity data, as well as define and modify entity schemas.
Key Concepts
Entities
Entities represent business objects in your application domain. Each entity has:
- A unique identifier
- A set of properties (fields)
- Optional relationships with other entities
- Metadata describing its structure and behavior
Entity Definitions
Entity definitions (schemas) define the structure of entities:
- Property definitions (name, type, constraints)
- Relationships with other entity types
- Indexes for optimizing queries
- Validation rules
- Display and UI metadata
Properties
Properties are the individual fields that make up an entity:
- Simple types (string, number, boolean, date)
- Complex types (objects, arrays)
- References to other entities
- Computed properties
Authentication
The API uses token-based authentication. Most operations require a valid authentication token, which should be included in the request parameters. The token determines the permissions and access level for the operations.
Common Parameters
Most operations accept these common parameters:
| Parameter | Type | Description |
|---|---|---|
| token | string | Authentication token for your request. If not provided, the system will use the default API key from environment variables. |
| tenantCode | string | Tenant code to specify which tenant's data to access. If not provided, the system will extract it from the token or use the default tenant code from environment variables. |
Response Format
All API operations return responses in a consistent format:
Success Response
{
"success": true,
"data": {
// Operation-specific response data
}
}
Error Response
{
"success": false,
"error": "Error message describing what went wrong"
}
Operation Categories
Entity Data Operations
Operations for working with entity data:
getById: Retrieve an entity by its IDgetCopy: Get a copy of an entity with a new IDquery: Query entities based on filtersqueryMapped: Query entities with mapped resultssave: Create or update an entitysaveMulti: Create or update multiple entitiesdelete: Delete an entity by IDdeleteQuery: Delete entities matching a query
Entity Relationship Operations
Operations for managing relationships between entities:
saveMappedItems: Save relationships between entitiesremoveMappedItems: Remove relationships between entities
Entity Definition Operations
Operations for managing entity definitions (schemas):
getEntityDef: Get an entity definition by IDgetDefinition: Get an entity definition by namequeryEntityDefs: Query entity definitionscreateEntityDef: Create a new entity definitionupdateEntityDef: Update an existing entity definitiongetCommonPropertyDefs: Get common property definitions
Property Operations
Operations for managing entity properties:
addProperty: Add a property to an entity definitionupdateProperty: Update a property in an entity definitionremoveProperty: Remove a property from an entity definition
Workflow Operations
Operations for executing workflows:
runWorkflow: Execute a workflowstartWorkflow: Start a workflowrunWfFunction: Run a workflow functioniterateTask: Iterate through a workflow task
Documentation Operations
Operations for retrieving API documentation:
getDocs: Get comprehensive API documentationgetApiDocs: Get general API information
Best Practices
Error Handling: Always check the
successfield in responses and handle errors appropriately.Pagination: When querying large datasets, use pagination parameters to limit the result size.
Validation: Validate entity data against entity definitions before saving to avoid errors.
Transactions: For operations that modify multiple entities, consider using batch operations like
saveMultito ensure atomicity.Security: Always use the principle of least privilege when assigning permissions to tokens.
Performance: Use appropriate indexes in entity definitions to optimize query performance.
Caching: Consider caching frequently accessed entity definitions and reference data.
Getting Started
To get started with the GSB Entity Service API:
Obtain an authentication token with appropriate permissions.
Explore the available entity definitions using
queryEntityDefs.Retrieve detailed documentation for specific operations using
getDocs.Start with simple operations like
getByIdandqueryto retrieve data.Progress to more complex operations as you become familiar with the API.
Additional Resources
- For detailed documentation on each operation, use the
getDocsoperation. - For information about the API version and general metadata, use the
getApiDocsoperation.
Entity data
getById Purpose : Retrieves a single entity by its unique ID. When to use : Fetching specific records Direct entity access by ID Displaying entity details Input… getCopy Purpose : Retrieves a deep copy of an entity with its related entities. When to use : Creating duplicates of complex entities Getting complete object gr… query Purpose : Searches and retrieves entities based on complex criteria. When to use : Filtering entities by property values Sorting and paginating results… queryMapped Purpose : Retrieves related entities through a reference property. When to use : Accessing items in many to one relationships Retrieving members in many… save Purpose : Creates new entities or updates existing ones. When to use : Creating new entities Updating existing entities Saving complex nested data struc… saveMulti Purpose : Creates or updates multiple entities in a single transaction. When to use : Batch processing multiple entities Need better performance than in… delete Purpose : Removes a single entity from the database by its ID. When to use : Deleting specific records Removing data permanently Targeted data cleanup I… deleteQuery Purpose : Removes multiple entities based on complex query criteria. When to use : Batch deleting records Conditional data removal Filtering entities fo… Relationships
saveMappedItems Purpose : Adds or updates related entities for a parent entity. When to use : Creating/updating items in collections Managing one to many relationships… removeMappedItems Purpose : Removes relationships between entities or deletes related entities. When to use : Breaking connections between related entities Removing items… Definitions
getCommonPropertyDefs Purpose : Retrieves available property data types in the system. When to use : Creating entity definitions Adding properties to entities Finding data ty… getEntityDef Purpose : Retrieves complete entity definition schema by ID or name. When to use : Need schema information Exploring entity structure Creating/validatin… queryEntityDefs Purpose : Retrieves paginated list of entity definitions schemas . When to use : Discovering available entity types Building data dictionaries Creating… createEntityDef Purpose : Creates a new entity type data table in the system. When to use : Defining new data structures Creating database tables Establishing entity re… updateEntityDef Purpose : Modifies existing entity definition metadata and configuration. When to use : Updating entity titles/descriptions Changing permission settings… addProperty Purpose : Adds a new property column to an existing entity definition. When to use : Extending entity schemas Adding new data fields Creating relationsh… updateProperty Purpose : Modifies an existing property within an entity definition. When to use : Changing property titles/descriptions Updating validation rules Modif… removeProperty Purpose : Permanently removes a property from an entity definition. When to use : Eliminating unused properties Restructuring entity schemas Inputs : pr… createOrUpdateSchema Purpose : Creates or updates multiple entity definitions in a single transaction. When to use : Setting up initial schema structure Creating interconnec… Functions and workflows
runWfFunction Purpose : Executes a specific workflow function directly by name or ID. When to use : Need targeted function execution without running a complete workfl… testWfFunction Purpose : Tests a workflow function without saving it to the GSB backend. When to use : Developing and debugging new functions Testing function behavior… runWorkflow Purpose : Executes a workflow and waits for the backend to finish before returning. When to use : The caller needs the workflow result in the same reque… startWorkflow Purpose : Creates a workflow instance and returns immediately, without waiting for completion. When to use : Workflows with human tasks, timers, or exte… iterateTask Purpose : Advances or provides input to tasks within running workflows. When to use : Approving/rejecting workflow tasks Providing data to waiting tasks… iterateOnce Purpose : Administrator only step: advances a workflow instance by exactly one activity and stops, returning the full live instance. When to use : Debug… submitWorkflowTask Purpose : Lets the assigned user act on their workflow task by choosing an outgoing transition, adding a note, or reassigning it. When to use : Approval… Resource packs
addResourcePack Summary for 'addResourcePack' not found. Available operations: getById, getCopy, query, queryMapped, save, saveMulti, delete, deleteQuery, saveMappedIte… installResourcePack Summary for 'installResourcePack' not found. Available operations: getById, getCopy, query, queryMapped, save, saveMulti, delete, deleteQuery, saveMappe… getJobStatus Summary for 'getJobStatus' not found. Available operations: getById, getCopy, query, queryMapped, save, saveMulti, delete, deleteQuery, saveMappedItems,…