{
    "openapi": "3.0.0",
    "info": {
        "title": "Multi-Tenant API Documentation",
        "description": "API documentation for Multi-Tenant Laravel Application with Stancl Tenancy",
        "contact": {
            "email": "admin@example.com"
        },
        "license": {
            "name": "MIT",
            "url": "https://opensource.org/licenses/MIT"
        },
        "version": "1.0.0"
    },
    "servers": [
        {
            "url": "http://127.0.0.1:8000",
            "description": "Development Server"
        }
    ],
    "paths": {
        "/tenant/login": {
            "post": {
                "tags": [
                    "Authentication"
                ],
                "summary": "Tenant User Login",
                "description": "Authenticate a tenant user and return access token with tenant information",
                "operationId": "782ad5ee5fb62301cf1438f137e9052f",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "email",
                                    "password"
                                ],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "example": "admin@tenant128.com"
                                    },
                                    "password": {
                                        "type": "string",
                                        "format": "password",
                                        "example": "password123"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Login successful",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Login successful"
                                        },
                                        "data": {
                                            "properties": {
                                                "user": {
                                                    "properties": {
                                                        "id": {
                                                            "type": "integer",
                                                            "example": 128
                                                        },
                                                        "name": {
                                                            "type": "string",
                                                            "example": "Admin User 128"
                                                        },
                                                        "email": {
                                                            "type": "string",
                                                            "example": "admin@tenant128.com"
                                                        },
                                                        "role_id": {
                                                            "type": "integer",
                                                            "example": 1
                                                        },
                                                        "role_name": {
                                                            "type": "string",
                                                            "example": "Admin"
                                                        },
                                                        "tenant_id": {
                                                            "type": "string",
                                                            "example": "128"
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "tenant": {
                                                    "properties": {
                                                        "id": {
                                                            "type": "integer",
                                                            "example": 128
                                                        },
                                                        "name": {
                                                            "type": "string",
                                                            "example": "Test Tenant 128"
                                                        },
                                                        "email": {
                                                            "type": "string",
                                                            "example": "tenant128@example.com"
                                                        },
                                                        "domain": {
                                                            "type": "string",
                                                            "example": "test2-kzcl7"
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "access_token": {
                                                    "type": "string",
                                                    "example": "7|E6lmFZWumyJc5XtJJUnb8o41jlrkpMRyJs5QeCX284e8c7ee"
                                                },
                                                "token_type": {
                                                    "type": "string",
                                                    "example": "Bearer"
                                                },
                                                "redirect_urls": {
                                                    "properties": {
                                                        "dashboard": {
                                                            "type": "string",
                                                            "example": "http://127.0.0.1:8000/tenant/128"
                                                        },
                                                        "profile": {
                                                            "type": "string",
                                                            "example": "http://127.0.0.1:8000/tenant/128/profile"
                                                        },
                                                        "logout": {
                                                            "type": "string",
                                                            "example": "http://127.0.0.1:8000/tenant/128/logout"
                                                        }
                                                    },
                                                    "type": "object"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Invalid credentials",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": false
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Invalid credentials or user not found"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validation error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": false
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Validation failed"
                                        },
                                        "errors": {
                                            "properties": {
                                                "email": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string"
                                                    }
                                                },
                                                "password": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string"
                                                    }
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": false
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Login failed"
                                        },
                                        "error": {
                                            "type": "string",
                                            "example": "Error message"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/tenant/{tenant}/profile": {
            "get": {
                "tags": [
                    "Authentication"
                ],
                "summary": "Get User Profile",
                "description": "Get the current authenticated user's profile information",
                "operationId": "1e5cc71eab8b6ba911f71dd709f9cc6d",
                "parameters": [
                    {
                        "name": "tenant",
                        "in": "path",
                        "description": "Tenant ID",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 128
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Profile retrieved successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "data": {
                                            "properties": {
                                                "user": {
                                                    "properties": {
                                                        "id": {
                                                            "type": "integer",
                                                            "example": 128
                                                        },
                                                        "name": {
                                                            "type": "string",
                                                            "example": "Admin User 128"
                                                        },
                                                        "email": {
                                                            "type": "string",
                                                            "example": "admin@tenant128.com"
                                                        },
                                                        "role_id": {
                                                            "type": "integer",
                                                            "example": 1
                                                        },
                                                        "role_name": {
                                                            "type": "string",
                                                            "example": "Admin"
                                                        },
                                                        "tenant_id": {
                                                            "type": "string",
                                                            "example": "128"
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "tenant": {
                                                    "properties": {
                                                        "id": {
                                                            "type": "integer",
                                                            "example": 128
                                                        },
                                                        "name": {
                                                            "type": "string",
                                                            "example": "Test Tenant 128"
                                                        },
                                                        "email": {
                                                            "type": "string",
                                                            "example": "tenant128@example.com"
                                                        },
                                                        "domain": {
                                                            "type": "string",
                                                            "example": "test2-kzcl7"
                                                        }
                                                    },
                                                    "type": "object"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized - Invalid or missing token",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": false
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "No token provided"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Forbidden - Unauthorized access to tenant",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": false
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Unauthorized access to tenant"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/tenant/{tenant}/users/signup": {
            "post": {
                "tags": [
                    "User Management"
                ],
                "summary": "Create New User",
                "description": "Create a new user within the tenant's isolated database",
                "operationId": "61a901158cad44587f2051611c484a1d",
                "parameters": [
                    {
                        "name": "tenant",
                        "in": "path",
                        "description": "Tenant ID",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 146
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "name",
                                    "email",
                                    "mobile",
                                    "password"
                                ],
                                "properties": {
                                    "name": {
                                        "description": "User's full name",
                                        "type": "string",
                                        "example": "John Doe"
                                    },
                                    "email": {
                                        "description": "User's email address",
                                        "type": "string",
                                        "format": "email",
                                        "example": "john.doe@example.com"
                                    },
                                    "mobile": {
                                        "description": "User's mobile number",
                                        "type": "string",
                                        "example": "5551234567"
                                    },
                                    "password": {
                                        "description": "User's password (min 6 characters)",
                                        "type": "string",
                                        "format": "password",
                                        "example": "password123"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "User created successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "User created successfully"
                                        },
                                        "data": {
                                            "properties": {
                                                "user": {
                                                    "properties": {
                                                        "id": {
                                                            "type": "integer",
                                                            "example": 1
                                                        },
                                                        "name": {
                                                            "type": "string",
                                                            "example": "John Doe"
                                                        },
                                                        "email": {
                                                            "type": "string",
                                                            "example": "john.doe@example.com"
                                                        },
                                                        "mobile": {
                                                            "type": "string",
                                                            "example": "5551234567"
                                                        },
                                                        "tenant_id": {
                                                            "type": "integer",
                                                            "example": 146
                                                        },
                                                        "role_id": {
                                                            "type": "integer",
                                                            "example": 2
                                                        },
                                                        "status": {
                                                            "type": "integer",
                                                            "example": 1
                                                        },
                                                        "user_type": {
                                                            "type": "string",
                                                            "example": "tenant_user"
                                                        },
                                                        "created_at": {
                                                            "type": "string",
                                                            "format": "date-time",
                                                            "example": "2025-09-17 08:03:20"
                                                        }
                                                    },
                                                    "type": "object"
                                                },
                                                "tenant": {
                                                    "properties": {
                                                        "id": {
                                                            "type": "integer",
                                                            "example": 146
                                                        },
                                                        "name": {
                                                            "type": "string",
                                                            "example": "Ravi Raj"
                                                        }
                                                    },
                                                    "type": "object"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Tenant not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": false
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Tenant not found"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validation error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": false
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Validation failed"
                                        },
                                        "errors": {
                                            "properties": {
                                                "email": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string"
                                                    }
                                                },
                                                "mobile": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string"
                                                    }
                                                },
                                                "name": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string"
                                                    }
                                                },
                                                "password": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string"
                                                    }
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": false
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "User creation failed"
                                        },
                                        "error": {
                                            "type": "string",
                                            "example": "Error message"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/tenant/{tenant}/users": {
            "get": {
                "tags": [
                    "User Management"
                ],
                "summary": "List All Users",
                "description": "Get a list of all users within the tenant's isolated database",
                "operationId": "28185d726922d1555e66afc99074bf4d",
                "parameters": [
                    {
                        "name": "tenant",
                        "in": "path",
                        "description": "Tenant ID",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 146
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Users retrieved successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "data": {
                                            "properties": {
                                                "users": {
                                                    "type": "array",
                                                    "items": {
                                                        "properties": {
                                                            "id": {
                                                                "type": "integer",
                                                                "example": 1
                                                            },
                                                            "name": {
                                                                "type": "string",
                                                                "example": "John Doe"
                                                            },
                                                            "email": {
                                                                "type": "string",
                                                                "example": "john.doe@example.com"
                                                            },
                                                            "mobile": {
                                                                "type": "string",
                                                                "example": "5551234567"
                                                            },
                                                            "role_id": {
                                                                "type": "integer",
                                                                "example": 2
                                                            },
                                                            "status": {
                                                                "type": "integer",
                                                                "example": 1
                                                            },
                                                            "user_type": {
                                                                "type": "string",
                                                                "example": "tenant_user"
                                                            },
                                                            "created_at": {
                                                                "type": "string",
                                                                "format": "date-time",
                                                                "example": "2025-09-17T08:03:51.000000Z"
                                                            }
                                                        },
                                                        "type": "object"
                                                    }
                                                },
                                                "total": {
                                                    "type": "integer",
                                                    "example": 2
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": false
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Failed to fetch users"
                                        },
                                        "error": {
                                            "type": "string",
                                            "example": "Error message"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/tenant/{tenant}/users/{user}": {
            "get": {
                "tags": [
                    "User Management"
                ],
                "summary": "Get User Details",
                "description": "Get detailed information about a specific user within the tenant's database",
                "operationId": "404d4d1ac4fd8eed3d87a7432025afb8",
                "parameters": [
                    {
                        "name": "tenant",
                        "in": "path",
                        "description": "Tenant ID",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 146
                        }
                    },
                    {
                        "name": "user",
                        "in": "path",
                        "description": "User ID",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "User details retrieved successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "data": {
                                            "properties": {
                                                "user": {
                                                    "properties": {
                                                        "id": {
                                                            "type": "integer",
                                                            "example": 1
                                                        },
                                                        "name": {
                                                            "type": "string",
                                                            "example": "John Doe"
                                                        },
                                                        "email": {
                                                            "type": "string",
                                                            "example": "john.doe@example.com"
                                                        },
                                                        "mobile": {
                                                            "type": "string",
                                                            "example": "5551234567"
                                                        },
                                                        "tenant_id": {
                                                            "type": "string",
                                                            "example": "146"
                                                        },
                                                        "role_id": {
                                                            "type": "integer",
                                                            "example": 2
                                                        },
                                                        "status": {
                                                            "type": "integer",
                                                            "example": 1
                                                        },
                                                        "user_type": {
                                                            "type": "string",
                                                            "example": "tenant_user"
                                                        },
                                                        "created_at": {
                                                            "type": "string",
                                                            "format": "date-time",
                                                            "example": "2025-09-17 08:03:20"
                                                        },
                                                        "updated_at": {
                                                            "type": "string",
                                                            "format": "date-time",
                                                            "example": "2025-09-17 08:03:20"
                                                        }
                                                    },
                                                    "type": "object"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "User not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": false
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "User not found"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": false
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Failed to fetch user"
                                        },
                                        "error": {
                                            "type": "string",
                                            "example": "Error message"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "description": "Enter your API token",
                "bearerFormat": "JWT",
                "scheme": "bearer"
            }
        }
    },
    "tags": [
        {
            "name": "Authentication",
            "description": "Tenant authentication endpoints"
        },
        {
            "name": "User Management",
            "description": "Tenant user management endpoints"
        }
    ]
}