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

# Nachricht hinzufügen

> Sende eine Nutzernachricht an einen Chat und erhalte die Antwort des Assistenten.

Füge einem Chat eine Nutzernachricht hinzu. Der Assistent verarbeitet die Nachricht und gibt eine Antwort zurück, die Folgefragen und Produktempfehlungen enthalten kann.

## Authentifizierung

Diese Anfrage benötigt deinen API-Key im `x-api-key`-Header.

## Request

<ParamField path="chatId" type="string" required>
  ID des Chats, dem die Nachricht hinzugefügt wird.
</ParamField>

<ParamField query="store" type="string">
  Optionaler Query-Parameter.
</ParamField>

<ParamField body="message" type="string" required>
  Der Nachrichtentext des Nutzers.
</ParamField>

<ParamField body="currentUrl" type="string" required>
  Die URL der Seite, die der Nutzer gerade betrachtet. Wird genutzt, um dem Assistenten den Seitenkontext zu geben.
</ParamField>

## Response

<ResponseField name="id" type="string" required>
  ID der erstellten Nachricht.
</ResponseField>

<ResponseField name="chatId" type="string" required>
  ID des Chats, zu dem die Nachricht gehört.
</ResponseField>

<ResponseField name="type" type="string" required>
  Der Nachrichtentyp, zum Beispiel ob sie vom Nutzer oder vom Assistenten stammt.
</ResponseField>

<ResponseField name="content" type="string" required>
  Der Textinhalt der Nachricht.
</ResponseField>

<ResponseField name="suggestions" type="string[]">
  Optionale Liste vorgeschlagener Folgefragen.
</ResponseField>

<ResponseField name="products" type="object[]">
  Optionale Liste empfohlener Produkte.

  <Expandable title="MessageProductDto">
    <ResponseField name="gtin" type="string" required>
      Global Trade Item Number des Produkts.
    </ResponseField>

    <ResponseField name="brand" type="string" required>
      Markenname.
    </ResponseField>

    <ResponseField name="designation" type="string" required>
      Produktname oder Bezeichnung.
    </ResponseField>

    <ResponseField name="url" type="string" required>
      URL der Produktdetailseite.
    </ResponseField>

    <ResponseField name="image" type="string" required>
      URL des Produktbilds.
    </ResponseField>

    <ResponseField name="price" type="number" required>
      Produktpreis.
    </ResponseField>

    <ResponseField name="currency" type="string" required>
      Währungscode des Preises, zum Beispiel `EUR`.
    </ResponseField>

    <ResponseField name="priceInfo" type="string">
      Zusätzliche Preisinformation.
    </ResponseField>

    <ResponseField name="location" type="object[]">
      Schlüssel/Wert-Paare, die den Standort des Produkts beschreiben.

      <Expandable title="MessageProductLocationDto">
        <ResponseField name="key" type="string" required>
          Name des Standort-Attributs.
        </ResponseField>

        <ResponseField name="value" type="string" required>
          Wert des Standort-Attributs.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="availability" type="object">
      Lagerverfügbarkeit des Produkts.

      <Expandable title="MessageAvailabilityDto">
        <ResponseField name="status" type="string" required>
          Verfügbarkeitsstatus.
        </ResponseField>

        <ResponseField name="quantity" type="number" required>
          Verfügbare Menge.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="category" type="string">
      Produktkategorie.
    </ResponseField>

    <ResponseField name="query" type="string">
      Suchanfrage, die das Produkt gefunden hat.
    </ResponseField>

    <ResponseField name="description" type="string">
      Produktbeschreibung.
    </ResponseField>

    <ResponseField name="recommendationText" type="string">
      Text, der erklärt, warum das Produkt empfohlen wird.
    </ResponseField>

    <ResponseField name="flags" type="object[]">
      Highlight-Badges, die dem Produkt zugeordnet sind.

      <Expandable title="ProductFlags">
        <ResponseField name="type" type="string" required>
          Flag-Typ.
        </ResponseField>

        <ResponseField name="title" type="string" required>
          Flag-Titel.
        </ResponseField>

        <ResponseField name="text" type="string" required>
          Flag-Text.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="createdAt" type="string" required>
  ISO-8601-Zeitstempel, wann die Nachricht erstellt wurde.
</ResponseField>

<Note>
  Um die gestreamte Antwort des Assistenten und Tool-Aktivität in Echtzeit zu empfangen, öffne den [Nachrichten-Events](/de/api-reference/backend/messages/message-events)-Stream für dieselbe `chatId`.
