{
  "openapi": "3.2.0",
  "info": {
    "title": "ApelCuAi REST API v1",
    "description": "The REST API an organization's own systems call (calls, customers, agent, guided menus, webhook test). Create a key in the dashboard (Chei API) and send it as `Authorization: Bearer acai_sk_…`. Contracts: https://apelcuai.store/dezvoltatori",
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://api.apelcuai.store"
    }
  ],
  "paths": {
    "/api/v1/organization": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "The key's organization and the key's scopes",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/calls": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Calls and chats, newest first",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/calls/{callId}": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "One call with its transcript",
        "parameters": [
          {
            "name": "callId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/customers": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "The organization's customer list",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/customers/{id}": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "One customer",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/customers/import": {
      "post": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Create or update customers (matched by externalId, then phone + name)",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicCustomerImportDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/agent": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "The agent's configuration",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Replace the agent's configuration",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentConfigDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "patch": {
        "tags": [
          "PublicSettingsApi"
        ],
        "summary": "Change some fields of the agent's configuration",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonElement"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/flows": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "The widget's guided menus",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Replace the widget's guided menus",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatFlows"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/desk": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "The desk: the assistant, where a hand-over goes, who is live",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/desk/assistant": {
      "put": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Pause or resume the assistant",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeskAssistantRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/desk/transfer": {
      "put": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "The backup number and how long live people ring",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeskTransferRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/desk/operators": {
      "post": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Sign a person in as a live operator (or change how they are reached)",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OperatorSignInRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/desk/operators/{id}": {
      "put": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Change a live operator's name or route",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OperatorUpdateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Sign a live operator out",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/desk/operators/{id}/token": {
      "post": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "A fresh pass for the operator's socket",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/voices": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "The voices on offer, the default greeting and announcement",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/waiting-words": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "The assistant's waiting words",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Replace the organization's own waiting words",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WaitingWordsDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Back to the platform's waiting words",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/widget": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "The website widget's settings",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Change the website widget's settings",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WidgetSettingsDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/notifications/settings": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Which notifications the organization is told about",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Choose the notifications",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationSettingsDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/webhooks": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Where results are delivered (the secret is never read back)",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Change where results are delivered",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeliveryDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/call-types": {
      "get": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "The call types the assistant places calls with",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Add a call type",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CallType"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/call-types/{callTypeId}": {
      "put": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Change a call type",
        "parameters": [
          {
            "name": "callTypeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CallType"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Delete a call type",
        "parameters": [
          {
            "name": "callTypeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/webhooks/test": {
      "post": {
        "tags": [
          "ApelAi.Api"
        ],
        "summary": "Send a webhook.test event to the organization's webhook now",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AgentConfigDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "voice": {
            "type": "string"
          },
          "personas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentPersona"
            }
          },
          "language": {
            "type": "string"
          },
          "persona": {
            "type": "string"
          },
          "systemPrompt": {
            "type": "string"
          },
          "businessHours": {
            "type": "string"
          },
          "escalationPhone": {
            "type": "string"
          },
          "allowedPromises": {
            "type": "string"
          },
          "consentAnnouncement": {
            "type": "string"
          },
          "announcementEnabled": {
            "type": "boolean"
          },
          "announcementVoice": {
            "type": "string"
          },
          "connectSound": {
            "type": "boolean"
          },
          "greeting": {
            "type": "string"
          },
          "backgroundAmbience": {
            "type": "boolean"
          },
          "vocabulary": {
            "type": "string"
          }
        }
      },
      "AgentPersona": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "voice": {
            "type": "string"
          },
          "persona": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          }
        }
      },
      "CallScript": {
        "type": "object",
        "properties": {
          "startStepId": {
            "type": "string"
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScriptStep"
            }
          }
        }
      },
      "CallType": {
        "type": "object",
        "properties": {
          "orgId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "purpose": {
            "type": "string"
          },
          "opening": {
            "type": "string"
          },
          "script": {
            "$ref": "#/components/schemas/CallScript"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "ChatFlows": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "startNodeId": {
            "type": "string"
          },
          "showOnStart": {
            "type": "boolean"
          },
          "nodes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FlowNode"
            }
          }
        }
      },
      "DeliveryDto": {
        "type": "object",
        "properties": {
          "webhookUrl": {
            "type": "string"
          },
          "secret": {
            "type": "string"
          },
          "events": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            }
          },
          "includeTranscript": {
            "type": [
              "null",
              "boolean"
            ]
          },
          "includeSentiment": {
            "type": [
              "null",
              "boolean"
            ]
          }
        }
      },
      "DeskAssistantRequest": {
        "type": "object",
        "properties": {
          "paused": {
            "type": [
              "null",
              "boolean"
            ]
          },
          "by": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "DeskTransferRequest": {
        "type": "object",
        "properties": {
          "backupPhone": {
            "type": [
              "null",
              "string"
            ]
          },
          "ringSeconds": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "FlowNode": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "options": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FlowOption"
            }
          },
          "x": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "y": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          }
        }
      },
      "FlowOption": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "target": {
            "type": "string"
          }
        }
      },
      "JsonElement": { },
      "NotificationSettingsDto": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "OperatorSignInRequest": {
        "type": "object",
        "properties": {
          "externalId": {
            "type": [
              "null",
              "string"
            ]
          },
          "name": {
            "type": [
              "null",
              "string"
            ]
          },
          "route": {
            "type": [
              "null",
              "string"
            ]
          },
          "phone": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "OperatorUpdateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": [
              "null",
              "string"
            ]
          },
          "route": {
            "type": [
              "null",
              "string"
            ]
          },
          "phone": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "PublicCustomerDto": {
        "type": "object",
        "properties": {
          "externalId": {
            "type": [
              "null",
              "string"
            ]
          },
          "name": {
            "type": [
              "null",
              "string"
            ]
          },
          "phones": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            }
          },
          "email": {
            "type": [
              "null",
              "string"
            ]
          },
          "notes": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "PublicCustomerImportDto": {
        "type": "object",
        "properties": {
          "customers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicCustomerDto"
            }
          },
          "lawfulBasisConfirmed": {
            "type": "boolean"
          }
        }
      },
      "ScriptStep": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "yesStepId": {
            "type": "string"
          },
          "noStepId": {
            "type": "string"
          },
          "instruction": {
            "type": "string"
          },
          "x": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "y": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          }
        }
      },
      "WaitingMomentDto": {
        "type": "object",
        "properties": {
          "moment": {
            "type": "string"
          },
          "words": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WaitingWordDto"
            }
          }
        }
      },
      "WaitingWordDto": {
        "type": "object",
        "properties": {
          "text": {
            "type": [
              "null",
              "string"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "stretch": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          }
        }
      },
      "WaitingWordsDto": {
        "type": "object",
        "properties": {
          "moments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WaitingMomentDto"
            }
          }
        }
      },
      "WidgetAppearance": {
        "type": "object",
        "properties": {
          "accent": {
            "type": "string"
          },
          "accentText": {
            "type": "string"
          },
          "surface": {
            "type": "string"
          },
          "ink": {
            "type": "string"
          },
          "soft": {
            "type": "string"
          },
          "radius": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "position": {
            "type": "string"
          },
          "theme": {
            "type": "string"
          },
          "font": {
            "type": "string"
          },
          "launcherLabel": {
            "type": "string"
          },
          "launcherIcon": {
            "type": "string"
          },
          "avatarUrl": {
            "type": "string"
          }
        }
      },
      "WidgetSettingsDto": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "allowedOrigins": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "title": {
            "type": "string"
          },
          "greeting": {
            "type": "string"
          },
          "voiceEnabled": {
            "type": "boolean"
          },
          "voiceMaxSeconds": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "voiceMaxConcurrent": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "voiceRequiresIdentity": {
            "type": "boolean"
          },
          "greetByName": {
            "type": "boolean"
          },
          "namedGreeting": {
            "type": "string"
          },
          "appearance": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WidgetAppearance"
              }
            ]
          },
          "showBranding": {
            "type": [
              "null",
              "boolean"
            ]
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "http",
        "description": "An organization API key: 'Bearer acai_sk_{id}_{secret}'.",
        "scheme": "bearer",
        "bearerFormat": "acai_sk_…"
      }
    }
  },
  "security": [
    {
      "ApiKey": [ ]
    }
  ],
  "tags": [
    {
      "name": "ApelAi.Api"
    },
    {
      "name": "PublicSettingsApi"
    }
  ]
}