> ## 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.

# Crear nota de crédito por devolución

> Crea una nota de crédito vinculada a una venta existente. Usá este endpoint cuando tenés un sale_id de La Pyme y querés devolver parcial o totalmente sus renglones.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/sales/{sale_id}/returns
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/sales/{sale_id}/returns:
    post:
      tags:
        - API
      summary: Crear nota de crédito por devolución
      description: >-
        Crea una nota de crédito vinculada a una venta existente. Usá este
        endpoint cuando tenés un sale_id de La Pyme y querés devolver parcial o
        totalmente sus renglones.
      operationId: createApiReturnCreditNote
      parameters:
        - name: sale_id
          in: path
          description: ID de la venta original
          required: true
          schema:
            type: string
            format: uuid
        - name: Idempotency-Key
          in: header
          description: Clave estable para deduplicar reintentos de la misma operación.
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - items
              properties:
                items:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                      - sale_item_id
                      - quantity
                      - unit_price
                    properties:
                      sale_item_id:
                        type: string
                        format: uuid
                      product_id:
                        type:
                          - string
                          - 'null'
                        format: uuid
                      warehouse_id:
                        type:
                          - string
                          - 'null'
                        format: uuid
                      quantity:
                        type: number
                        exclusiveMinimum: 0
                      unit_price:
                        type: integer
                        minimum: 0
                      discount_amount:
                        type:
                          - integer
                          - 'null'
                        minimum: 0
                      discount_percentage:
                        type:
                          - number
                          - 'null'
                        minimum: 0
                        maximum: 100
                      subtotal:
                        type: integer
                        minimum: 0
                      tax_amount:
                        type: integer
                        minimum: 0
                      total:
                        type: integer
                        minimum: 0
                payment_date:
                  type: string
                  format: date
                notes:
                  type: string
                refund_amounts_by_method:
                  type: object
                  additionalProperties:
                    type: integer
                    minimum: 0
                restock_inventory:
                  type: boolean
                integration_source:
                  type:
                    - string
                    - 'null'
                integration_id:
                  type:
                    - string
                    - 'null'
                auto_invoicing:
                  type: boolean
                skip_refund_payment:
                  type: boolean
                operator_id:
                  type: string
                  format: uuid
      responses:
        '200':
          description: Nota de crédito creada exitosamente
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiSharedObject44d57fbeb2'
        '400':
          description: Solicitud inválida
          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: Solicitud inválida
                      retryable: false
                      details: []
        '401':
          description: API key faltante o inválida
          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: API key faltante o inválida
                      retryable: false
                      details: []
        '403':
          description: Scopes insuficientes
          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: Scopes insuficientes
                      retryable: false
                      details: []
        '404':
          description: Pedido 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: Pedido no encontrado
                      retryable: false
                      details: []
        '409':
          description: Conflicto de idempotencia o de negocio
          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: Conflicto de idempotencia o de negocio
                      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: Error interno del servidor
          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: Error interno del servidor
                      retryable: false
                      details: []
components:
  schemas:
    ApiSharedObject44d57fbeb2:
      type: object
      properties:
        request_id:
          type: string
        data:
          $ref: '#/components/schemas/ApiSharedObject2f89490657'
        warnings:
          type: array
          items: {}
    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:
                $ref: '#/components/schemas/ApiSharedObjectc671832641'
          required:
            - type
            - code
            - message
            - retryable
            - details
          additionalProperties: false
      required:
        - request_id
        - error
      additionalProperties: false
    ApiSharedObject2f89490657:
      type: object
      properties:
        credit_note:
          $ref: '#/components/schemas/ApiSharedObject2d5ef0a199'
    ApiSharedObjectc671832641:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        field:
          type: string
      required:
        - code
        - message
      additionalProperties: false
    ApiSharedObject2d5ef0a199:
      type: object
      properties:
        object:
          $ref: '#/components/schemas/ApiSharedEnumed3bc9006a'
        sale_id:
          type: string
          format: uuid
        total:
          type:
            - integer
            - 'null'
        invoice_status:
          type:
            - string
            - 'null'
        invoice_number:
          type:
            - integer
            - 'null'
        formatted_invoice_number:
          type:
            - string
            - 'null'
        voucher_type:
          type:
            - string
            - 'null'
    ApiSharedEnumed3bc9006a:
      type: string
      enum:
        - credit_note
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: Incluí tu API key en el header Authorization con el prefijo Bearer.

````