{
    "openapi": "3.1.0",
    "info": {
        "title": "Team Management API",
        "version": "v1",
        "description": "Lesende REST API für das eigene Team: Stammdaten und Paket, Mitglieder mit Rolle und Modulrechten, der Modulkatalog, offene Einladungen und die Sitzplätze."
    },
    "servers": [
        {
            "url": "https://api.flowsuite.one",
            "description": "FlowSuite API"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "team",
            "description": "Team und Module"
        },
        {
            "name": "members",
            "description": "Mitglieder"
        },
        {
            "name": "invitations",
            "description": "Einladungen und Sitzplätze"
        }
    ],
    "paths": {
        "/team": {
            "get": {
                "operationId": "team-show",
                "summary": "Eigenes Team abrufen",
                "description": "Liefert UUID und Name des Teams, die UUID der Inhaberin oder des Inhabers, das wirksame Paket, den Zustand der Testphase und die Kurzkennungen der aktiven Module. Während einer laufenden Testphase ist das genannte Paket das Leistungspaket der Testphase, nicht das gebuchte; der Block trial weist das aus.",
                "tags": [
                    "team"
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "9d2f4c1a-7b3e-4f8a-9c5d-1e6a8b0c2d4f",
                                        "name": "Musterfirma GmbH",
                                        "owner_uuid": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
                                        "package": {
                                            "key": "flow_suite_pro",
                                            "name": "FlowSuite Pro"
                                        },
                                        "trial": {
                                            "active": false,
                                            "ends_at": "2026-08-01T00:00:00+02:00",
                                            "days_remaining": 0,
                                            "package_key": null
                                        },
                                        "active_modules": [
                                            "ai",
                                            "cc",
                                            "tt",
                                            "cm",
                                            "td",
                                            "fs",
                                            "sa",
                                            "fa",
                                            "fe",
                                            "fd",
                                            "flowsupport"
                                        ],
                                        "created_at": "2025-11-02T09:14:00+01:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/team/modules": {
            "get": {
                "operationId": "team-modules",
                "summary": "Modulkatalog mit eigenen Rechten abrufen",
                "description": "Liefert jedes Modul mit Kurzkennung, langer Kennung und Anzeigenamen, dazu ob das Paket es enthält, ob das Team es eingeschaltet hat, ob es damit nutzbar ist, und ob der aufrufende Schlüssel selbst darauf zugreifen darf. own_sub_access nennt die eigenen Unterzugriffe des Moduls. Bei Modulen außerhalb der Pakete, etwa Hosting oder Teamverwaltung, ist package_granted null.",
                "tags": [
                    "team"
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "field": "cm",
                                            "key": "flowcrm",
                                            "label": "FlowCRM",
                                            "group": "flow_suite",
                                            "availability": "package",
                                            "package_granted": true,
                                            "team_active": true,
                                            "available": true,
                                            "own_access": true,
                                            "own_sub_access": [
                                                "kunden",
                                                "projekte"
                                            ]
                                        },
                                        {
                                            "field": "tm",
                                            "key": null,
                                            "label": "Teamverwaltung",
                                            "group": "additional",
                                            "availability": "always",
                                            "package_granted": null,
                                            "team_active": true,
                                            "available": true,
                                            "own_access": false,
                                            "own_sub_access": []
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/team/members": {
            "get": {
                "operationId": "team-members-index",
                "summary": "Mitglieder auflisten",
                "description": "Liefert die Mitglieder des eigenen Teams mit UUID, Name, E-Mail-Adresse, abgeleiteter Rolle, freier Bezeichnung, den Modulrechten als Wahrheitswerte je Kurzkennung, den gespeicherten Unterzugriffen je Modul und den Vollzugriffsbereichen. Die Modulrechte berücksichtigen, dass die Inhaberin oder der Inhaber jedes angebotene Modul hält, auch ohne gesetztes Kennzeichen.",
                "tags": [
                    "members"
                ],
                "parameters": [
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Einträge pro Seite, 1 bis 200, Standard 50.",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Seitenzahl, Standard 1.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
                                            "name": "Anna Beispiel",
                                            "email": "anna@example.com",
                                            "role": "manager",
                                            "role_label": "Buchhaltung",
                                            "modules": {
                                                "tt": true,
                                                "cm": true,
                                                "fa": false,
                                                "tm": true
                                            },
                                            "sub_access": {
                                                "flowcrm": [
                                                    "kunden",
                                                    "projekte"
                                                ]
                                            },
                                            "full_access_scopes": [],
                                            "joined_at": "2025-11-02T09:14:00+01:00"
                                        }
                                    ],
                                    "meta": {
                                        "current_page": 1,
                                        "per_page": 50,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/team/members/{userUuid}": {
            "get": {
                "operationId": "team-members-show",
                "summary": "Einzelnes Mitglied abrufen",
                "description": "Liefert ein einzelnes Mitglied in derselben Form wie die Liste. Angesprochen wird die UUID der Person. Eine UUID, die zu niemandem gehört, und eine aus einem fremden Team antworten beide mit HTTP 404.",
                "tags": [
                    "members"
                ],
                "parameters": [
                    {
                        "name": "userUuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "uuid": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
                                        "name": "Anna Beispiel",
                                        "email": "anna@example.com",
                                        "role": "member",
                                        "role_label": null,
                                        "modules": {
                                            "tt": true,
                                            "cm": true
                                        },
                                        "sub_access": {
                                            "flowtime": [
                                                "berichte"
                                            ]
                                        },
                                        "full_access_scopes": [],
                                        "joined_at": "2025-11-02T09:14:00+01:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/team/invitations": {
            "get": {
                "operationId": "team-invitations",
                "summary": "Offene Einladungen auflisten",
                "description": "Liefert die Einladungen, die eine Adresse noch an dieses Team binden, mit UUID, Adresse, freier Bezeichnung, Zustand, Ablaufzeitpunkt und Anlagezeitpunkt. Abgelaufene und bereits angenommene Einladungen erscheinen nicht.",
                "tags": [
                    "invitations"
                ],
                "parameters": [
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Einträge pro Seite, 1 bis 200, Standard 50.",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Seitenzahl, Standard 1.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": [
                                        {
                                            "uuid": "7f8e9d0c-1b2a-4c3d-8e5f-6a7b8c9d0e1f",
                                            "email": "neu@example.com",
                                            "role": null,
                                            "status": "pending",
                                            "expires_at": "2026-10-05T12:00:00+02:00",
                                            "created_at": "2026-09-21T12:00:00+02:00"
                                        }
                                    ],
                                    "meta": {
                                        "current_page": 1,
                                        "per_page": 50,
                                        "total": 1,
                                        "last_page": 1
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/team/licenses": {
            "get": {
                "operationId": "team-licenses",
                "summary": "Sitzplätze abrufen",
                "description": "Liefert die Sitzplatzlage des Teams: gebuchte Plätze, belegte Plätze, offene Einladungen, ob eine weitere Einladung möglich ist, und bei einem Enterprise-Vertrag dessen Mitgliedergrenze. state ist active_subscription, trialing oder no_subscription. Die Auskunft stammt aus derselben Prüfung, die auch in der Weboberfläche über eine weitere Einladung entscheidet.",
                "tags": [
                    "invitations"
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "success": true,
                                    "data": {
                                        "state": "active_subscription",
                                        "purchased": 5,
                                        "active": 3,
                                        "pending": 1,
                                        "enterprise_max_members": null,
                                        "can_invite": true,
                                        "enterprise_capped": false,
                                        "billing_cycle": "monthly",
                                        "current_period_end": "2026-10-21T00:00:00+02:00",
                                        "trial_ends_at": "2026-08-01T00:00:00+02:00",
                                        "trial_days_remaining": 0
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "API-Schlüssel (pk_… oder at_…) als Authorization: Bearer <Schlüssel>. Andere Übergabewege werden mit 401 abgelehnt."
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "properties": {
                    "success": {
                        "type": "boolean"
                    },
                    "error": {
                        "type": "string"
                    },
                    "message": {
                        "type": "string"
                    },
                    "errors": {
                        "type": "object"
                    }
                }
            }
        }
    }
}