{
    "openapi": "3.1.0",
    "info": {
        "title": "Softwire API",
        "version": "1.0.0",
        "description": "REST API and inbound webhooks for Softwire workspaces \u2014 tickets, projects, HRMS attendance, CRM, Git integrations, error monitoring, and lead capture."
    },
    "servers": [
        {
            "url": "https://softwireapp.in/api/v1",
            "description": "Authenticated v1 REST API"
        },
        {
            "url": "https://softwireapp.in/api",
            "description": "Inbound webhooks (no bearer token)"
        }
    ],
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "Workspace API token prefixed with softwire_"
            },
            "webhookSecret": {
                "type": "apiKey",
                "in": "header",
                "name": "X-Softwire-Webhook-Secret"
            }
        },
        "schemas": {
            "TicketCollection": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array"
                    }
                }
            },
            "TicketResource": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object"
                    }
                }
            },
            "TaskResource": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object"
                    }
                }
            },
            "ProjectCollection": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array"
                    }
                }
            },
            "EmployeeCollection": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array"
                    }
                }
            },
            "DealCollection": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array"
                    }
                }
            }
        }
    },
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "paths": {
        "/workspaces/{workspace}/tickets": {
            "get": {
                "summary": "List tickets",
                "tags": [
                    "Tickets"
                ],
                "parameters": [
                    {
                        "name": "workspace",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/TicketCollection"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "Create ticket",
                "tags": [
                    "Tickets"
                ],
                "parameters": [
                    {
                        "name": "workspace",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "title"
                                ],
                                "properties": {
                                    "title": {
                                        "type": "string"
                                    },
                                    "description": {
                                        "type": "string"
                                    },
                                    "priority": {
                                        "type": "string"
                                    },
                                    "category": {
                                        "type": "string"
                                    },
                                    "assigned_to": {
                                        "type": "integer"
                                    },
                                    "project_id": {
                                        "type": "integer"
                                    },
                                    "due_at": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "tags": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Created",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/TicketResource"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/workspaces/{workspace}/tasks": {
            "post": {
                "summary": "Create task",
                "tags": [
                    "Tasks"
                ],
                "parameters": [
                    {
                        "name": "workspace",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "title"
                                ],
                                "properties": {
                                    "title": {
                                        "type": "string"
                                    },
                                    "description": {
                                        "type": "string"
                                    },
                                    "status": {
                                        "type": "string"
                                    },
                                    "priority": {
                                        "type": "string"
                                    },
                                    "project_id": {
                                        "type": "integer"
                                    },
                                    "ticket_id": {
                                        "type": "integer"
                                    },
                                    "parent_id": {
                                        "type": "integer"
                                    },
                                    "assigned_to": {
                                        "type": "integer"
                                    },
                                    "due_at": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "tags": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Created",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/TaskResource"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/workspaces/{workspace}/projects": {
            "get": {
                "summary": "List projects",
                "tags": [
                    "Projects"
                ],
                "parameters": [
                    {
                        "name": "workspace",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ProjectCollection"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/workspaces/{workspace}/hrms/employees": {
            "get": {
                "summary": "List HRMS employees",
                "tags": [
                    "HRMS"
                ],
                "parameters": [
                    {
                        "name": "workspace",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/EmployeeCollection"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/workspaces/{workspace}/hrms/attendance/punch": {
            "post": {
                "summary": "Record attendance punch",
                "tags": [
                    "HRMS"
                ],
                "parameters": [
                    {
                        "name": "workspace",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "employee_code": {
                                        "type": "string"
                                    },
                                    "attendance_uid": {
                                        "type": "string"
                                    },
                                    "user_id": {
                                        "type": "integer"
                                    },
                                    "email": {
                                        "type": "string"
                                    },
                                    "device_id": {
                                        "type": "integer"
                                    },
                                    "external_device_id": {
                                        "type": "string"
                                    },
                                    "source_type": {
                                        "type": "string"
                                    },
                                    "direction": {
                                        "type": "string"
                                    },
                                    "timestamp": {
                                        "type": "string",
                                        "format": "date-time"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Punch recorded"
                    }
                }
            }
        },
        "/workspaces/{workspace}/crm/deals": {
            "get": {
                "summary": "List CRM deals",
                "tags": [
                    "CRM"
                ],
                "parameters": [
                    {
                        "name": "workspace",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/DealCollection"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/workspaces/{workspace}/crm/leads": {
            "post": {
                "summary": "Create CRM lead",
                "tags": [
                    "CRM"
                ],
                "parameters": [
                    {
                        "name": "workspace",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "name",
                                    "source"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "email": {
                                        "type": "string"
                                    },
                                    "phone": {
                                        "type": "string"
                                    },
                                    "company": {
                                        "type": "string"
                                    },
                                    "source": {
                                        "type": "string"
                                    },
                                    "notes": {
                                        "type": "string"
                                    },
                                    "estimated_value": {
                                        "type": "number"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Lead created"
                    },
                    "409": {
                        "description": "Duplicate open lead for email"
                    }
                }
            }
        }
    },
    "tags": [
        {
            "name": "Tickets"
        },
        {
            "name": "Tasks"
        },
        {
            "name": "Projects"
        },
        {
            "name": "HRMS"
        },
        {
            "name": "CRM"
        },
        {
            "name": "Inbound webhooks"
        }
    ]
}