{
    "openapi": "3.1.0",
    "info": {
        "title": "FlowCall API",
        "version": "v1",
        "description": "REST API for call projects: create and edit leads, record call outcomes, manage follow-ups, import and export lists, assign roles and run reports."
    },
    "servers": [
        {
            "url": "https://api.flowsuite.one",
            "description": "FlowSuite API"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "context",
            "description": "Overview"
        },
        {
            "name": "projects",
            "description": "Projects"
        },
        {
            "name": "guideline",
            "description": "Call guide and form"
        },
        {
            "name": "imports",
            "description": "Imports"
        },
        {
            "name": "exports",
            "description": "Exports"
        },
        {
            "name": "leads",
            "description": "Leads"
        },
        {
            "name": "comments",
            "description": "Comments"
        },
        {
            "name": "follow-ups",
            "description": "Follow-ups"
        },
        {
            "name": "calls",
            "description": "Calls"
        },
        {
            "name": "emails",
            "description": "Emails"
        },
        {
            "name": "team",
            "description": "Team and roles"
        },
        {
            "name": "call-history",
            "description": "Call log"
        },
        {
            "name": "reports",
            "description": "Reports"
        }
    ],
    "paths": {
        "/flowcall/context": {
            "get": {
                "operationId": "flowcall-context",
                "summary": "Get projects, rights and terms",
                "description": "Returns every reachable call project with your own rights in it, the ten permission names, the usual call outcomes and whether this key acts as owner. One call, so a program doesn't have to hard-code the terms of this API.",
                "tags": [
                    "context"
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "acts_as_owner": false,
                                        "permission_flags": [
                                            "team_verwalten",
                                            "team_rollen_verwalten",
                                            "callhistory_all",
                                            "projekte_verwalten",
                                            "projekt_bearbeiten",
                                            "projekt_alle_leads",
                                            "projekt_leads_export",
                                            "projekt_telefonie",
                                            "projekt_lead_hinzufuegen",
                                            "projekt_unstimmigkeiten"
                                        ],
                                        "lead_statuses": [
                                            "Offen",
                                            "Übersprungen",
                                            "Kein Interesse",
                                            "Keinen erreicht",
                                            "Falsche Rufnummer",
                                            "AP nicht im hause",
                                            "Wiedervorlage",
                                            "E-Mail senden",
                                            "Termin vereinbart"
                                        ],
                                        "projects": [
                                            {
                                                "uuid": "8f1c4a72-3d95-4e06-b1a8-5c7e2d0f9b41",
                                                "name": "Herbstaktion Handwerk",
                                                "status": "active",
                                                "rights": {
                                                    "projekt_telefonie": true,
                                                    "projekt_alle_leads": true,
                                                    "projekte_verwalten": false
                                                }
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects": {
            "get": {
                "operationId": "flowcall-projects-index",
                "summary": "List call projects",
                "description": "All call projects this key reaches, newest first.",
                "tags": [
                    "projects"
                ],
                "parameters": [
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Entries per page, 1 to 200, default 25.",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number, default 1.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "8f1c4a72-3d95-4e06-b1a8-5c7e2d0f9b41",
                                            "name": "Herbstaktion Handwerk",
                                            "status": "active",
                                            "call_again_after_attempts": "3",
                                            "appointment_link": "https://termine.example.com/herbst",
                                            "email_service": true,
                                            "sender_name": "Vertrieb",
                                            "sender_email": "vertrieb@example.com",
                                            "form_fields": [],
                                            "created_at": "2026-09-01T09:00:00+02:00",
                                            "updated_at": "2026-09-18T11:20:00+02:00"
                                        }
                                    ],
                                    "meta": {
                                        "current_page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "flowcall-projects-store",
                "summary": "Create a call project",
                "description": "Turns an existing client project into a call project, or creates both in one go. Exactly one of project_uuid and client_uuid is required. If the client project already has a call configuration, the call answers with HTTP 422 and the error already_exists. This permission is checked team-wide, because a project that doesn't exist yet can't have a permission row of its own.",
                "tags": [
                    "projects"
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "8f1c4a72-3d95-4e06-b1a8-5c7e2d0f9b41",
                                        "name": "Herbstaktion Handwerk",
                                        "status": "active",
                                        "call_again_after_attempts": "3",
                                        "appointment_link": null,
                                        "email_service": false,
                                        "sender_name": null,
                                        "sender_email": null,
                                        "form_fields": []
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "project_uuid": {
                                        "type": "string",
                                        "description": "An existing client project of the team. Required if client_uuid is missing."
                                    },
                                    "client_uuid": {
                                        "type": "string",
                                        "description": "A client of the team under which a new project is created. Required if project_uuid is missing."
                                    },
                                    "name": {
                                        "type": "string",
                                        "description": "Name of the new project, at most 255 characters. Required together with client_uuid."
                                    },
                                    "appointment_link": {
                                        "type": "string",
                                        "description": "Booking link for appointments, http or https, at most 2048 characters."
                                    },
                                    "call_again_after_attempts": {
                                        "type": "string",
                                        "description": "After how many unsuccessful attempts the lead is called again. Free text, at most 10 characters, default 3."
                                    },
                                    "email_service": {
                                        "type": "boolean",
                                        "description": "Switches on email sending for the project."
                                    },
                                    "sender_name": {
                                        "type": "string",
                                        "description": "Sender name, only stored when email sending is on."
                                    },
                                    "sender_email": {
                                        "type": "string",
                                        "description": "Sender address, only stored when email sending is on."
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}": {
            "get": {
                "operationId": "flowcall-projects-show",
                "summary": "Get a call project",
                "description": "A project with your own rights in it, the period, the agreed scope, the description and the overview figures. Unworked means a lead with no outcome row at all, which is something different from a lead with the outcome Offen.",
                "tags": [
                    "projects"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "8f1c4a72-3d95-4e06-b1a8-5c7e2d0f9b41",
                                        "name": "Herbstaktion Handwerk",
                                        "status": "active",
                                        "call_again_after_attempts": "3",
                                        "email_service": true,
                                        "form_fields": [],
                                        "rights": {
                                            "projekt_telefonie": true,
                                            "projekt_alle_leads": true
                                        },
                                        "start_date": "2026-09-01",
                                        "end_date": "2026-12-31",
                                        "hours": "40 pro Monat",
                                        "information": "Zielgruppe Handwerksbetriebe ab zehn Mitarbeitenden.",
                                        "stats": {
                                            "leads": 1240,
                                            "locked": 3,
                                            "untouched": 480,
                                            "by_status": {
                                                "Termin vereinbart": 62,
                                                "Kein Interesse": 190
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}/settings": {
            "put": {
                "operationId": "flowcall-projects-settings",
                "summary": "Change a project's settings",
                "description": "Changes the call settings that are not credentials. A field that is left out stays unchanged. If email sending is switched off, the project loses its sender details, so it never keeps writing under a sender nobody remembers. Requires projekte_verwalten.",
                "tags": [
                    "projects"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "8f1c4a72-3d95-4e06-b1a8-5c7e2d0f9b41",
                                        "name": "Herbstaktion Handwerk",
                                        "status": "active",
                                        "call_again_after_attempts": "5",
                                        "appointment_link": "https://termine.example.com/herbst",
                                        "email_service": false,
                                        "sender_name": null,
                                        "sender_email": null,
                                        "form_fields": []
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "appointment_link": {
                                        "type": "string",
                                        "description": "Booking link for appointments, http or https, at most 2048 characters, or null."
                                    },
                                    "call_again_after_attempts": {
                                        "type": "string",
                                        "description": "Free text, at most 10 characters, or null."
                                    },
                                    "email_service": {
                                        "type": "boolean",
                                        "description": "Switches email sending for the project on or off."
                                    },
                                    "sender_name": {
                                        "type": "string",
                                        "description": "Sender name, at most 255 characters, or null."
                                    },
                                    "sender_email": {
                                        "type": "string",
                                        "description": "Sender address, at most 255 characters, or null."
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}/dates": {
            "put": {
                "operationId": "flowcall-projects-dates",
                "summary": "Change period, scope and description",
                "description": "Sets the period, the agreed scope and the project description. The scope is free text, because it holds values such as 40 per month that a plain number would reject. Requires projekte_verwalten.",
                "tags": [
                    "projects"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "start_date": "2026-09-01",
                                        "end_date": "2026-12-31",
                                        "hours": "40 pro Monat",
                                        "information": "Zielgruppe Handwerksbetriebe ab zehn Mitarbeitenden."
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "start_date": {
                                        "type": "string",
                                        "description": "Start in the format YYYY-MM-DD, or null."
                                    },
                                    "end_date": {
                                        "type": "string",
                                        "description": "End in the format YYYY-MM-DD, not before the start, or null."
                                    },
                                    "hours": {
                                        "type": "string",
                                        "description": "Agreed scope as free text, at most 255 characters, or null."
                                    },
                                    "information": {
                                        "type": "string",
                                        "description": "Description of the project, at most 200000 characters, or null."
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}/status": {
            "put": {
                "operationId": "flowcall-projects-status",
                "summary": "Switch a project on or off",
                "description": "Sets the status of the client project to active or inactive. The status reaches beyond FlowCall, because it belongs to the client project. Requires projekte_verwalten.",
                "tags": [
                    "projects"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "8f1c4a72-3d95-4e06-b1a8-5c7e2d0f9b41",
                                        "name": "Herbstaktion Handwerk",
                                        "status": "inactive",
                                        "email_service": true,
                                        "form_fields": []
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "status": {
                                        "type": "string",
                                        "description": "active or inactive. Any other value is rejected."
                                    }
                                },
                                "required": [
                                    "status"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}/leads/unworked": {
            "delete": {
                "operationId": "flowcall-projects-leads-unworked",
                "summary": "Delete a project's unworked leads",
                "description": "Removes every lead of the project that nobody has touched. Unworked means: neither an outcome nor a comment. A lead that was called once is never included. Requires projekte_verwalten.",
                "tags": [
                    "projects"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "deleted": 480
                                    },
                                    "message": "480 unbearbeitete Leads wurden gelöscht."
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}/guideline": {
            "get": {
                "operationId": "flowcall-guideline-show",
                "summary": "Get the call guide",
                "description": "Returns the project's shared guide or your own version. Requires projekt_bearbeiten or projekt_telefonie.",
                "tags": [
                    "guideline"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "required": false,
                        "description": "original or user. Default is original.",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "d4a9b021-6e37-4c58-90f1-2b8c5e7d0a63",
                                        "type": "original",
                                        "content": "Guten Tag, mein Name ist ...",
                                        "updated_at": "2026-09-14T10:05:00+02:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "operationId": "flowcall-guideline-update",
                "summary": "Write the call guide",
                "description": "Writes the guide. The shared version requires projekt_bearbeiten, your own version projekt_telefonie.",
                "tags": [
                    "guideline"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "d4a9b021-6e37-4c58-90f1-2b8c5e7d0a63",
                                        "type": "original",
                                        "content": "Guten Tag, mein Name ist ...",
                                        "updated_at": "2026-09-20T08:30:00+02:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "content": {
                                        "type": "string",
                                        "description": "The text, at most 200000 characters."
                                    },
                                    "type": {
                                        "type": "string",
                                        "description": "original or user. Default is original."
                                    }
                                },
                                "required": [
                                    "content"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}/form": {
            "get": {
                "operationId": "flowcall-form-show",
                "summary": "Get the project form",
                "description": "The fields filled in during a call. Requires projekt_bearbeiten or projekt_telefonie.",
                "tags": [
                    "guideline"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "fields": [
                                            {
                                                "label": "Anzahl Mitarbeitende",
                                                "typ": "number",
                                                "placeholder": "z. B. 15"
                                            },
                                            {
                                                "label": "Interesse an",
                                                "typ": "select",
                                                "optionen": [
                                                    "Webseite",
                                                    "Wartung"
                                                ]
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "operationId": "flowcall-form-update",
                "summary": "Replace the project form",
                "description": "Replaces the field list in full. An empty list removes the form. Requires projekte_verwalten.",
                "tags": [
                    "guideline"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "fields": [
                                            {
                                                "label": "Anzahl Mitarbeitende",
                                                "typ": "number",
                                                "placeholder": "z. B. 15"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "fields": {
                                        "type": "array",
                                        "items": [],
                                        "description": "The complete field list. The field must be present but may be empty.",
                                        "properties": {
                                            "*.label": {
                                                "type": "string",
                                                "description": "Label of the field, at most 255 characters."
                                            },
                                            "*.typ": {
                                                "type": "string",
                                                "description": "text, textarea, select, checkbox, radio, date or number."
                                            },
                                            "*.placeholder": {
                                                "type": "string",
                                                "description": "Placeholder text, at most 255 characters."
                                            },
                                            "*.optionen": {
                                                "type": "array",
                                                "items": [],
                                                "description": "Choices for select, checkbox and radio, each at most 255 characters."
                                            }
                                        }
                                    }
                                },
                                "required": [
                                    "fields"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}/imports": {
            "get": {
                "operationId": "flowcall-imports-index",
                "summary": "List a project's imports",
                "description": "The uploaded lead lists of a project, newest first. The state is a short chain: uploaded means the file is there and nothing has happened, queued means the mapping is set and the work is waiting, processing means it is running, then finished or failed. Requires projekte_verwalten.",
                "tags": [
                    "imports"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Entries per page, 1 to 200, default 25.",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number, default 1.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "b20e6c47-91fd-4a35-8c07-3e1b9d5a7f28",
                                            "status": "finished",
                                            "filename": "handwerk-september.csv",
                                            "total_rows": 1240,
                                            "processed_rows": 1240,
                                            "mapping": {
                                                "Firma": "firma",
                                                "Telefon": "phone_numbers:Zentrale",
                                                "Notiz": null
                                            },
                                            "error_message": null,
                                            "created_at": "2026-09-05T14:02:00+02:00",
                                            "updated_at": "2026-09-05T14:09:00+02:00"
                                        }
                                    ],
                                    "meta": {
                                        "current_page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "flowcall-imports-store",
                "summary": "Upload a lead list",
                "description": "Accepts a lead list as multipart/form-data and answers with HTTP 201. Without mapping, the response contains the file's column headings and the possible target fields, and the import waits. With mapping it starts immediately; an unusable mapping answers with HTTP 422 and the error invalid_mapping. Requires projekte_verwalten.",
                "tags": [
                    "imports"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "b20e6c47-91fd-4a35-8c07-3e1b9d5a7f28",
                                        "status": "uploaded",
                                        "filename": "handwerk-september.csv",
                                        "total_rows": 0,
                                        "processed_rows": 0,
                                        "mapping": null,
                                        "error_message": null,
                                        "headers": [
                                            "Firma",
                                            "Telefon",
                                            "Notiz"
                                        ],
                                        "mappable_fields": [
                                            "firma",
                                            "ansprechpartner",
                                            "vorname",
                                            "nachname",
                                            "anschrift",
                                            "strasse",
                                            "hausnummer",
                                            "plz",
                                            "stadt",
                                            "bundesland",
                                            "land",
                                            "phone_numbers",
                                            "emails",
                                            "websites"
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "file": {
                                        "type": "string",
                                        "format": "binary",
                                        "description": "The lead list as txt, csv, xls or xlsx, at most 50 MB."
                                    },
                                    "mapping": {
                                        "type": "object",
                                        "description": "Mapping from column heading to target field. After a colon, a value may carry the label of a value collection, for example emails:Allgemein. null means the column is skipped."
                                    },
                                    "url": {
                                        "type": "string",
                                        "description": "Explicitly rejected. A file is uploaded, not fetched from an address."
                                    }
                                },
                                "required": [
                                    "file"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}/imports/{importUuid}/mapping": {
            "put": {
                "operationId": "flowcall-imports-mapping",
                "summary": "Set an import's column mapping",
                "description": "Sets the column mapping of an uploaded list and hands the import over to the queue. Every column heading of the file belongs in the mapping, including the ones that map to nothing; they then carry the value null. An unusable mapping answers with HTTP 422 and the error invalid_mapping. Requires projekte_verwalten.",
                "tags": [
                    "imports"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "importUuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "b20e6c47-91fd-4a35-8c07-3e1b9d5a7f28",
                                        "status": "queued",
                                        "filename": "handwerk-september.csv",
                                        "total_rows": 0,
                                        "processed_rows": 0,
                                        "mapping": {
                                            "Firma": "firma",
                                            "Telefon": "phone_numbers:Zentrale",
                                            "Notiz": null
                                        },
                                        "error_message": null
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "mapping": {
                                        "type": "object",
                                        "description": "Mapping from column heading to target field, at least one entry. After a colon, a value may carry the label of a value collection, for example emails:Allgemein. null means the column is skipped."
                                    }
                                },
                                "required": [
                                    "mapping"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}/imports/{importUuid}/retry": {
            "post": {
                "operationId": "flowcall-imports-retry",
                "summary": "Restart an import",
                "description": "Restarts a failed import with the mapping it already has. An import in any other state answers with HTTP 409 and the error not_retryable. Requires projekte_verwalten.",
                "tags": [
                    "imports"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "importUuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "b20e6c47-91fd-4a35-8c07-3e1b9d5a7f28",
                                        "status": "queued",
                                        "filename": "handwerk-september.csv",
                                        "total_rows": 1240,
                                        "processed_rows": 0,
                                        "error_message": null
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}/exports": {
            "get": {
                "operationId": "flowcall-exports-index",
                "summary": "List a project's exports",
                "description": "A project's exports with their state and expiry. Requires projekt_leads_export.",
                "tags": [
                    "exports"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Entries per page, 1 to 200, default 25.",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number, default 1.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "6ad3f158-70c2-4b91-a5de-0f4c8b26e719",
                                            "status": "completed",
                                            "recipient_email": "vertrieb@example.com",
                                            "filename": "leads-herbstaktion.xlsx",
                                            "expires_at": "2026-09-21T14:02:00+02:00",
                                            "expired": false,
                                            "created_at": "2026-09-20T14:02:00+02:00"
                                        }
                                    ],
                                    "meta": {
                                        "current_page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "flowcall-exports-store",
                "summary": "Start an export",
                "description": "Queues an export of the leads and answers with HTTP 202. Without recipient_email, the announcement goes to your own address. Requires projekt_leads_export.",
                "tags": [
                    "exports"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "6ad3f158-70c2-4b91-a5de-0f4c8b26e719",
                                        "status": "pending",
                                        "recipient_email": "vertrieb@example.com",
                                        "filename": null,
                                        "expires_at": null,
                                        "expired": false,
                                        "created_at": "2026-09-20T14:02:00+02:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "recipient_email": {
                                        "type": "string",
                                        "description": "Recipient of the announcement. Default is your own address."
                                    },
                                    "status": {
                                        "type": "string",
                                        "description": "Limits the export to one call outcome. The value all covers every lead and is the default."
                                    },
                                    "include_call_results": {
                                        "type": "boolean",
                                        "description": "Includes the call history in the file."
                                    },
                                    "max_call_results": {
                                        "type": "integer",
                                        "description": "How many history entries per lead, 1 to 100, default 5."
                                    },
                                    "include_comments": {
                                        "type": "boolean",
                                        "description": "Includes the comments in the file."
                                    },
                                    "max_comments": {
                                        "type": "integer",
                                        "description": "How many comments per lead, 1 to 100, default 5."
                                    },
                                    "highlight_rows": {
                                        "type": "boolean",
                                        "description": "Highlights the rows in colour according to their call outcome."
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/projects/{uuid}/exports/{exportUuid}/download": {
            "get": {
                "operationId": "flowcall-exports-download",
                "summary": "Download a finished export file",
                "description": "Returns the finished file as a download. An export that is still running, failed or expired answers with HTTP 409 and the error not_ready. If the file no longer exists, the call answers with HTTP 410 and the error file_missing. Requires projekt_leads_export.",
                "tags": [
                    "exports"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "exportUuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/octet-stream": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/leads": {
            "get": {
                "operationId": "flowcall-leads-index",
                "summary": "List leads",
                "description": "The leads of all reachable projects, newest first, filtered and paginated. Without project_uuid, the list covers every project this key sees.",
                "tags": [
                    "leads"
                ],
                "parameters": [
                    {
                        "name": "project_uuid",
                        "in": "query",
                        "required": false,
                        "description": "Limit to one call project.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "required": false,
                        "description": "Only leads with this call outcome, for example Termin vereinbart.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "assigned_user_uuid",
                        "in": "query",
                        "required": false,
                        "description": "Only leads assigned to this team member.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "required": false,
                        "description": "Searches company, contact person, first name, last name and city.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "follow_up_due",
                        "in": "query",
                        "required": false,
                        "description": "Only leads whose follow-up is due today or overdue.",
                        "schema": {
                            "type": "boolean"
                        }
                    },
                    {
                        "name": "locked",
                        "in": "query",
                        "required": false,
                        "description": "Only leads that are currently being worked on, or only the free ones.",
                        "schema": {
                            "type": "boolean"
                        }
                    },
                    {
                        "name": "untouched",
                        "in": "query",
                        "required": false,
                        "description": "Only leads with no outcome row at all.",
                        "schema": {
                            "type": "boolean"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Entries per page, 1 to 200, default 25.",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number, default 1.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                            "project_uuid": "8f1c4a72-3d95-4e06-b1a8-5c7e2d0f9b41",
                                            "company": "Doe Bedachungen",
                                            "contact_person": "Frau Keller",
                                            "first_name": null,
                                            "last_name": null,
                                            "address": null,
                                            "street": "Hauptstraße",
                                            "house_number": "12",
                                            "postcode": "50667",
                                            "city": "Köln",
                                            "state": "Nordrhein-Westfalen",
                                            "country": "Deutschland",
                                            "phone_numbers": [
                                                {
                                                    "label": "Zentrale",
                                                    "value": "0221 1234567"
                                                }
                                            ],
                                            "emails": [
                                                {
                                                    "label": "Allgemein",
                                                    "value": "info@example.com"
                                                }
                                            ],
                                            "websites": [],
                                            "extra": [],
                                            "form_data": [],
                                            "locked": false,
                                            "locked_until": null,
                                            "status": "Wiedervorlage",
                                            "created_at": "2026-09-05T14:09:00+02:00",
                                            "updated_at": "2026-09-19T16:42:00+02:00"
                                        }
                                    ],
                                    "meta": {
                                        "current_page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "flowcall-leads-store",
                "summary": "Create a lead",
                "description": "Creates a lead in a call project and answers with HTTP 201. The platform assigns the ID; a reference of your own belongs in extra. Requires projekt_lead_hinzufuegen.",
                "tags": [
                    "leads"
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                        "project_uuid": "8f1c4a72-3d95-4e06-b1a8-5c7e2d0f9b41",
                                        "company": "Doe Bedachungen",
                                        "contact_person": "Frau Keller",
                                        "city": "Köln",
                                        "phone_numbers": [
                                            {
                                                "label": "Zentrale",
                                                "value": "0221 1234567"
                                            }
                                        ],
                                        "emails": [],
                                        "websites": [],
                                        "extra": [],
                                        "form_data": [],
                                        "locked": false,
                                        "locked_until": null
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "project_uuid": {
                                        "type": "string",
                                        "description": "The call project, addressed by the UUID of the client project."
                                    },
                                    "company": {
                                        "type": "string",
                                        "description": "Company, at most 255 characters."
                                    },
                                    "contact_person": {
                                        "type": "string",
                                        "description": "Contact person, at most 255 characters."
                                    },
                                    "first_name": {
                                        "type": "string",
                                        "description": "First name, at most 255 characters."
                                    },
                                    "last_name": {
                                        "type": "string",
                                        "description": "Last name, at most 255 characters."
                                    },
                                    "address": {
                                        "type": "string",
                                        "description": "Full address as a single field, at most 1000 characters."
                                    },
                                    "street": {
                                        "type": "string",
                                        "description": "Street, at most 255 characters."
                                    },
                                    "house_number": {
                                        "type": "string",
                                        "description": "House number, at most 50 characters."
                                    },
                                    "postcode": {
                                        "type": "string",
                                        "description": "Postcode, at most 20 characters."
                                    },
                                    "city": {
                                        "type": "string",
                                        "description": "City, at most 255 characters."
                                    },
                                    "state": {
                                        "type": "string",
                                        "description": "State or region, at most 255 characters."
                                    },
                                    "country": {
                                        "type": "string",
                                        "description": "Country, at most 255 characters."
                                    },
                                    "phone_numbers": {
                                        "type": "array",
                                        "items": [],
                                        "description": "List of pairs with label and value. Plain text without a label is not accepted."
                                    },
                                    "emails": {
                                        "type": "array",
                                        "items": [],
                                        "description": "List of pairs with label and value."
                                    },
                                    "websites": {
                                        "type": "array",
                                        "items": [],
                                        "description": "List of pairs with label and value."
                                    },
                                    "extra": {
                                        "type": "array",
                                        "items": [],
                                        "description": "Further details, freely structured. The right place for a reference of your own."
                                    },
                                    "form_data": {
                                        "type": "array",
                                        "items": [],
                                        "description": "Answers of the project form, stored under the keys of the fields."
                                    },
                                    "project_id": {
                                        "type": "integer",
                                        "description": "Rejected. Use project_uuid instead."
                                    },
                                    "team_id": {
                                        "type": "integer",
                                        "description": "Rejected. The team follows from the API key."
                                    }
                                },
                                "required": [
                                    "project_uuid"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/leads/{uuid}": {
            "get": {
                "operationId": "flowcall-leads-show",
                "summary": "Get a lead",
                "description": "A lead with its current call outcome, the person responsible and everything attached to it. The sub-lists are limited: up to 50 calls, 50 comments and 50 emails, plus the follow-up. If you need the full history, use the dedicated lists. Requires projekt_alle_leads or projekt_telefonie.",
                "tags": [
                    "leads"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                        "project_uuid": "8f1c4a72-3d95-4e06-b1a8-5c7e2d0f9b41",
                                        "company": "Doe Bedachungen",
                                        "city": "Köln",
                                        "locked": false,
                                        "status": "Wiedervorlage",
                                        "assigned_user_uuid": "3f8b1c6e-2d44-4a9b-8e77-5c1a0b9d3e22",
                                        "calls": [
                                            {
                                                "uuid": "0c95e2a7-48b3-4d61-90fa-7e2c5b8d1436",
                                                "status": "Keinen erreicht",
                                                "agent_name": "Anna Berger",
                                                "created_at": "2026-09-18T09:15:00+02:00"
                                            }
                                        ],
                                        "comments": [
                                            {
                                                "uuid": "a1d7b309-64ce-4f28-8b05-9c3e7f0a2d54",
                                                "text": "Ruft nächste Woche zurück.",
                                                "system": false,
                                                "agent_name": "Anna Berger",
                                                "created_at": "2026-09-19T16:42:00+02:00"
                                            }
                                        ],
                                        "follow_ups": [
                                            {
                                                "uuid": "5e8c0b43-2fa7-4916-8d3c-1b6a9e4f7c20",
                                                "date": "2026-09-25",
                                                "time": "09:30",
                                                "agent_name": "Anna Berger"
                                            }
                                        ],
                                        "emails": []
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "operationId": "flowcall-leads-update",
                "summary": "Update a lead",
                "description": "Changes a lead's master data. A field that is left out stays unchanged. The change is recorded as a comment, just as in the interface; such comments carry the marker system in the comment list. The fields are the same as when creating. project_uuid, project_id and team_id are rejected. Requires projekt_bearbeiten or projekt_telefonie.",
                "tags": [
                    "leads"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                        "project_uuid": "8f1c4a72-3d95-4e06-b1a8-5c7e2d0f9b41",
                                        "company": "Doe Bedachungen GmbH",
                                        "city": "Köln",
                                        "locked": false,
                                        "updated_at": "2026-09-20T10:11:00+02:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "company": {
                                        "type": "string",
                                        "description": "Company, at most 255 characters."
                                    },
                                    "contact_person": {
                                        "type": "string",
                                        "description": "Contact person, at most 255 characters."
                                    },
                                    "first_name": {
                                        "type": "string",
                                        "description": "First name, at most 255 characters."
                                    },
                                    "last_name": {
                                        "type": "string",
                                        "description": "Last name, at most 255 characters."
                                    },
                                    "address": {
                                        "type": "string",
                                        "description": "Full address as a single field, at most 1000 characters."
                                    },
                                    "street": {
                                        "type": "string",
                                        "description": "Street, at most 255 characters."
                                    },
                                    "house_number": {
                                        "type": "string",
                                        "description": "House number, at most 50 characters."
                                    },
                                    "postcode": {
                                        "type": "string",
                                        "description": "Postcode, at most 20 characters."
                                    },
                                    "city": {
                                        "type": "string",
                                        "description": "City, at most 255 characters."
                                    },
                                    "state": {
                                        "type": "string",
                                        "description": "State or region, at most 255 characters."
                                    },
                                    "country": {
                                        "type": "string",
                                        "description": "Country, at most 255 characters."
                                    },
                                    "phone_numbers": {
                                        "type": "array",
                                        "items": [],
                                        "description": "List of pairs with label and value."
                                    },
                                    "emails": {
                                        "type": "array",
                                        "items": [],
                                        "description": "List of pairs with label and value."
                                    },
                                    "websites": {
                                        "type": "array",
                                        "items": [],
                                        "description": "List of pairs with label and value."
                                    },
                                    "extra": {
                                        "type": "array",
                                        "items": [],
                                        "description": "Further details, freely structured."
                                    },
                                    "form_data": {
                                        "type": "array",
                                        "items": [],
                                        "description": "Answers of the project form."
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "flowcall-leads-destroy",
                "summary": "Delete a lead",
                "description": "Removes the lead together with its calls, comments, follow-ups and emails. Requires projekte_verwalten.",
                "tags": [
                    "leads"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "message": "Lead gelöscht."
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/leads/{uuid}/status": {
            "put": {
                "operationId": "flowcall-leads-status",
                "summary": "Record a call outcome",
                "description": "Writes the lead's current call outcome and overwrites the previous one. In the same step you can optionally create a comment, an entry in the call history and a new follow-up. Every recorded outcome closes the open follow-up, unless a new date is passed at the same time. Requires projekt_telefonie.",
                "tags": [
                    "leads"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                        "status": "Wiedervorlage",
                                        "follow_up_date": "2026-09-25"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "status": {
                                        "type": "string",
                                        "description": "The call outcome, at most 255 characters. Usual values are Offen, Übersprungen, Kein Interesse, Keinen erreicht, Falsche Rufnummer, AP nicht im hause, Wiedervorlage, E-Mail senden and Termin vereinbart; the field is free text."
                                    },
                                    "comment": {
                                        "type": "string",
                                        "description": "Recorded as a comment on the lead, at most 60000 characters."
                                    },
                                    "follow_up_date": {
                                        "type": "string",
                                        "description": "New follow-up in the format YYYY-MM-DD. Without a value, the open follow-up is closed."
                                    },
                                    "follow_up_time": {
                                        "type": "string",
                                        "description": "Time of the follow-up in the format HH:MM, default 08:00."
                                    },
                                    "log_call": {
                                        "type": "boolean",
                                        "description": "Whether an entry in the call history is created as well. Default is true; false suits a skipped lead that never counted as a call."
                                    }
                                },
                                "required": [
                                    "status"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/leads/{uuid}/lock": {
            "post": {
                "operationId": "flowcall-leads-lock",
                "summary": "Lock a lead for yourself",
                "description": "Takes the lead for your own work, so two people don't call it at the same time. A lead someone is already working on answers with HTTP 409 instead of being taken over silently. Requires projekt_telefonie.",
                "tags": [
                    "leads"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                        "locked": true,
                                        "locked_until": "2026-09-20T10:45:00+02:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "flowcall-leads-unlock",
                "summary": "Release a lead",
                "description": "Returns the lead to the shared list. Requires projekt_telefonie.",
                "tags": [
                    "leads"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "message": "Sperre aufgehoben."
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/leads/{uuid}/comments": {
            "get": {
                "operationId": "flowcall-comments-index",
                "summary": "List a lead's comments",
                "description": "The comments of a lead, newest first. Requires projekt_telefonie.",
                "tags": [
                    "comments"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Entries per page, 1 to 200, default 25.",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number, default 1.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "a1d7b309-64ce-4f28-8b05-9c3e7f0a2d54",
                                            "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                            "agent_uuid": "3f8b1c6e-2d44-4a9b-8e77-5c1a0b9d3e22",
                                            "agent_name": "Anna Berger",
                                            "text": "Ruft nächste Woche zurück.",
                                            "system": false,
                                            "created_at": "2026-09-19T16:42:00+02:00",
                                            "updated_at": "2026-09-19T16:42:00+02:00"
                                        }
                                    ],
                                    "meta": {
                                        "current_page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "flowcall-comments-store",
                "summary": "Write a comment",
                "description": "Records a note on the lead and answers with HTTP 201. Requires projekt_telefonie.",
                "tags": [
                    "comments"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "a1d7b309-64ce-4f28-8b05-9c3e7f0a2d54",
                                        "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                        "agent_name": "Anna Berger",
                                        "text": "Ruft nächste Woche zurück.",
                                        "system": false,
                                        "created_at": "2026-09-19T16:42:00+02:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "text": {
                                        "type": "string",
                                        "description": "The text, at most 60000 characters."
                                    }
                                },
                                "required": [
                                    "text"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/leads/{uuid}/comments/{commentUuid}": {
            "put": {
                "operationId": "flowcall-comments-update",
                "summary": "Update a comment",
                "description": "Rewrites a comment. Only the person who wrote it may do so; anyone else gets HTTP 403. Requires projekt_telefonie.",
                "tags": [
                    "comments"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "commentUuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "a1d7b309-64ce-4f28-8b05-9c3e7f0a2d54",
                                        "text": "Ruft übernächste Woche zurück.",
                                        "system": false,
                                        "updated_at": "2026-09-20T09:00:00+02:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "text": {
                                        "type": "string",
                                        "description": "The new text, at most 60000 characters."
                                    }
                                },
                                "required": [
                                    "text"
                                ]
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "flowcall-comments-destroy",
                "summary": "Delete a comment",
                "description": "Removes a comment. Only the person who wrote it may do so; anyone else gets HTTP 403. Requires projekt_telefonie.",
                "tags": [
                    "comments"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "commentUuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "message": "Kommentar gelöscht."
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/leads/{uuid}/follow-ups": {
            "get": {
                "operationId": "flowcall-follow-ups-index",
                "summary": "List a lead's follow-ups",
                "description": "The lead's follow-up, ordered by date and time. Since a lead has at most one, the list is empty or has one element. Requires projekt_telefonie.",
                "tags": [
                    "follow-ups"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "5e8c0b43-2fa7-4916-8d3c-1b6a9e4f7c20",
                                            "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                            "agent_uuid": "3f8b1c6e-2d44-4a9b-8e77-5c1a0b9d3e22",
                                            "agent_name": "Anna Berger",
                                            "date": "2026-09-25",
                                            "time": "09:30",
                                            "created_at": "2026-09-19T16:42:00+02:00",
                                            "updated_at": "2026-09-19T16:42:00+02:00"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "flowcall-follow-ups-store",
                "summary": "Set a follow-up",
                "description": "Puts the lead back on the list for a given day and answers with HTTP 201. An existing follow-up is replaced. Requires projekt_telefonie.",
                "tags": [
                    "follow-ups"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "5e8c0b43-2fa7-4916-8d3c-1b6a9e4f7c20",
                                        "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                        "agent_name": "Anna Berger",
                                        "date": "2026-09-25",
                                        "time": "09:30"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "date": {
                                        "type": "string",
                                        "description": "Date in the format YYYY-MM-DD."
                                    },
                                    "time": {
                                        "type": "string",
                                        "description": "Time in the format HH:MM, default 08:00."
                                    }
                                },
                                "required": [
                                    "date"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/leads/{uuid}/follow-ups/{followUpUuid}": {
            "put": {
                "operationId": "flowcall-follow-ups-update",
                "summary": "Move a follow-up",
                "description": "Moves an existing follow-up. Date and time can be changed separately. Requires projekt_telefonie.",
                "tags": [
                    "follow-ups"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "followUpUuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "5e8c0b43-2fa7-4916-8d3c-1b6a9e4f7c20",
                                        "date": "2026-09-28",
                                        "time": "14:00",
                                        "updated_at": "2026-09-20T09:05:00+02:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "date": {
                                        "type": "string",
                                        "description": "New date in the format YYYY-MM-DD."
                                    },
                                    "time": {
                                        "type": "string",
                                        "description": "New time in the format HH:MM."
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "flowcall-follow-ups-destroy",
                "summary": "Delete a follow-up",
                "description": "Removes the follow-up without writing a call outcome. Requires projekt_telefonie.",
                "tags": [
                    "follow-ups"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "followUpUuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "message": "Wiedervorlage gelöscht."
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/leads/{uuid}/calls": {
            "get": {
                "operationId": "flowcall-calls-index",
                "summary": "Get a lead's call history",
                "description": "The entries of the call history, newest first. Requires projekt_telefonie.",
                "tags": [
                    "calls"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Entries per page, 1 to 200, default 25.",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number, default 1.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "0c95e2a7-48b3-4d61-90fa-7e2c5b8d1436",
                                            "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                            "agent_uuid": "3f8b1c6e-2d44-4a9b-8e77-5c1a0b9d3e22",
                                            "agent_name": "Anna Berger",
                                            "status": "Keinen erreicht",
                                            "created_at": "2026-09-18T09:15:00+02:00"
                                        }
                                    ],
                                    "meta": {
                                        "current_page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "flowcall-calls-store",
                "summary": "Log a call afterwards",
                "description": "Logs a call that took place elsewhere and answers with HTTP 201. Only the history entry is written; the lead's current call outcome stays where it is. Requires projekt_telefonie.",
                "tags": [
                    "calls"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "0c95e2a7-48b3-4d61-90fa-7e2c5b8d1436",
                                        "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                        "agent_name": "Anna Berger",
                                        "status": "Keinen erreicht",
                                        "created_at": "2026-09-20T11:00:00+02:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "status": {
                                        "type": "string",
                                        "description": "The outcome of this call, at most 255 characters. Usual values are the same nine terms as for the call outcome; the field is free text."
                                    }
                                },
                                "required": [
                                    "status"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/leads/{uuid}/emails": {
            "get": {
                "operationId": "flowcall-emails-index",
                "summary": "List a lead's emails",
                "description": "The emails written to the lead, newest first. The timestamps for delivery, open, click and bounce are filled in later by the sending service; until then they stay empty. Requires projekt_telefonie.",
                "tags": [
                    "emails"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Entries per page, 1 to 200, default 25.",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number, default 1.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "7b1e0d46-93ac-4f27-8051-4d6a2c9f5e83",
                                            "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                            "status": "ausstehend",
                                            "address": "info@example.com",
                                            "subject": "Unser Gespräch",
                                            "body": "Guten Tag, wie besprochen ...",
                                            "attachment": null,
                                            "delivered_at": null,
                                            "opened_at": null,
                                            "clicked_at": null,
                                            "bounced_at": null,
                                            "created_at": "2026-09-19T16:45:00+02:00"
                                        }
                                    ],
                                    "meta": {
                                        "current_page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "flowcall-emails-store",
                "summary": "Queue an email to the lead",
                "description": "Queues an email from the project template and answers with HTTP 202. If a follow-up date is passed, the lead comes back on the list on that day; without a date, the open follow-up is closed. Requires projekt_telefonie.",
                "tags": [
                    "emails"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "7b1e0d46-93ac-4f27-8051-4d6a2c9f5e83",
                                        "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                        "status": "ausstehend",
                                        "address": "info@example.com",
                                        "subject": "Unser Gespräch",
                                        "delivered_at": null,
                                        "created_at": "2026-09-20T11:30:00+02:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "address": {
                                        "type": "string",
                                        "description": "Recipient address, at most 255 characters."
                                    },
                                    "subject": {
                                        "type": "string",
                                        "description": "Subject, at most 255 characters. Without a value, the project template applies."
                                    },
                                    "body": {
                                        "type": "string",
                                        "description": "Text, at most 200000 characters. Without a value, the project template applies."
                                    },
                                    "skip_verification": {
                                        "type": "boolean",
                                        "description": "Marks the address as valid without verification, as the checkbox in the interface does. This is recorded as a comment on the lead."
                                    },
                                    "follow_up_date": {
                                        "type": "string",
                                        "description": "Follow-up in the format YYYY-MM-DD."
                                    },
                                    "follow_up_time": {
                                        "type": "string",
                                        "description": "Time of the follow-up in the format HH:MM, default 08:00."
                                    }
                                },
                                "required": [
                                    "address"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/roles": {
            "get": {
                "operationId": "flowcall-roles-index",
                "summary": "List roles",
                "description": "All FlowCall roles of the team with their ten permissions, in alphabetical order. Requires team_rollen_verwalten.",
                "tags": [
                    "team"
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "9c40b7e2-1a58-4d63-b07f-8e5c2a1d9f34",
                                            "name": "agent",
                                            "flags": {
                                                "team_verwalten": false,
                                                "team_rollen_verwalten": false,
                                                "callhistory_all": false,
                                                "projekte_verwalten": false,
                                                "projekt_bearbeiten": false,
                                                "projekt_alle_leads": false,
                                                "projekt_leads_export": false,
                                                "projekt_telefonie": true,
                                                "projekt_lead_hinzufuegen": true,
                                                "projekt_unstimmigkeiten": false
                                            },
                                            "created_at": "2026-08-12T10:00:00+02:00",
                                            "updated_at": "2026-08-12T10:00:00+02:00"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "flowcall-roles-store",
                "summary": "Create a role",
                "description": "Creates a role and answers with HTTP 201. The name is stored in lower case and must be unique within the team; a name already in use answers with HTTP 422 and the error already_exists. Permissions that are not named are set to denied. Requires team_rollen_verwalten.",
                "tags": [
                    "team"
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "9c40b7e2-1a58-4d63-b07f-8e5c2a1d9f34",
                                        "name": "agent",
                                        "flags": {
                                            "team_verwalten": false,
                                            "team_rollen_verwalten": false,
                                            "callhistory_all": false,
                                            "projekte_verwalten": false,
                                            "projekt_bearbeiten": false,
                                            "projekt_alle_leads": false,
                                            "projekt_leads_export": false,
                                            "projekt_telefonie": true,
                                            "projekt_lead_hinzufuegen": true,
                                            "projekt_unstimmigkeiten": false
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "description": "The name of the role, at most 255 characters. It is stored in lower case."
                                    },
                                    "flags": {
                                        "type": "object",
                                        "description": "The permissions as booleans, named after the ten names from the overview. An unknown name is rejected instead of being silently skipped."
                                    }
                                },
                                "required": [
                                    "name"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/roles/{uuid}": {
            "put": {
                "operationId": "flowcall-roles-update",
                "summary": "Update a role",
                "description": "Changes name and permissions. A permission that is not named stays unchanged. A rename carries the new name into the assignments and project permissions in the same step. A name already in use answers with HTTP 422 and the error already_exists. Requires team_rollen_verwalten.",
                "tags": [
                    "team"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "9c40b7e2-1a58-4d63-b07f-8e5c2a1d9f34",
                                        "name": "agent senior",
                                        "flags": {
                                            "projekt_telefonie": true,
                                            "projekt_alle_leads": true,
                                            "projekt_leads_export": true
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "description": "The new name, at most 255 characters. It is stored in lower case."
                                    },
                                    "flags": {
                                        "type": "object",
                                        "description": "The permissions to change, as booleans. Permissions that are not named stay as they are."
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "flowcall-roles-destroy",
                "summary": "Delete a role",
                "description": "Deletes a role that nobody holds any more. If someone still holds it, the call answers with HTTP 409 and the error role_in_use. Requires team_rollen_verwalten.",
                "tags": [
                    "team"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "message": "Rolle gelöscht."
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/members": {
            "get": {
                "operationId": "flowcall-members-index",
                "summary": "List team members",
                "description": "All members of the FlowCall team with the role they hold. The entry's UUID identifies the membership, user_uuid the person. Requires team_verwalten.",
                "tags": [
                    "team"
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "c8f52e07-4b1a-4936-80d7-2e6c9a3f5b18",
                                            "user_uuid": "3f8b1c6e-2d44-4a9b-8e77-5c1a0b9d3e22",
                                            "name": "Anna Berger",
                                            "email": "anna@example.com",
                                            "role": "agent",
                                            "created_at": "2026-08-12T10:05:00+02:00"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/members/{userUuid}/role": {
            "put": {
                "operationId": "flowcall-members-role",
                "summary": "Give a member a role",
                "description": "Assigns a FlowCall role to a team member. The role is named by its UUID, so a rename is not mistaken for a new assignment. The assignment takes effect immediately in all of this person's project permissions. A person outside the team answers with HTTP 404. Requires team_verwalten.",
                "tags": [
                    "team"
                ],
                "parameters": [
                    {
                        "name": "userUuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "c8f52e07-4b1a-4936-80d7-2e6c9a3f5b18",
                                        "user_uuid": "3f8b1c6e-2d44-4a9b-8e77-5c1a0b9d3e22",
                                        "name": "Anna Berger",
                                        "email": "anna@example.com",
                                        "role": "agent senior"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "role_uuid": {
                                        "type": "string",
                                        "description": "UUID of the FlowCall role."
                                    }
                                },
                                "required": [
                                    "role_uuid"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/call-history": {
            "get": {
                "operationId": "flowcall-call-history",
                "summary": "Get the call log",
                "description": "The calls from the connected phone system, newest first. With callhistory_all the list covers the whole team, otherwise only your own calls. If a row is matched to a lead, it carries that lead's UUID.",
                "tags": [
                    "call-history"
                ],
                "parameters": [
                    {
                        "name": "direction",
                        "in": "query",
                        "required": false,
                        "description": "Direction of the call as the phone system reports it, for example inbound or outbound.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "since",
                        "in": "query",
                        "required": false,
                        "description": "Only calls from this point on, as a date or timestamp.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Entries per page, 1 to 200, default 25.",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number, default 1.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "direction": "outbound",
                                            "status": "answered",
                                            "from_number": "+4922112345",
                                            "to_number": "+492211234567",
                                            "start_time": "2026-09-18 09:15:02",
                                            "answered_time": "2026-09-18 09:15:11",
                                            "end_time": "2026-09-18 09:18:40",
                                            "duration": 209,
                                            "comment": null,
                                            "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52"
                                        }
                                    ],
                                    "meta": {
                                        "current_page": 1,
                                        "per_page": 25,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/reports/leads": {
            "get": {
                "operationId": "flowcall-reports-leads",
                "summary": "Lead stock",
                "description": "The state of the leads in the reachable projects: the total, how many are currently being worked on, how many nobody has touched yet and the distribution across call outcomes.",
                "tags": [
                    "reports"
                ],
                "parameters": [
                    {
                        "name": "project_uuid",
                        "in": "query",
                        "required": false,
                        "description": "Limit to one call project.",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "total": 1240,
                                        "locked": 3,
                                        "untouched": 480,
                                        "by_status": {
                                            "Offen": 120,
                                            "Keinen erreicht": 310,
                                            "Kein Interesse": 190,
                                            "Wiedervorlage": 78,
                                            "Termin vereinbart": 62
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/reports/calls": {
            "get": {
                "operationId": "flowcall-reports-calls",
                "summary": "Call volume",
                "description": "How much was called, by whom and with which outcome. The window is counted back in days and is at most one year, because the report works on the full call history.",
                "tags": [
                    "reports"
                ],
                "parameters": [
                    {
                        "name": "project_uuid",
                        "in": "query",
                        "required": false,
                        "description": "Limit to one call project.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "days",
                        "in": "query",
                        "required": false,
                        "description": "Time window in days, 1 to 365, default 14.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "window_days": 14,
                                        "total": 842,
                                        "mine": 214,
                                        "by_agent": [
                                            {
                                                "user_uuid": "3f8b1c6e-2d44-4a9b-8e77-5c1a0b9d3e22",
                                                "calls": 214
                                            }
                                        ],
                                        "by_status": {
                                            "Keinen erreicht": 401,
                                            "Kein Interesse": 233,
                                            "Termin vereinbart": 38
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcall/reports/follow-ups": {
            "get": {
                "operationId": "flowcall-reports-follow-ups",
                "summary": "Follow-ups",
                "description": "What is overdue, what is due today and what comes next. The preview covers the next twenty follow-ups.",
                "tags": [
                    "reports"
                ],
                "parameters": [
                    {
                        "name": "project_uuid",
                        "in": "query",
                        "required": false,
                        "description": "Limit to one call project.",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "overdue": 12,
                                        "today": 7,
                                        "mine": 5,
                                        "next": [
                                            {
                                                "uuid": "5e8c0b43-2fa7-4916-8d3c-1b6a9e4f7c20",
                                                "lead_uuid": "f37a2d08-5b14-4e9c-8207-6d0a1f8c3b52",
                                                "agent_uuid": "3f8b1c6e-2d44-4a9b-8e77-5c1a0b9d3e22",
                                                "agent_name": "Anna Berger",
                                                "date": "2026-09-25",
                                                "time": "09:30"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Error response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "API key (pk_… or at_…) as Authorization: Bearer <key>. Any other way of sending it is rejected with 401."
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "properties": {
                    "success": {
                        "type": "boolean"
                    },
                    "error": {
                        "type": "string"
                    },
                    "message": {
                        "type": "string"
                    },
                    "errors": {
                        "type": "object"
                    }
                }
            }
        }
    }
}