{
    "api": {
        "name": "Yeastar-SITHIA CRM Integration API",
        "version": "1.0.0",
        "description": "RESTful API for integrating Yeastar PBX with SITHIA CRM",
        "base_url": "https://api.sithia.gr/api/yeastar/",
        "documentation": "https://api.sithia.gr/api/yeastar/docs",
        "timestamp": "2026-05-26T17:45:57Z"
    },
    "status": {
        "api_status": "operational",
        "php_version": "8.2.20",
        "curl_available": true,
        "json_available": true,
        "server_time": "2026-05-26T17:45:57Z",
        "timezone": "UTC",
        "supabase_connectivity": "error",
        "supabase_response_code": 401
    },
    "endpoints": {
        "GET /": {
            "description": "API information and status",
            "parameters": []
        },
        "GET /get-users.php": {
            "description": "Get CRM users with Yeastar extensions",
            "parameters": []
        },
        "POST /get-users.php": {
            "description": "Update user Yeastar extension",
            "parameters": [
                "user_id",
                "extension"
            ]
        },
        "POST /search-contact.php": {
            "description": "Search contacts by phone number or name",
            "parameters": [
                "search"
            ]
        },
        "POST /create-contact.php": {
            "description": "Create new contact from call data",
            "parameters": [
                "first_name",
                "phone",
                "last_name?",
                "email?",
                "company?"
            ]
        },
        "POST /update-contact.php": {
            "description": "Update existing contact",
            "parameters": [
                "contact_id|phone|email",
                "fields_to_update..."
            ]
        },
        "POST /create-task.php": {
            "description": "Create follow-up task",
            "parameters": [
                "title",
                "contact_id",
                "description?",
                "due_date?"
            ]
        },
        "POST /log-call.php": {
            "description": "Log call records to CRM",
            "parameters": [
                "call_logs[]"
            ]
        },
        "POST /sync-contacts.php": {
            "description": "Bulk sync contacts from Yeastar",
            "parameters": [
                "contacts[]"
            ]
        },
        "POST /update-agent-stats.php": {
            "description": "Update agent daily statistics",
            "parameters": [
                "agent_id",
                "stats",
                "date?"
            ]
        },
        "POST /initiate-call.php": {
            "description": "Initiate outbound call via Yeastar",
            "parameters": [
                "caller_extension",
                "callee_number"
            ]
        },
        "POST /webhook-handler.php": {
            "description": "Handle Yeastar webhook events",
            "parameters": [
                "event_data"
            ]
        }
    },
    "usage": {
        "authentication": "No authentication required for most endpoints",
        "content_type": "application/json",
        "cors": "Enabled for all origins",
        "rate_limiting": "None currently implemented"
    },
    "examples": {
        "search_contact": {
            "url": "POST /search-contact.php",
            "body": {
                "search": "2101234567"
            }
        },
        "create_contact": {
            "url": "POST /create-contact.php",
            "body": {
                "first_name": "John",
                "last_name": "Doe",
                "phone": "2101234567",
                "email": "john@example.com"
            }
        },
        "log_call": {
            "url": "POST /log-call.php",
            "body": {
                "call_logs": [
                    {
                        "id": "call_123",
                        "start_time": "2024-01-15T10:30:00Z",
                        "caller": "2101234567",
                        "callee": "101",
                        "duration": 120,
                        "status": "answered"
                    }
                ]
            }
        }
    }
}