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

# Record Conversion

> Records the outcome of a conversation for analytics and conversion tracking. The `session_id` must match the value used when calling `/v1/next-questions`. The `Idempotency-Key` header is required — replaying the same key for the same conversation is a no-op, making the call safe to retry.




## OpenAPI

````yaml /openapi.yaml post /v1/sessions/{session_id}/conversion
openapi: 3.1.0
info:
  title: NBQ Engine API
  description: >-
    The NBQ Engine REST API returns the next best question to ask during a
    conversation.
  version: 1.0.0
servers:
  - url: https://api.zelinqa.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Health
    description: API health check
  - name: Questions
    description: Next-question selection
  - name: Sessions
    description: Conversation outcome recording
paths:
  /v1/sessions/{session_id}/conversion:
    post:
      tags:
        - Sessions
      summary: Record Conversion
      description: >
        Records the outcome of a conversation for analytics and conversion
        tracking. The `session_id` must match the value used when calling
        `/v1/next-questions`. The `Idempotency-Key` header is required —
        replaying the same key for the same conversation is a no-op, making the
        call safe to retry.
      operationId: recordConversion
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
          description: The session ID used when calling `/v1/next-questions`.
          example: conv-7f3a1c
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            format: uuid
          description: >-
            A client-generated unique key (UUID recommended). Safe to retry with
            the same key.
          example: 6f1d2c8e-9a4b-4f7a-bd2e-0c1a2b3c4d5e
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConversionRequest'
            example:
              outcome: purchase
              metadata:
                order_value: 1290
                currency: EUR
      responses:
        '202':
          description: Conversion recorded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversionResponse'
              example:
                conversion_id: cv_4a7b9c0d1e2f3a4b5c6d7e8f
                request_id: req_77a8b9c0d1e2f3a4
        '403':
          description: Unauthorized
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation error — e.g. missing Idempotency-Key header
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too many requests
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ConversionRequest:
      type: object
      required:
        - outcome
      properties:
        outcome:
          type: string
          enum:
            - purchase
            - lead
            - abandon
            - other
          description: The outcome of the conversation.
          example: purchase
        metadata:
          type: object
          description: >-
            Free-form key/value details for your own use. Not interpreted by
            NBQ. Maximum 4096 bytes serialized.
          additionalProperties: true
          example:
            order_value: 1290
            currency: EUR
    ConversionResponse:
      type: object
      properties:
        conversion_id:
          type: string
          description: Identifier of the recorded conversion.
          example: cv_4a7b9c0d1e2f3a4b5c6d7e8f
        request_id:
          type: string
          description: Unique ID for this request. Include in any support request.
          example: req_77a8b9c0d1e2f3a4
    ErrorResponse:
      type: object
      description: >-
        RFC 7807 problem-details format. Returned with Content-Type:
        application/problem+json.
      properties:
        type:
          type: string
          description: Stable URI identifying the error class.
          example: https://api.zelinqa.ai/errors/validation_failed
        title:
          type: string
          description: Short, human-readable summary of the problem.
          example: Request body or parameters failed validation.
        status:
          type: integer
          description: HTTP status code, mirrored in the body.
          example: 422
        request_id:
          type: string
          description: Include in any support request to trace the exact call.
          example: req_2c4e6a8b0d1f3508
        detail:
          type: string
          description: Human-readable explanation specific to this occurrence.
          example: >-
            Value error, invalid_request: provide conversation_history or
            context
        errors:
          type: array
          description: Per-field validation problems. Present on 422 validation failures.
          items:
            type: object
            properties:
              loc:
                type: array
                items:
                  type: string
              msg:
                type: string
              type:
                type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Pass your NBQ API key in the Authorization header: `Bearer nbq_live_xxx`'

````