</Note>

## Beispiele

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.yourhomie.ai/v1/chats/ab12cd34-ef56-7890-ab12-cd34ef567890/messages \
    -H "x-api-key: homie_sk_live_8f3a..." \
    -H "Content-Type: application/json" \
    -d '{
      "message": "Do you have a waterproof jacket in blue?",
      "currentUrl": "https://shop.example.com/jackets"
    }'
  ```

  ```javascript JavaScript (fetch) theme={null}
  const chatId = "ab12cd34-ef56-7890-ab12-cd34ef567890";

  const res = await fetch(
    `https://api.yourhomie.ai/v1/chats/${chatId}/messages`,
    {
      method: "POST",
      headers: {
        "x-api-key": "homie_sk_live_8f3a...",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        message: "Do you have a waterproof jacket in blue?",
        currentUrl: "https://shop.example.com/jackets",
      }),
    },
  );

  const message = await res.json();
  ```
</CodeGroup>

### Erfolgreiche Response

```json theme={null}
{
  "id": "9b8a7c6d-5e4f-4a3b-9c2d-1e0f2a3b4c5d",
  "chatId": "ab12cd34-ef56-7890-ab12-cd34ef567890",
  "type": "assistant",
  "content": "Yes, here is a waterproof jacket available in blue.",
  "suggestions": [
    "What sizes are available?",
    "Is it machine washable?"
  ],
  "products": [
    {
      "gtin": "4006381333931",
      "brand": "Acme",
      "designation": "All-Weather Jacket",
      "url": "https://shop.example.com/p/all-weather-jacket",
      "image": "https://shop.example.com/img/all-weather-jacket.jpg",
      "price": 129.99,
      "currency": "EUR",
      "availability": {
        "status": "in_stock",
        "quantity": 12
      }
    }
  ],
  "createdAt": "2025-10-16T11:45:02.512Z"
}
```

### Fehler-Response

```json theme={null}
{
  "message": "Monthly message quota reached"
}
```


## OpenAPI

````yaml api-reference/openapi.json POST /v1/chats/{chatId}/messages
openapi: 3.0.0
info:
  title: homie AI API
  description: The homie AI API description
  version: 0.0.1
  contact: {}
servers:
  - url: https://api.yourhomie.ai
    description: Production server
security: []
tags:
  - name: Chat
    description: ''
  - name: Knowledge
    description: Public, CORS-enabled endpoints for PDP question sets
paths:
  /v1/chats/{chatId}/messages:
    post:
      tags:
        - Chat
      summary: Add Message to Chat
      operationId: ChatController_addMessageToChat
      parameters:
        - name: chatId
          required: true
          in: path
          schema:
            type: string
        - name: store
          required: false
          in: query
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessageRequestDto'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageDto'
      security:
        - bearer: []
components:
  schemas:
    MessageRequestDto:
      type: object
      properties:
        message:
          type: string
        currentUrl:
          type: string
      required:
        - message
        - currentUrl
    MessageDto:
      type: object
      properties:
        id:
          type: string
        chatId:
          type: string
        type:
          type: string
        content:
          type: string
        suggestions:
          type: array
          items:
            type: string
        products:
          type: array
          items:
            $ref: '#/components/schemas/MessageProductDto'
        createdAt:
          type: string
      required:
        - id
        - chatId
        - type
        - content
        - createdAt
    MessageProductDto:
      type: object
      properties:
        gtin:
          type: string
        brand:
          type: string
        designation:
          type: string
        url:
          type: string
          format: uri
        image:
          type: string
          format: uri
        price:
          type: number
        priceInfo:
          type: string
        currency:
          type: string
        location:
          type: array
          items:
            $ref: '#/components/schemas/MessageProductLocationDto'
        availability:
          $ref: '#/components/schemas/MessageAvailabilityDto'
        category:
          type: string
        query:
          type: string
        description:
          type: string
        recommendationText:
          type: string
        flags:
          type: array
          items:
            $ref: '#/components/schemas/ProductFlags'
      required:
        - gtin
        - brand
        - designation
        - url
        - image
        - price
        - currency
    MessageProductLocationDto:
      type: object
      properties:
        key:
          type: string
        value:
          type: string
      required:
        - key
        - value
    MessageAvailabilityDto:
      type: object
      properties:
        status:
          type: string
        quantity:
          type: number
      required:
        - status
        - quantity
    ProductFlags:
      type: object
      properties:
        type:
          type: string
        title:
          type: string
        text:
          type: string
      required:
        - type
        - title
        - text
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````