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

# Actualizar metadatos de venta

> Actualiza solo metadatos operativos de una venta: notas, referencia de integracion externa y vendedor. No permite modificar items, importes, pagos ni datos fiscales.



## OpenAPI

````yaml /api-reference/openapi.json patch /api/v1/sales/{sale_id}
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}:
    patch:
      tags:
        - API
      summary: Actualizar metadatos de venta
      description: >-
        Actualiza solo metadatos operativos de una venta: notas, referencia de
        integracion externa y vendedor. No permite modificar items, importes,
        pagos ni datos fiscales.
      operationId: patchApiSaleMetadata
      parameters:
        - name: sale_id
          in: path
          description: ID de la venta
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiSaleMetadataPatchRequest'
            examples:
              update_notes_and_reference:
                summary: Actualizar notas y referencia externa
                value:
                  notes: Pedido conciliado con ERP
                  integration_source: ERP
                  integration_id: SO-10045
              clear_external_reference:
                summary: Limpiar referencia externa
                value:
                  integration_source: null
                  integration_id: null
      responses:
        '200':
          description: Venta actualizada exitosamente
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiSaleDetailResponse'
        '400':
          description: Payload invalido o metadatos no permitidos
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: INVALID_REQUEST
                  value:
                    request_id: req_sale_patch_1
                    error:
                      code: INVALID_REQUEST
                      message: Invalid request for updating the sale
                      retryable: false
                      details:
                        - field: integration_id
                          code: custom
                          message: >-
                            integration_source and integration_id must be
                            provided together.
                      type: invalid_request_error
        '401':
          description: API key faltante o invalida
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: AUTHENTICATION_REQUIRED
                  value:
                    request_id: req_sale_patch_1
                    error:
                      code: AUTHENTICATION_REQUIRED
                      message: API key is required in the Authorization header
                      retryable: false
                      type: invalid_request_error
                      details: []
        '403':
          description: Scopes insuficientes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: FORBIDDEN
                  value:
                    request_id: req_sale_patch_1
                    error:
                      code: FORBIDDEN
                      message: Your API key does not have permission for this operation
                      retryable: false
                      type: invalid_request_error
                      details: []
        '404':
          description: Venta no encontrada
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: NOT_FOUND
                  value:
                    request_id: req_sale_patch_1
                    error:
                      code: NOT_FOUND
                      message: Sale not found
                      retryable: false
                      type: invalid_request_error
                      details: []
        '409':
          description: La referencia de integracion ya esta asociada a otra venta
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                default:
                  summary: CONFLICT
                  value:
                    request_id: req_sale_patch_1
                    error:
                      code: CONFLICT
                      message: Sale integration reference already exists.
                      retryable: false
                      details:
                        - field: integration_id
                          code: duplicate_integration_reference
                          message: >-
                            Another sale already uses this integration source
                            and ID.
                      type: invalid_request_error
        '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: INTERNAL_ERROR
                  value:
                    request_id: req_sale_patch_1
                    error:
                      code: INTERNAL_ERROR
                      message: Could not update the sale
                      retryable: false
                      type: invalid_request_error
                      details: []
      x-codeSamples:
        - lang: typescript
          label: La Pyme SDK
          source: |
            import { Lapyme } from "lapyme";

            const lapyme = new Lapyme({
              bearerAuth: process.env["LAPYME_API_KEY"] ?? "",
            });

            const sale = await lapyme.sales.patchMetadata({
              saleId: "9c692e8b-0f9a-4f7c-8b99-061a2eb188ae",
              body: {
                notes: "Referencia actualizada desde integracion",
              },
            });
components:
  schemas:
    ApiSaleMetadataPatchRequest:
      type: object
      properties:
        notes:
          description: >-
            Notas operativas de la venta. Enviar null o string vacio para
            limpiar.
          anyOf:
            - type: string
            - type: 'null'
        integration_source:
          description: >-
            Fuente de integracion externa. Debe enviarse junto con
            integrationId.
          anyOf:
            - type: string
            - type: 'null'
        integration_id:
          description: ID de referencia externa. Debe enviarse junto con integrationSource.
          anyOf:
            - type: string
            - type: 'null'
        salesperson_id:
          description: ID del miembro/vendedor que debe quedar asociado a la venta.
          type: string
          format: uuid
      additionalProperties: false
      description: >-
        Actualizacion parcial de metadatos operativos de venta. Envia al menos
        un campo. integration_source e integration_id deben enviarse juntos;
        para limpiar la referencia externa, envia ambos en null.
      minProperties: 1
    ApiSaleDetailResponse:
      type: object
      properties:
        request_id:
          type: string
        data:
          type: object
          properties:
            object:
              type: string
              const: sale
            id:
              type: string
              format: uuid
            accounting:
              $ref: '#/components/schemas/ApiSharedObject799d3e3f37'
            document:
              $ref: '#/components/schemas/ApiSharedObject44d94dc68b'
            customer:
              anyOf:
                - type: object
                  additionalProperties: {}
                - type: 'null'
            amounts:
              type: object
              additionalProperties: {}
            items:
              type: array
              items:
                type: object
                additionalProperties: {}
            payments:
              type: object
              additionalProperties: {}
            applications:
              type: object
              additionalProperties: {}
            fiscal:
              type: object
              additionalProperties: {}
            integration:
              type: object
              additionalProperties: {}
            reverses_voucher:
              anyOf:
                - type: object
                  additionalProperties: {}
                - type: 'null'
            audit:
              type: object
              additionalProperties: {}
          additionalProperties: {}
      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:
                $ref: '#/components/schemas/ApiSharedObjectc671832641'
          required:
            - type
            - code
            - message
            - retryable
            - details
          additionalProperties: false
      required:
        - request_id
        - error
      additionalProperties: false
    ApiSharedObject799d3e3f37:
      type: object
      properties:
        object:
          type: string
          const: accounting_evidence
        status:
          $ref: '#/components/schemas/ApiSharedEnum8b51d9e8f5'
        journal_entry_ids:
          type: array
          items:
            type: string
            format: uuid
        journal_entries_url:
          anyOf:
            - type: string
            - type: 'null'
        warnings:
          type: array
          items:
            $ref: '#/components/schemas/ApiSharedObject76de9df039'
      required:
        - object
        - status
        - journal_entry_ids
        - journal_entries_url
        - warnings
      additionalProperties: false
    ApiSharedObject44d94dc68b:
      type: object
      properties:
        file:
          $ref: '#/components/schemas/ApiSharedObject890679c3fd'
      required:
        - file
      additionalProperties: {}
    ApiSharedObjectc671832641:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        field:
          type: string
      required:
        - code
        - message
      additionalProperties: false
    ApiSharedEnum8b51d9e8f5:
      type: string
      enum:
        - not_enabled
        - not_applicable
        - pending
        - posted
        - failed
    ApiSharedObject76de9df039:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
      required:
        - code
        - message
      additionalProperties: false
    ApiSharedObject890679c3fd:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/ApiSharedEnum1ba2b57809'
        url:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Stable authenticated La Pyme API path. Present only when status is
            ready; follow redirects when downloading.
      required:
        - status
        - url
      additionalProperties: false
      description: >-
        Document availability. The URL requires bearer authentication and never
        contains a storage path or signed query string.
    ApiSharedEnum1ba2b57809:
      type: string
      enum:
        - ready
        - pending
        - failed
        - missing
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: Incluí tu API key en el header Authorization con el prefijo Bearer.

````