

{
    "success": true,
    "api_name": "PMTNM Workflow Management API",
    "version": "1.0",
    "base_url": "\/api\/workflow",
    "endpoints": [
        {
            "path": "\/tickets",
            "method": "GET",
            "description": "Get tickets (all, by user, or by recipient)",
            "parameters": {
                "user_email": "Filter by originator email",
                "recipient_email": "Filter by recipient email",
                "status": "Filter by status (pending_response, responded, fulfilled_pending_confirmation, resolved, unresolved)"
            },
            "example": "\/api\/workflow\/tickets?user_email=user@example.com&status=pending_response"
        },
        {
            "path": "\/tickets\/{ticket_id}",
            "method": "GET",
            "description": "Get specific ticket by ID",
            "example": "\/api\/workflow\/tickets\/ticket_abc123"
        },
        {
            "path": "\/tickets",
            "method": "POST",
            "description": "Create new ticket",
            "parameters": {
                "workflow_type": "Workflow type (required)",
                "email": "Originator email (required)",
                "name": "Originator name (required)",
                "subject": "Ticket subject (required)",
                "message": "Initial message (required)",
                "metadata": "Additional metadata (JSON object)"
            },
            "example": "POST \/api\/workflow\/tickets with form data or JSON"
        },
        {
            "path": "\/tickets\/{ticket_id}\/respond",
            "method": "POST",
            "description": "Add response to ticket",
            "parameters": {
                "email": "Respondent email (required)",
                "name": "Respondent name (optional)",
                "message": "Response message (required)"
            }
        },
        {
            "path": "\/tickets\/{ticket_id}\/fulfill",
            "method": "POST",
            "description": "Mark ticket as fulfilled",
            "parameters": {
                "email": "Fulfiller email (required)",
                "notes": "Fulfillment notes (optional)"
            }
        },
        {
            "path": "\/tickets\/{ticket_id}\/resolve",
            "method": "POST",
            "description": "Mark ticket as resolved",
            "parameters": {
                "email": "Originator email (required)",
                "notes": "Resolution notes (optional)"
            }
        },
        {
            "path": "\/tickets\/{ticket_id}\/unresolved",
            "method": "POST",
            "description": "Mark ticket as unresolved",
            "parameters": {
                "reason": "Reason (required)"
            }
        },
        {
            "path": "\/tickets\/{ticket_id}\/resend_confirmation",
            "method": "POST",
            "description": "Resend confirmation request to originator"
        },
        {
            "path": "\/workflows",
            "method": "GET",
            "description": "Get all workflow definitions",
            "example": "\/api\/workflow\/workflows"
        },
        {
            "path": "\/workflows\/{workflow_type}",
            "method": "GET",
            "description": "Get specific workflow definition",
            "example": "\/api\/workflow\/workflows\/financial_access_request"
        },
        {
            "path": "\/workflows\/validate",
            "method": "POST",
            "description": "Validate workflow data",
            "parameters": {
                "workflow_type": "Workflow type (required)",
                "data": "Data to validate (JSON object)"
            }
        },
        {
            "path": "\/tokens",
            "method": "POST",
            "description": "Generate or validate tokens",
            "parameters": {
                "action": "generate or validate (required)",
                "ticket_id": "Ticket ID (required)",
                "email": "Email address (required)",
                "token_action": "Action type: view, respond, fulfill (default: view)",
                "valid_hours": "Token validity in hours (default: 48)",
                "token": "Token to validate (for validate action)"
            },
            "example": "POST \/api\/workflow\/tokens?action=generate&ticket_id=ticket_abc&email=user@example.com"
        },
        {
            "path": "\/stats",
            "method": "GET",
            "description": "Get workflow statistics",
            "example": "\/api\/workflow\/stats"
        },
        {
            "path": "\/test",
            "method": "GET",
            "description": "Run system tests",
            "parameters": {
                "type": "Test type: all, manager, router, templates, files, tokens, email"
            },
            "example": "\/api\/workflow\/test?type=all"
        },
        {
            "path": "\/test",
            "method": "POST",
            "description": "Run test actions",
            "parameters": {
                "action": "create_test_ticket or cleanup_test_tickets"
            }
        }
    ],
    "response_format": {
        "success": "boolean - true if operation succeeded",
        "error": "string - error message if success is false",
        "data": "varies - response data"
    },
    "authentication": "Currently no authentication required for API access. Consider adding API keys for production.",
    "cors": "CORS headers are enabled for cross-origin requests",
    "documentation": "See docs\/md\/WORKFLOW_API_REFERENCE.md for detailed API documentation"
}