InfraNotes CORE · v1.35.9
Welcome
Select a document from the sidebar to read it.
InfraNotes Approval Workflow System - Frontend Implementation Guide
This guide provides detailed information on how to integrate with the InfraNotes approval workflow system API. It includes all available endpoints, their request/response formats, examples, and integration patterns.
Table of Contents
- System Overview
- Authentication
- Integration Points
- Workflow Management
- Workflow Steps
- Approval Operations
- Approval Instance Management
- Delegation Management
- Frontend Implementation Patterns
- Error Handling
- Permissions
System Overview
The approval workflow system enables organizations to implement customizable approval processes for invoices and expenses. It provides:
- Configurable Approval Chains: Multi-step approval workflows with sequential steps
- Multiple Approver Types: Support for individual users, roles, or team-based approvers
- Delegation Support: Allow approvers to delegate their responsibility to others
- Real-time Notifications: Automated notifications for pending approvals and status changes
- Amount-based Thresholds: Automatic workflow selection based on entity amounts
- Complete Audit Trail: Full history and tracking of approval processes
Integration Points
The approval workflow system integrates with:
- Invoice System: Primary integration with approval status tracking
- Expense System: Planned integration for expense approvals
- Activity Logging: Tracks all approval-related activities
- Notification System: Sends email and in-app notifications
- Permission System: Manages approval-related permissions
- User Management: Links approvers to users and teams
Authentication
All API endpoints require authentication using JWT Bearer tokens:
Authorization: Bearer your_jwt_token
Integration Points
Invoice Model Extensions
When working with invoices, these additional fields are available:
{
"id": 123,
"invoice_number": "INV-2025-001",
"approval_status": "pending",
"approval_workflow_id": 4,
"requires_approval": true,
"last_approval_action_at": "2025-05-23T16:25:12Z"
}
Approval Status Values
not_required: No approval neededpending: Awaiting approvalapproved: Fully approvedrejected: Rejected by an approvercanceled: Approval request canceled
Workflow Management
Create Workflow
Endpoint: POST /api/approval/workflows
Purpose: Create a new approval workflow template
Request Body:
{
"name": "Invoice Approval - Finance",
"description": "Standard workflow for finance department invoices",
"entity_type": "invoice",
"is_active": true,
"min_amount_threshold": 1000.00,
"max_amount_threshold": 10000.00,
"is_default": false
}
Response:
{
"id": 4,
"name": "Invoice Approval - Finance",
"description": "Standard workflow for finance department invoices",
"is_active": true,
"user_id": 2,
"entity_type": "invoice",
"min_amount_threshold": 1000.00,
"max_amount_threshold": 10000.00,
"is_default": false,
"created_at": "2025-05-23T15:31:00Z",
"updated_at": "2025-05-23T15:31:00Z"
}
List Workflows
Endpoint: GET /api/approval/workflows
Purpose: Retrieve workflows with filtering and pagination
Query Parameters:
entity_type: Filter by entity type (invoice,expense)user_id: Filter by workflow ownerteam_id: Filter by teamis_active: Filter by active status (true,false)is_default: Filter by default status (true,false)limit: Number of records (default: 25)offset: Pagination offset (default: 0)
Example Request:
GET /api/approval/workflows?entity_type=invoice&is_active=true&limit=10
Response:
{
"data": [
{
"id": 4,
"name": "Invoice Approval - Finance",
"description": "Standard workflow for finance department invoices",
"is_active": true,
"user_id": 2,
"entity_type": "invoice",
"min_amount_threshold": 1000.00,
"max_amount_threshold": 10000.00,
"is_default": true,
"created_at": "2025-05-23T15:31:00Z",
"updated_at": "2025-05-23T16:25:12Z"
}
],
"meta": {
"limit": 10,
"offset": 0,
"total": 1
},
"status": "success"
}
Get Workflow
Endpoint: GET /api/approval/workflows/{id}
Purpose: Get specific workflow with all steps
Response:
{
"id": 4,
"name": "Invoice Approval - Finance",
"description": "Standard workflow for finance department invoices",
"is_active": true,
"user_id": 2,
"entity_type": "invoice",
"min_amount_threshold": 1000.00,
"max_amount_threshold": 10000.00,
"is_default": true,
"steps": [
{
"id": 1,
"workflow_id": 4,
"step_order": 1,
"approver_type": "user",
"approver_id": 5,
"name": "Manager Approval",
"description": "Department manager review",
"is_required": true,
"created_at": "2025-05-23T15:32:00Z",
"updated_at": "2025-05-23T15:32:00Z"
}
],
"created_at": "2025-05-23T15:31:00Z",
"updated_at": "2025-05-23T16:25:12Z"
}
Update Workflow
Endpoint: PUT /api/approval/workflows/{id}
Purpose: Update workflow properties
Request Body:
{
"name": "Updated Invoice Approval Workflow",
"description": "Updated description",
"is_active": true,
"min_amount_threshold": 500.00,
"max_amount_threshold": 15000.00
}
Response: Updated workflow object with new updated_at timestamp
Delete Workflow
Endpoint: DELETE /api/approval/workflows/{id}
Purpose: Delete workflow and all associated steps
Response: HTTP 204 No Content
Set Default Workflow
Endpoint: PUT /api/approval/workflows/{id}/default
Purpose: Set workflow as default for its entity type
Response:
{
"message": "Workflow 4 set as default for invoice entities",
"status": "success"
}
Workflow Steps
Add Workflow Step
Endpoint: POST /api/approval/workflows/{id}/steps
Purpose: Add an approval step to a workflow
Request Body:
{
"step_order": 1,
"approver_type": "user",
"approver_id": 456,
"name": "Manager Approval",
"description": "Department manager review",
"is_required": true
}
Approver Types:
user: Individual user approvalrole: Any user with specific roleteam: Any user from specific team
Response:
{
"id": 4,
"workflow_id": 4,
"step_order": 1,
"approver_type": "user",
"approver_id": 456,
"name": "Manager Approval",
"description": "Department manager review",
"is_required": true,
"created_at": "2025-05-23T15:32:47Z",
"updated_at": "2025-05-23T15:32:47Z"
}
Update Workflow Step
Endpoint: PUT /api/approval/workflows/{workflowId}/steps/{stepId}
Purpose: Update existing workflow step
Request Body:
{
"name": "Updated Manager Approval",
"description": "Updated description for manager approval",
"approver_type": "user",
"approver_id": 456,
"is_required": true
}
Response: Updated step object
Delete Workflow Step
Endpoint: DELETE /api/approval/workflows/{workflowId}/steps/{stepId}
Purpose: Remove step from workflow
Response: HTTP 204 No Content
Approval Operations
Request Approval
Endpoint: POST /api/approval/request
Purpose: Initiate approval process for an entity
Request Body:
{
"entity_type": "invoice",
"entity_id": 789,
"workflow_id": 123,
"notes": "Please approve this invoice for project XYZ"
}
Response:
{
"id": 1,
"workflow_id": 123,
"entity_type": "invoice",
"entity_id": 789,
"status": "pending",
"requester_id": 2,
"requested_at": "2025-05-23T16:30:00Z",
"current_step_index": 0,
"notes": "Please approve this invoice for project XYZ",
"workflow": {
"id": 123,
"name": "Invoice Approval - Finance"
},
"created_at": "2025-05-23T16:30:00Z",
"updated_at": "2025-05-23T16:30:00Z"
}
Approve Request
Endpoint: POST /api/approval/instances/{id}/approve
Purpose: Approve a pending approval request
Request Body:
{
"notes": "Approved - within budget and properly documented"
}
Response:
{
"message": "Approval processed successfully",
"status": "success",
"instance": {
"id": 1,
"status": "approved",
"current_step_index": 1,
"updated_at": "2025-05-23T16:35:00Z"
}
}
Reject Request
Endpoint: POST /api/approval/instances/{id}/reject
Purpose: Reject a pending approval request
Request Body:
{
"notes": "Rejected - missing supporting documentation"
}
Response: Similar to approve response with status "rejected"
Delegate Request
Endpoint: POST /api/approval/instances/{id}/delegate
Purpose: Delegate approval to another user
Request Body:
{
"delegate_id": 789,
"notes": "Please review this invoice while I'm on vacation"
}
Response: Updated approval instance with delegation information
Cancel Request
Endpoint: POST /api/approval/instances/{id}/cancel
Purpose: Cancel pending approval request
Request Body:
{
"notes": "Canceling due to invoice error"
}
Response: Updated approval instance with status "canceled"
Approval Instance Management
List Approval Instances
Endpoint: GET /api/approval/instances
Purpose: Get approval instances with filtering
Query Parameters:
entity_type: Filter by entity type (invoice,expense)entity_id: Filter by specific entity IDworkflow_id: Filter by workflow IDstatus: Filter by status (pending,approved,rejected,canceled)requester_id: Filter by requester IDlimit: Number of records (default: 25)offset: Pagination offset (default: 0)
Example Request:
GET /api/approval/instances?entity_type=invoice&status=pending&limit=10
Response:
{
"data": [
{
"id": 1,
"workflow_id": 123,
"entity_type": "invoice",
"entity_id": 789,
"status": "pending",
"requester_id": 2,
"requested_at": "2025-05-23T16:30:00Z",
"current_step_index": 0,
"notes": "Please approve this invoice for project XYZ",
"created_at": "2025-05-23T16:30:00Z",
"updated_at": "2025-05-23T16:30:00Z"
}
],
"meta": {
"limit": 10,
"offset": 0,
"total": 1
},
"status": "success"
}
Get Approval Instance
Endpoint: GET /api/approval/instances/{id}
Purpose: Get specific approval instance details
Response:
{
"id": 1,
"workflow_id": 123,
"entity_type": "invoice",
"entity_id": 789,
"status": "pending",
"requester_id": 2,
"requested_at": "2025-05-23T16:30:00Z",
"current_step_index": 0,
"notes": "Please approve this invoice for project XYZ",
"workflow": {
"id": 123,
"name": "Invoice Approval - Finance",
"steps": [
{
"id": 1,
"step_order": 1,
"approver_type": "user",
"approver_id": 5,
"name": "Manager Approval"
}
]
},
"created_at": "2025-05-23T16:30:00Z",
"updated_at": "2025-05-23T16:30:00Z"
}
Get Pending Approvals
Endpoint: GET /api/approval/pending
Purpose: Get pending approvals for the current user
Query Parameters:
limit: Number of records (default: 25)offset: Pagination offset (default: 0)
Response:
{
"data": [
{
"id": 1,
"workflow_id": 123,
"entity_type": "invoice",
"entity_id": 789,
"status": "pending",
"requester_id": 2,
"requested_at": "2025-05-23T16:30:00Z",
"current_step_index": 0,
"notes": "Please approve this invoice for project XYZ"
}
],
"meta": {
"limit": 25,
"offset": 0,
"total": 1
},
"status": "success"
}
Delegation Management
Add Delegate
Endpoint: POST /api/approval/delegates
Purpose: Add approval delegation
Request Body:
{
"delegate_id": 789,
"workflow_id": 123,
"valid_from": "2025-05-23T00:00:00Z",
"valid_until": "2025-05-30T23:59:59Z"
}
Response: Created delegation record
List Delegates
Endpoint: GET /api/approval/delegates
Purpose: List current user's delegates
Response: Array of delegate records
Remove Delegate
Endpoint: DELETE /api/approval/delegates/{id}
Purpose: Remove delegation
Response: HTTP 204 No Content
Frontend Implementation Patterns
Dashboard Integration
For approval dashboard implementation:
-
Pending Approvals Widget:
// Get count of pending approvals GET /api/approval/pending?limit=1 // Use meta.total for count display -
Recent Activity:
// Get recent approval instances GET /api/approval/instances?limit=5&requester_id={currentUserId} -
Workflow Status Indicators:
// Display approval status in invoice lists // Use approval_status field from invoice responses
Invoice Integration
When creating/editing invoices:
-
Check if Approval Required:
// Based on invoice amount and available workflows GET /api/approval/workflows?entity_type=invoice&is_default=true -
Request Approval Button:
// Show when invoice.requires_approval === false // Hide when invoice.approval_status === 'pending' -
Approval Status Display:
const statusLabels = { 'not_required': 'No Approval Needed', 'pending': 'Pending Approval', 'approved': 'Approved', 'rejected': 'Rejected', 'canceled': 'Canceled' };
Workflow Management UI
For admin workflow configuration:
-
Workflow Builder:
- Create workflow form with entity type selection
- Add/remove/reorder steps interface
- Set default workflow toggle
-
Step Configuration:
- Approver type selection (user/role/team)
- Approver picker based on type
- Required/optional step toggle
-
Workflow Testing:
- Preview workflow flow
- Test with sample entities
Error Handling
Common Error Responses
Validation Errors:
{
"error_code": "validation_failed",
"message": "Validation errors occurred",
"details": [
{
"field": "name",
"message": "Name is required"
},
{
"field": "entity_type",
"message": "Invalid entity type"
}
]
}
Authorization Errors:
{
"error_code": "insufficient_permissions",
"message": "You don't have permission to approve this request"
}
Business Logic Errors:
{
"error_code": "invalid_state",
"message": "Cannot request approval on inactive workflow"
}
HTTP Status Codes
200: Success with data201: Created successfully204: Success with no content400: Bad request/validation error401: Unauthorized403: Forbidden404: Resource not found409: Conflict (business rule violation)500: Internal server error
Permissions
Required Permissions
Workflow Management:
approval:workflow:view: View workflowsapproval:workflow:create: Create workflowsapproval:workflow:update: Update workflowsapproval:workflow:delete: Delete workflowsapproval:workflow:step:manage: Manage workflow stepsapproval:workflow:set:default: Set default workflows
Approval Operations:
invoice:approval:request: Request invoice approvalinvoice:approval:approve: Approve invoicesinvoice:approval:reject: Reject invoicesinvoice:approval:cancel: Cancel approval requests
Delegation:
approval:delegate:manage: Manage approval delegates
Viewing:
approval:actions:view: View approval actionsapproval:instances:view: View approval instances
Permission Checking
Frontend should check permissions before showing UI elements:
// Check if user can create workflows
if (user.permissions.includes('approval:workflow:create')) {
showCreateWorkflowButton();
}
// Check if user can approve
if (user.permissions.includes('invoice:approval:approve')) {
showApproveButton();
}
Conclusion
This approval workflow system provides a comprehensive foundation for implementing approval processes in your application. The API is designed to be flexible and extensible, supporting various approval scenarios while maintaining security and auditability.
Key implementation considerations:
- Always check permissions before showing UI elements
- Implement proper error handling for all states
- Use real-time updates for approval status changes
- Provide clear visual indicators for approval states
- Include comprehensive audit trails for compliance