{
    "openapi": "3.1.0",
    "info": {
        "title": "FlowContacts API",
        "version": "v1",
        "description": "REST API zur Verwaltung von privaten Kontakten, Timeline-Einträgen und persönlichen Details. Für Integrationen, Daten-Synchronisation und individuelle Beziehungs-Management-Tools."
    },
    "servers": [
        {
            "url": "https://api.flowsuite.one",
            "description": "FlowSuite API"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "endpoints",
            "description": "API-Referenz"
        }
    ],
    "paths": {
        "/flowcontacts/contacts": {
            "get": {
                "operationId": "contacts-list",
                "summary": "Kontakte auflisten",
                "description": "Ruft eine Liste Ihrer persönlichen Kontakte ab. Die Antwort enthält alle verknüpften Daten wie E-Mails, Telefonnummern und Adressen.",
                "tags": [
                    "endpoints"
                ],
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "required": false,
                        "description": "Filter nach Status: active, archived, all",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "required": false,
                        "description": "Suchbegriff (Name, Firma, Job, E-Mail)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Anzahl der Ergebnisse (max 200)",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "uuid": "123e4567-e89b-12d3-a456-426614174000",
                                            "id": 1042,
                                            "first_name": "Max",
                                            "last_name": "Mustermann",
                                            "company": "Firma GmbH",
                                            "job_title": null,
                                            "notes": null,
                                            "birthday": null,
                                            "avatar_url": null,
                                            "avatar_sha1": null,
                                            "is_shared": false,
                                            "is_own": true,
                                            "status": "active",
                                            "emails": [
                                                {
                                                    "label": "Privat",
                                                    "address": "max@example.com",
                                                    "is_primary": true
                                                }
                                            ],
                                            "phones": [],
                                            "addresses": [],
                                            "created_at": "2026-07-21T10:00:00+00:00",
                                            "updated_at": "2026-07-21T10:00:00+00:00"
                                        }
                                    ],
                                    "meta": {
                                        "current_page": 1,
                                        "per_page": 15,
                                        "total": 42
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "contact-create",
                "summary": "Kontakt erstellen",
                "description": "Erstellt einen neuen privaten Kontakt. Breaking Change: Die frühere Upsert-Semantik über eine uuid im Body existiert nicht mehr; Aktualisierungen laufen über PUT /flowcontacts/contacts/{uuid}.",
                "tags": [
                    "endpoints"
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "uuid": "223e4567-e89b-12d3-a456-426614174111",
                                        "id": 1043,
                                        "first_name": "Erika",
                                        "last_name": "Mustermann",
                                        "company": null,
                                        "job_title": "Designerin",
                                        "notes": null,
                                        "birthday": null,
                                        "avatar_url": null,
                                        "avatar_sha1": null,
                                        "is_shared": false,
                                        "is_own": true,
                                        "status": "active",
                                        "emails": [
                                            {
                                                "label": "Geschäftlich",
                                                "address": "erika@muster.de",
                                                "is_primary": true
                                            }
                                        ],
                                        "phones": [],
                                        "addresses": [],
                                        "created_at": "2026-07-21T10:00:00+00:00",
                                        "updated_at": "2026-07-21T10:00:00+00:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "first_name": {
                                        "type": "string",
                                        "description": "Vorname"
                                    },
                                    "last_name": {
                                        "type": "string",
                                        "description": "Nachname"
                                    },
                                    "company": {
                                        "type": "string",
                                        "description": "Firma"
                                    },
                                    "job_title": {
                                        "type": "string",
                                        "description": "Berufsbezeichnung"
                                    },
                                    "email_addresses": {
                                        "type": "array",
                                        "items": [],
                                        "description": "Array aus E-Mail-Objekten mit label, address und is_primary"
                                    },
                                    "phone_numbers": {
                                        "type": "array",
                                        "items": [],
                                        "description": "Array aus Telefon-Objekten mit label, number und is_primary"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcontacts/contacts/{uuid}": {
            "get": {
                "operationId": "contact-detail",
                "summary": "Kontakt-Details abrufen",
                "description": "Ruft die vollständigen Details eines einzelnen Kontakts ab, inklusive E-Mails, Telefonnummern und Adressen. Empfohlener Weg ist die Adressierung per UUID. Übergangsweise wird zusätzlich die numerische ID akzeptiert (/flowcontacts/contacts/123) &ndash; dieser Weg ist veraltet und läuft aus, sobald die FlowContacts-App vollständig auf UUIDs umgestellt ist. Neue Integrationen dürfen ausschließlich UUIDs verwenden. Die Antwort enthält neben uuid übergangsweise wieder das Feld id; Unterobjekte (E-Mails, Telefonnummern, Adressen) tragen weiterhin keine IDs.",
                "tags": [
                    "endpoints"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "uuid": "123e4567-e89b-12d3-a456-426614174000",
                                        "id": 1042,
                                        "first_name": "Max",
                                        "last_name": "Mustermann",
                                        "company": "Firma GmbH",
                                        "job_title": null,
                                        "notes": null,
                                        "birthday": null,
                                        "avatar_url": null,
                                        "avatar_sha1": null,
                                        "is_shared": false,
                                        "is_own": true,
                                        "status": "active",
                                        "emails": [
                                            {
                                                "label": "Privat",
                                                "address": "max@example.com",
                                                "is_primary": true
                                            }
                                        ],
                                        "phones": [],
                                        "addresses": [],
                                        "created_at": "2026-07-21T10:00:00+00:00",
                                        "updated_at": "2026-07-21T10:00:00+00:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "operationId": "contact-update",
                "summary": "Kontakt aktualisieren",
                "description": "Aktualisiert einen bestehenden Kontakt per UUID (Teil-Update: nur gesendete Felder werden geschrieben). Übergangsweise wird auch die numerische ID im Pfad akzeptiert; dieser Weg ist veraltet und läuft aus. Ein unbekannter oder fremder Pfadwert ergibt in beiden Formen HTTP 404.",
                "tags": [
                    "endpoints"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "uuid": "223e4567-e89b-12d3-a456-426614174111",
                                        "id": 1043,
                                        "first_name": "Erika",
                                        "last_name": "Mustermann",
                                        "company": "Muster Design",
                                        "job_title": "Designerin",
                                        "notes": null,
                                        "birthday": null,
                                        "avatar_url": null,
                                        "avatar_sha1": null,
                                        "is_shared": false,
                                        "is_own": true,
                                        "status": "active",
                                        "emails": [
                                            {
                                                "label": "Geschäftlich",
                                                "address": "erika@muster.de",
                                                "is_primary": true
                                            }
                                        ],
                                        "phones": [],
                                        "addresses": [],
                                        "created_at": "2026-07-21T10:00:00+00:00",
                                        "updated_at": "2026-07-21T11:00:00+00:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "first_name": {
                                        "type": "string",
                                        "description": "Vorname"
                                    },
                                    "last_name": {
                                        "type": "string",
                                        "description": "Nachname"
                                    },
                                    "company": {
                                        "type": "string",
                                        "description": "Firma"
                                    },
                                    "job_title": {
                                        "type": "string",
                                        "description": "Berufsbezeichnung"
                                    },
                                    "email_addresses": {
                                        "type": "array",
                                        "items": [],
                                        "description": "Array aus E-Mail-Objekten mit label, address und is_primary"
                                    },
                                    "phone_numbers": {
                                        "type": "array",
                                        "items": [],
                                        "description": "Array aus Telefon-Objekten mit label, number und is_primary"
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "contact-delete",
                "summary": "Kontakt löschen",
                "description": "Löscht einen Kontakt per UUID (Soft-Delete). Übergangsweise wird auch die numerische ID im Pfad akzeptiert; dieser Weg ist veraltet und läuft aus. Ein unbekannter oder fremder Pfadwert ergibt in beiden Formen HTTP 404.",
                "tags": [
                    "endpoints"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flowcontacts/contacts/{uuid}/avatar": {
            "post": {
                "operationId": "contact-avatar-upload",
                "summary": "Profilbild hochladen",
                "description": "Lädt das Profilbild eines Kontakts als multipart/form-data hoch und ersetzt ein vorhandenes Bild. Das Bild wird serverseitig auf 500&times;500 Pixel zugeschnitten und als JPEG gespeichert, ein zuvor hinterlegtes Bild wird entfernt. Erlaubt sind JPEG, PNG und WebP bis 8&nbsp;MB. HEIC und HEIF werden nicht unterstützt &ndash; iOS-Clients konvertieren vor dem Upload nach JPEG. Profilbilder sind bewusst nicht Teil des Sync-Push-Protokolls; Änderungen erkennen Clients über avatar_sha1 im Sync-Pull.",
                "tags": [
                    "endpoints"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": {
                                        "avatar_url": "https://api.flowsuite.one/flowcontacts/contacts/123e4567-e89b-12d3-a456-426614174000/avatar",
                                        "avatar_sha1": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
                                        "avatar_updated_at": "2026-08-16T10:00:00+00:00"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "avatar": {
                                        "type": "string",
                                        "format": "binary",
                                        "description": "Bilddatei als multipart/form-data-Feld (JPEG, PNG oder WebP, max. 8 MB)"
                                    }
                                },
                                "required": [
                                    "avatar"
                                ]
                            }
                        }
                    }
                }
            },
            "get": {
                "operationId": "contact-avatar-download",
                "summary": "Profilbild abrufen",
                "description": "Liefert die Bilddaten des Profilbilds, in der Regel als image/jpeg. Die Antwort trägt einen ETag mit dem SHA-1 der Bytes; ein Aufruf mit If-None-Match wird mit 304 Not Modified ohne Inhalt beantwortet. Externe Profilbilder, etwa aus Google Kontakte, werden per 302 auf ihre Original-URL weitergeleitet. Ohne hinterlegtes Bild antwortet der Endpunkt mit 404. Wichtig: die URL ist wie jeder andere Endpunkt tokengeschützt &ndash; sie muss mit dem Authorization-Header abgerufen werden und funktioniert nicht in einem einfachen Bild-Tag.",
                "tags": [
                    "endpoints"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/octet-stream": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Fehlerantwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "contact-avatar-delete",
                "summary": "Profilbild löschen",
                "description": "Entfernt das Profilbild des Kontakts samt gespeicherter Datei. Der Aufruf ist idempotent: auch ohne hinterlegtes Bild antwortet der Server mit 204 No Content.",
                "tags": [
                    "endpoints"
                ],
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Erfolgreiche Antwort",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "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"
                    }
                }
            }
        }
    }
}