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

# Guardar las variantes de un producto

> Guarda opciones y variantes en una transacción. Las variantes omitidas se conservan. Solo remove_variants retira variantes. Incluí Idempotency-Key.



## OpenAPI

````yaml /api-reference/openapi.json put /api/v1/products/{product_id}/variants
openapi: 3.1.0
info:
  title: La Pyme API
  description: >-
    Resources and workflows for purchases, sales, inventory, contacts, products,
    reports, and settings.
  version: 1.0.0
  contact:
    name: La Pyme Support
    email: hola@lapyme.com.ar
  license:
    name: Proprietary
    url: https://lapyme.com.ar/terminos
servers:
  - url: https://api.lapyme.com.ar
    description: Servidor de producción
security:
  - bearerAuth: []
tags:
  - name: API
    description: Public API operations for La Pyme integrations.
paths:
  /api/v1/products/{product_id}/variants:
    put:
      tags:
        - API
      summary: Guardar las variantes de un producto
      description: >-
        Guarda opciones y variantes en una transacción. Las variantes omitidas
        se conservan. Solo remove_variants retira variantes. Incluí
        Idempotency-Key.
      operationId: saveApiProductVariants
      parameters:
        - name: product_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiProductVariantSaveRequest'
      responses:
        '200':
          description: Matriz guardada
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiProductVariantSaveResponse'
        '400':
          description: Matriz inválida o componente de combo activo
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: INVALID_REQUEST
                  value:
                    request_id: req_error_1
                    error:
                      type: invalid_request_error
                      code: INVALID_REQUEST
                      message: Matriz inválida o componente de combo activo
                      retryable: false
                      details: []
        '401':
          description: Autenticación requerida
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: INVALID_REQUEST
                  value:
                    request_id: req_error_1
                    error:
                      type: invalid_request_error
                      code: INVALID_REQUEST
                      message: Autenticación requerida
                      retryable: false
                      details: []
        '403':
          description: Sin permiso para modificar productos
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: INVALID_REQUEST
                  value:
                    request_id: req_error_1
                    error:
                      type: invalid_request_error
                      code: INVALID_REQUEST
                      message: Sin permiso para modificar productos
                      retryable: false
                      details: []
        '404':
          description: Producto no encontrado
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: INVALID_REQUEST
                  value:
                    request_id: req_error_1
                    error:
                      type: invalid_request_error
                      code: INVALID_REQUEST
                      message: Producto no encontrado
                      retryable: false
                      details: []
        '409':
          description: Clave de idempotencia usada con otro cuerpo
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: INVALID_REQUEST
                  value:
                    request_id: req_error_1
                    error:
                      type: invalid_request_error
                      code: INVALID_REQUEST
                      message: Clave de idempotencia usada con otro cuerpo
                      retryable: false
                      details: []
        '429':
          description: Límite de solicitudes excedido para la organización
          headers:
            Retry-After:
              description: Segundos a esperar antes de volver a intentar la solicitud.
              schema:
                type: string
                example: '30'
            X-RateLimit-Limit:
              description: Límite de la ventana activa.
              schema:
                type: string
                example: '5000'
            X-RateLimit-Remaining:
              description: Solicitudes restantes en la ventana activa.
              schema:
                type: string
                example: '0'
            X-RateLimit-Reset:
              description: Segundos restantes hasta el reset de la ventana activa.
              schema:
                type: string
                example: '30'
            RateLimit-Limit:
              description: Límite de la ventana activa en formato estándar.
              schema:
                type: string
                example: '5000'
            RateLimit-Remaining:
              description: Solicitudes restantes en la ventana activa en formato estándar.
              schema:
                type: string
                example: '0'
            RateLimit-Reset:
              description: >-
                Segundos hasta el reset de la ventana activa en formato
                estándar.
              schema:
                type: string
                example: '30'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: RATE_LIMITED
                  value:
                    request_id: req_rate_limit_1
                    error:
                      type: rate_limit_error
                      code: RATE_LIMITED
                      message: >-
                        The organization request limit was reached. Try again
                        later.
                      retryable: true
                      details: []
        '500':
          description: No se pudo guardar la matriz
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: INVALID_REQUEST
                  value:
                    request_id: req_error_1
                    error:
                      type: invalid_request_error
                      code: INVALID_REQUEST
                      message: No se pudo guardar la matriz
                      retryable: false
                      details: []
components:
  schemas:
    ApiProductVariantSaveRequest:
      type: object
      properties:
        options:
          minItems: 1
          maxItems: 3
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                minLength: 1
                maxLength: 100
              previous_name:
                type: string
                minLength: 1
                maxLength: 100
            required:
              - name
            additionalProperties: false
        remove_options:
          maxItems: 3
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 100
        rename_option_values:
          maxItems: 32
          type: array
          items:
            type: object
            properties:
              option:
                type: string
                minLength: 1
                maxLength: 100
              from:
                type: string
                minLength: 1
                maxLength: 100
              to:
                type: string
                minLength: 1
                maxLength: 100
            required:
              - option
              - from
              - to
            additionalProperties: false
        variants:
          maxItems: 32
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
              option_values:
                type: object
                propertyNames:
                  type: string
                  minLength: 1
                  maxLength: 100
                additionalProperties:
                  type: string
                  minLength: 1
                  maxLength: 100
              sku:
                type: string
                minLength: 1
                maxLength: 100
              barcode:
                anyOf:
                  - type: string
                    maxLength: 100
                  - type: 'null'
              cost:
                type: integer
                minimum: 0
              price:
                type: integer
                minimum: 0
              promotional_price:
                anyOf:
                  - type: integer
                    minimum: 0
                  - type: 'null'
            additionalProperties: false
        remove_variants:
          maxItems: 32
          type: array
          items:
            type: string
            format: uuid
      additionalProperties: false
    ApiProductVariantSaveResponse:
      type: object
      properties:
        request_id:
          type: string
        data:
          type: object
          properties:
            object:
              type: string
              const: product_variant_matrix
            created_count:
              type: integer
            idempotent_replay:
              type: boolean
            variants:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  sku:
                    type: string
                  option_values:
                    type: object
                    propertyNames:
                      type: string
                    additionalProperties:
                      type: string
                required:
                  - id
                  - sku
                  - option_values
                additionalProperties: false
            removed:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  status:
                    $ref: '#/components/schemas/ApiSharedEnum51b4d76d1b'
                required:
                  - id
                  - status
                additionalProperties: false
          required:
            - object
            - created_count
            - idempotent_replay
            - variants
            - removed
          additionalProperties: false
      required:
        - request_id
        - data
      additionalProperties: false
    ApiErrorEnvelope:
      type: object
      properties:
        request_id:
          type: string
        error:
          type: object
          properties:
            type:
              type: string
              enum:
                - api_error
                - authentication_error
                - authorization_error
                - business_error
                - external_dependency_error
                - idempotency_error
                - invalid_request_error
                - rate_limit_error
            code:
              type: string
            message:
              type: string
            retryable:
              type: boolean
            details:
              type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  metadata:
                    type: object
                    propertyNames:
                      type: string
                    additionalProperties:
                      type:
                        - string
                        - number
                        - boolean
                        - 'null'
                required:
                  - code
                  - message
                additionalProperties: false
          required:
            - type
            - code
            - message
            - retryable
            - details
          additionalProperties: false
      required:
        - request_id
        - error
      additionalProperties: false
    ApiSharedEnum51b4d76d1b:
      type: string
      enum:
        - deleted
        - archived
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: Incluí tu API key en el header Authorization con el prefijo Bearer.

````

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