{
    "openapi": "3.0.3",
    "info": {
        "title": "CRM API · web-wiiser",
        "version": "1.0",
        "description": "REST-API von CRM. Schlüssel im web-wiiser-Kundenbereich unter Software. Webhooks: Ereignisse crm.<objekt>.created|updated|deleted, Signatur X-WW-Signature: t=<unix>,v1=HMAC-SHA256(geheimnis, \"<t>.<körper>\")."
    },
    "servers": [
        {
            "url": "https://crm.saas.web-wiiser.ch"
        }
    ],
    "security": [
        {
            "bearer": []
        }
    ],
    "components": {
        "securitySchemes": {
            "bearer": {
                "type": "http",
                "scheme": "bearer"
            }
        },
        "schemas": {
            "firma": {
                "type": "object",
                "title": "Firma",
                "properties": {
                    "id": {
                        "type": "integer",
                        "readOnly": true
                    },
                    "name": {
                        "type": "string",
                        "title": "Name"
                    },
                    "branche": {
                        "type": "string",
                        "title": "Branche"
                    },
                    "ort": {
                        "type": "string",
                        "title": "Ort"
                    },
                    "website": {
                        "type": "string",
                        "format": "uri",
                        "title": "Website"
                    },
                    "telefon": {
                        "type": "string",
                        "title": "Telefon"
                    },
                    "email": {
                        "type": "string",
                        "format": "email",
                        "title": "E-Mail"
                    },
                    "adresse": {
                        "type": "string",
                        "title": "Adresse"
                    },
                    "notiz": {
                        "type": "string",
                        "title": "Notiz"
                    },
                    "created_at": {
                        "type": "string",
                        "readOnly": true
                    },
                    "updated_at": {
                        "type": "string",
                        "readOnly": true
                    }
                },
                "required": [
                    "name"
                ]
            },
            "kontakt": {
                "type": "object",
                "title": "Kontakt",
                "properties": {
                    "id": {
                        "type": "integer",
                        "readOnly": true
                    },
                    "vorname": {
                        "type": "string",
                        "title": "Vorname"
                    },
                    "nachname": {
                        "type": "string",
                        "title": "Nachname"
                    },
                    "firma": {
                        "type": "integer",
                        "description": "ID: firma",
                        "title": "Firma"
                    },
                    "position": {
                        "type": "string",
                        "title": "Position"
                    },
                    "email": {
                        "type": "string",
                        "format": "email",
                        "title": "E-Mail"
                    },
                    "telefon": {
                        "type": "string",
                        "title": "Telefon"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "Lead",
                            "Interessent",
                            "Kunde",
                            "Inaktiv"
                        ],
                        "title": "Status"
                    },
                    "notiz": {
                        "type": "string",
                        "title": "Notiz"
                    },
                    "created_at": {
                        "type": "string",
                        "readOnly": true
                    },
                    "updated_at": {
                        "type": "string",
                        "readOnly": true
                    }
                },
                "required": [
                    "nachname"
                ]
            },
            "deal": {
                "type": "object",
                "title": "Verkaufschance",
                "properties": {
                    "id": {
                        "type": "integer",
                        "readOnly": true
                    },
                    "titel": {
                        "type": "string",
                        "title": "Titel"
                    },
                    "firma": {
                        "type": "integer",
                        "description": "ID: firma",
                        "title": "Firma"
                    },
                    "kontakt": {
                        "type": "integer",
                        "description": "ID: kontakt",
                        "title": "Kontakt"
                    },
                    "wert": {
                        "type": "number",
                        "title": "Wert (CHF)"
                    },
                    "phase": {
                        "type": "string",
                        "enum": [
                            "Neu",
                            "Qualifiziert",
                            "Angebot",
                            "Verhandlung",
                            "Gewonnen",
                            "Verloren"
                        ],
                        "title": "Phase"
                    },
                    "wahrscheinlichkeit": {
                        "type": "integer",
                        "title": "Wahrscheinlichkeit"
                    },
                    "abschluss": {
                        "type": "string",
                        "format": "date",
                        "title": "Erwarteter Abschluss"
                    },
                    "notiz": {
                        "type": "string",
                        "title": "Notiz"
                    },
                    "created_at": {
                        "type": "string",
                        "readOnly": true
                    },
                    "updated_at": {
                        "type": "string",
                        "readOnly": true
                    }
                },
                "required": [
                    "titel",
                    "phase"
                ]
            },
            "aktivitaet": {
                "type": "object",
                "title": "Aktivität",
                "properties": {
                    "id": {
                        "type": "integer",
                        "readOnly": true
                    },
                    "typ": {
                        "type": "string",
                        "enum": [
                            "Anruf",
                            "E-Mail",
                            "Meeting",
                            "Aufgabe",
                            "Notiz"
                        ],
                        "title": "Typ"
                    },
                    "betreff": {
                        "type": "string",
                        "title": "Betreff"
                    },
                    "faellig": {
                        "type": "string",
                        "example": "2026-01-31 14:00",
                        "title": "Fällig"
                    },
                    "kontakt": {
                        "type": "integer",
                        "description": "ID: kontakt",
                        "title": "Kontakt"
                    },
                    "firma": {
                        "type": "integer",
                        "description": "ID: firma",
                        "title": "Firma"
                    },
                    "deal": {
                        "type": "integer",
                        "description": "ID: deal",
                        "title": "Verkaufschance"
                    },
                    "erledigt": {
                        "type": "integer",
                        "enum": [
                            0,
                            1
                        ],
                        "title": "Erledigt"
                    },
                    "notiz": {
                        "type": "string",
                        "title": "Notiz"
                    },
                    "created_at": {
                        "type": "string",
                        "readOnly": true
                    },
                    "updated_at": {
                        "type": "string",
                        "readOnly": true
                    }
                },
                "required": [
                    "typ",
                    "betreff"
                ]
            }
        }
    },
    "paths": {
        "/api.php?r=firma": {
            "get": {
                "summary": "Firmen auflisten",
                "operationId": "list_firma",
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Volltextsuche"
                    },
                    {
                        "name": "since",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Nur seit diesem Zeitpunkt geänderte (ISO 8601)"
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "maximum": 1000
                        }
                    },
                    {
                        "name": "offset",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "format",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "json",
                                "csv"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "count": {
                                            "type": "integer"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/firma"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "Firma anlegen",
                "operationId": "create_firma",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/firma"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Angelegt",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/firma"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Ungültige Angaben"
                    }
                }
            }
        },
        "/api.php?r=firma/{id}": {
            "get": {
                "summary": "Firma lesen",
                "operationId": "get_firma",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/firma"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Nicht gefunden"
                    }
                }
            },
            "patch": {
                "summary": "Firma ändern (nur übergebene Felder)",
                "operationId": "update_firma",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/firma"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/firma"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "summary": "Firma löschen",
                "operationId": "delete_firma",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Gelöscht"
                    }
                }
            }
        },
        "/api.php?r=kontakt": {
            "get": {
                "summary": "Kontakte auflisten",
                "operationId": "list_kontakt",
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Volltextsuche"
                    },
                    {
                        "name": "since",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Nur seit diesem Zeitpunkt geänderte (ISO 8601)"
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "maximum": 1000
                        }
                    },
                    {
                        "name": "offset",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "format",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "json",
                                "csv"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "count": {
                                            "type": "integer"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/kontakt"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "Kontakt anlegen",
                "operationId": "create_kontakt",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/kontakt"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Angelegt",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/kontakt"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Ungültige Angaben"
                    }
                }
            }
        },
        "/api.php?r=kontakt/{id}": {
            "get": {
                "summary": "Kontakt lesen",
                "operationId": "get_kontakt",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/kontakt"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Nicht gefunden"
                    }
                }
            },
            "patch": {
                "summary": "Kontakt ändern (nur übergebene Felder)",
                "operationId": "update_kontakt",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/kontakt"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/kontakt"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "summary": "Kontakt löschen",
                "operationId": "delete_kontakt",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Gelöscht"
                    }
                }
            }
        },
        "/api.php?r=deal": {
            "get": {
                "summary": "Verkaufschancen auflisten",
                "operationId": "list_deal",
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Volltextsuche"
                    },
                    {
                        "name": "since",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Nur seit diesem Zeitpunkt geänderte (ISO 8601)"
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "maximum": 1000
                        }
                    },
                    {
                        "name": "offset",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "format",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "json",
                                "csv"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "count": {
                                            "type": "integer"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/deal"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "Verkaufschance anlegen",
                "operationId": "create_deal",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/deal"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Angelegt",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/deal"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Ungültige Angaben"
                    }
                }
            }
        },
        "/api.php?r=deal/{id}": {
            "get": {
                "summary": "Verkaufschance lesen",
                "operationId": "get_deal",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/deal"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Nicht gefunden"
                    }
                }
            },
            "patch": {
                "summary": "Verkaufschance ändern (nur übergebene Felder)",
                "operationId": "update_deal",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/deal"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/deal"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "summary": "Verkaufschance löschen",
                "operationId": "delete_deal",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Gelöscht"
                    }
                }
            }
        },
        "/api.php?r=aktivitaet": {
            "get": {
                "summary": "Aktivitäten auflisten",
                "operationId": "list_aktivitaet",
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Volltextsuche"
                    },
                    {
                        "name": "since",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Nur seit diesem Zeitpunkt geänderte (ISO 8601)"
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "maximum": 1000
                        }
                    },
                    {
                        "name": "offset",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "format",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "json",
                                "csv"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "count": {
                                            "type": "integer"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/aktivitaet"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "Aktivität anlegen",
                "operationId": "create_aktivitaet",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/aktivitaet"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Angelegt",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/aktivitaet"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Ungültige Angaben"
                    }
                }
            }
        },
        "/api.php?r=aktivitaet/{id}": {
            "get": {
                "summary": "Aktivität lesen",
                "operationId": "get_aktivitaet",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/aktivitaet"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Nicht gefunden"
                    }
                }
            },
            "patch": {
                "summary": "Aktivität ändern (nur übergebene Felder)",
                "operationId": "update_aktivitaet",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/aktivitaet"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/aktivitaet"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "summary": "Aktivität löschen",
                "operationId": "delete_aktivitaet",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Gelöscht"
                    }
                }
            }
        }
    }
}