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

# Iniciar conversación

> Inicia una nueva conversación de chat con IA para un paciente. Consume 10 créditos.

## Body

<ParamField body="patientId" type="string" required>
  ID del paciente con quien iniciar la conversación.
</ParamField>

<ParamField body="context" type="string" required>
  Contexto e instrucciones para la IA. Define el propósito de la conversación, tono y límites.
</ParamField>

<ParamField body="language" type="string" default="es">
  Idioma de la conversación. Valores: `es` (español), `en` (inglés), `ca` (catalán).
</ParamField>

<Info>
  Iniciar una conversación consume **10 créditos**. Cada mensaje posterior consume **1 crédito**.
</Info>

<ResponseExample>
  ```json 201 theme={null}
  {
    "id": "conv_abc123",
    "patientId": "pat_xyz789",
    "context": "Seguimiento post-operatorio. Preguntar por dolor, movilidad y estado general.",
    "language": "es",
    "status": "active",
    "messages": [
      {
        "id": "msg_001",
        "role": "assistant",
        "content": "Hola María, soy LINA, tu asistente de salud. ¿Cómo te encuentras hoy?",
        "createdAt": "2026-05-14T10:00:00Z"
      }
    ],
    "creditsConsumed": 10,
    "createdAt": "2026-05-14T10:00:00Z"
  }
  ```
</ResponseExample>

<ResponseField name="id" type="string">
  Identificador único de la conversación con prefijo `conv_`.
</ResponseField>

<ResponseField name="status" type="string">
  Estado de la conversación: `active` o `ended`.
</ResponseField>

<ResponseField name="messages" type="array">
  Mensajes de la conversación. Al inicio contiene el primer mensaje de bienvenida de la IA.
</ResponseField>


## OpenAPI

````yaml openapi.yml POST /conversations
openapi: 3.1.0
info:
  title: LINA Healthcare Platform API
  version: 1.0.0
  description: |
    API de integración para la plataforma LINA Healthcare.
    Todas las rutas requieren un token JWT obtenido intercambiando una API Key.
servers:
  - url: https://api.linahealthcareplatform.com/api/v1
    description: Production
security:
  - bearerAuth: []
paths:
  /conversations:
    post:
      tags:
        - Conversaciones
      summary: Iniciar conversación IA
      description: Inicia una nueva conversación con IA para un paciente
      operationId: startConversation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - patientId
              properties:
                patientId:
                  type: string
                context:
                  type: string
                language:
                  type: string
                  enum:
                    - es
                    - en
                    - ca
      responses:
        '201':
          description: Conversación iniciada
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Conversation'
components:
  schemas:
    Conversation:
      type: object
      properties:
        id:
          type: string
        patientId:
          type: string
        status:
          type: string
        messages:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              role:
                type: string
              content:
                type: string
              createdAt:
                type: string
                format: date-time
        createdAt:
          type: string
          format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Token JWT obtenido via POST /auth/token

````