> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sleak.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Start een conversatie

> Creëert een nieuwe chatconversatie met de opgegeven chatbot

Dit endpoint begint een nieuwe conversatie met een specifieke chatbot. Je ontvangt een `conversation_id` terug die je kunt gebruiken om berichten te versturen.


## OpenAPI

````yaml POST /api/conversation
openapi: 3.0.3
info:
  title: Sleak Chat API
  description: >
    API voor het beheren van chatbot conversaties. Deze API maakt het mogelijk
    om veilig gesprekken te starten

    en berichten uit te wisselen met AI-chatbots, inclusief het meesturen van
    afbeeldingen.


    ## Authenticatie

    Gebruik je API sleutel als Bearer token in de Authorization header:

    ```

    Authorization: Bearer <jouw-api-sleutel>

    ```

    Een API sleutel hoort bij één organisatie en geeft toegang tot alle chatbots
    en conversaties van die organisatie.


    ## Werkwijze

    1. Start een conversatie met `POST /api/conversation` en bewaar de
    `conversation_id` en `contact_id`.

    2. Verstuur berichten met `POST /api/message`. Het antwoord van de chatbot
    zit direct in de response.

    3. Gebruik dezelfde `contact_id` bij een volgende conversatie om deze aan
    hetzelfde contact te koppelen.


    ## Rate Limiting

    Requests zijn beperkt tot 100 per minuut per API sleutel. Bij overschrijding
    volgt een `429` met de headers

    `Retry-After`, `X-RateLimit-Limit`, `X-RateLimit-Remaining` en
    `X-RateLimit-Reset`.
  version: 1.1.0
  contact:
    name: Sleak Support
    email: support@sleak.chat
servers:
  - url: https://api.v1.sleak.chat
security:
  - bearerAuth: []
tags:
  - name: Conversaties
    description: Beheer van chatbot conversaties
  - name: Berichten
    description: Berichten uitwisseling binnen conversaties
paths:
  /api/conversation:
    post:
      tags:
        - Conversaties
      summary: Start een nieuwe conversatie
      description: >
        Creëert een nieuwe conversatie met de opgegeven chatbot. Zonder
        `contact_id` wordt een nieuw contact aangemaakt.

        Met een bestaande `contact_id` wordt de conversatie aan dat contact
        gekoppeld en worden de opgegeven

        contactgegevens bijgewerkt.
      operationId: createConversation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConversationRequest'
      responses:
        '200':
          description: Conversatie succesvol aangemaakt
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationResponse'
        '400':
          description: >
            Ongeldige aanvraag, bijvoorbeeld een ontbrekende of onbekende
            `chatbot_id`,

            ongeldige JSON of een `contact_id` die geen UUID is.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubscriptionInactive'
        '404':
          description: >-
            Chatbot niet gevonden, of de `contact_id` hoort bij een andere
            organisatie
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          $ref: '#/components/responses/ValidationFailed'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    ConversationRequest:
      type: object
      required:
        - chatbot_id
      properties:
        chatbot_id:
          type: string
          format: uuid
          description: Unieke identifier van de chatbot
          example: b88e1147-d2ce-407e-8646-5a7c08ecaebc
        contact_id:
          type: string
          format: uuid
          description: >
            Optionele UUID voor het contact. Als deze niet wordt opgegeven,
            wordt automatisch een nieuwe ID

            gegenereerd. Een bestaand contact moet tot dezelfde organisatie als
            de chatbot behoren.
          example: c428c263-a1d3-4072-bf64-525cefbfb0b1
        external_id:
          type: string
          description: >-
            Optionele identifier uit je eigen systeem, opgeslagen bij de
            conversatie
          example: order-12345
        user_name:
          type: string
          description: Optionele naam van het contact
          example: Jan Jansen
        user_email:
          type: string
          description: Optioneel e-mailadres van het contact
          example: jan@example.com
        user_phone:
          type: string
          description: Optioneel telefoonnummer van het contact
          example: '+31612345678'
    ConversationResponse:
      type: object
      required:
        - conversation_id
        - contact_id
      properties:
        conversation_id:
          type: string
          format: uuid
          description: Unieke identifier van de aangemaakte conversatie
          example: 5fc020e6-d603-4069-890e-a231c8e9003c
        contact_id:
          type: string
          format: uuid
          description: Unieke identifier van het contact
          example: c428c263-a1d3-4072-bf64-525cefbfb0b1
    ErrorResponse:
      type: object
      properties:
        detail:
          type: string
          description: Foutmelding
          example: Invalid API key
    ValidationErrorResponse:
      type: object
      properties:
        detail:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                example: literal_error
              loc:
                type: array
                items:
                  oneOf:
                    - type: string
                    - type: integer
                example:
                  - body
                  - attachments
                  - 0
                  - type
              msg:
                type: string
                example: Input should be 'image'
    RateLimitResponse:
      type: object
      properties:
        detail:
          type: object
          properties:
            error:
              type: string
              example: Rate limit exceeded
            message:
              type: string
              example: Too many requests. Please try again later.
            limit:
              type: integer
              example: 100
            remaining:
              type: integer
              example: 0
            reset:
              type: string
              format: date-time
            retry_after:
              type: integer
              example: 42
  responses:
    Unauthorized:
      description: >-
        API sleutel ontbreekt, heeft een ongeldig formaat of hoort niet bij de
        organisatie van de chatbot
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            detail: Invalid API key
    SubscriptionInactive:
      description: Het abonnement van de organisatie is niet actief
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            detail: Organization subscription is not active
    ValidationFailed:
      description: De request body voldoet niet aan het schema
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationErrorResponse'
    RateLimited:
      description: Rate limit overschreden
      headers:
        Retry-After:
          description: Aantal seconden tot er weer requests verstuurd mogen worden
          schema:
            type: integer
        X-RateLimit-Limit:
          description: Maximum aantal requests per minuut
          schema:
            type: integer
        X-RateLimit-Remaining:
          description: Aantal resterende requests in het huidige window
          schema:
            type: integer
        X-RateLimit-Reset:
          description: Unix timestamp in milliseconden waarop de limiet reset
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitResponse'
    ServerError:
      description: Interne server fout
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        Gebruik je API sleutel als Bearer token.
        Voorbeeld: `Authorization: Bearer <jouw-api-sleutel>`

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.