> ## 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 orden de compra

> Actualiza una orden de compra editable y devuelve el detalle persistido. Requiere Idempotency-Key.



## OpenAPI

````yaml /api-reference/openapi.json put /api/v1/purchase-orders/{purchase_order_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/purchase-orders/{purchase_order_id}:
    put:
      tags:
        - API
      summary: Actualizar orden de compra
      description: >-
        Actualiza una orden de compra editable y devuelve el detalle persistido.
        Requiere Idempotency-Key.
      operationId: updateApiPurchaseOrder
      parameters:
        - name: purchase_order_id
          in: path
          description: ID de la orden de compra
          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:
              $ref: '#/components/schemas/ApiPurchaseOrderRequest'
      responses:
        '200':
          description: Orden de compra actualizada exitosamente
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiPurchaseOrderWriteResponse'
        '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: Orden de compra no encontrada
          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: Orden de compra no encontrada
                      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:
    ApiPurchaseOrderRequest:
      type: object
      properties:
        supplier_id:
          type: string
          format: uuid
        order_date:
          type: string
          format: date
        expected_date:
          type: string
          format: date
        warehouse_id:
          type: string
          format: uuid
        notes:
          type: string
        items:
          minItems: 1
          maxItems: 500
          type: array
          items:
            type: object
            properties:
              product_id:
                type: string
                format: uuid
              ordered_quantity:
                type: number
                exclusiveMinimum: 0
              expected_unit_cost:
                type: integer
                minimum: 0
            required:
              - product_id
              - ordered_quantity
            additionalProperties: false
      required:
        - supplier_id
        - order_date
        - warehouse_id
        - items
      additionalProperties: false
    ApiPurchaseOrderWriteResponse:
      type: object
      properties:
        request_id:
          type: string
        data:
          type: object
          properties:
            purchase_order:
              $ref: '#/components/schemas/ApiSharedObject92f376ac7c'
            idempotent_replay:
              type: boolean
          required:
            - purchase_order
            - idempotent_replay
          additionalProperties: false
        warnings:
          type: array
          items: {}
      required:
        - request_id
        - data
        - warnings
      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
    ApiSharedObject92f376ac7c:
      type: object
      properties:
        object:
          type: string
          const: purchase_order
        id:
          type: string
          format: uuid
        order_number:
          type: integer
        formatted_order_number:
          anyOf:
            - type: string
            - type: 'null'
        status:
          $ref: '#/components/schemas/ApiSharedEnumf2073aa092'
        order_date:
          type: string
          format: date
        expected_date:
          anyOf:
            - type: string
              format: date
            - type: 'null'
        currency:
          type: string
        supplier:
          anyOf:
            - $ref: '#/components/schemas/ApiSharedObjectaa12edb924'
            - type: 'null'
        warehouse:
          anyOf:
            - $ref: '#/components/schemas/ApiSharedObject8aeeceaf0f'
            - type: 'null'
        created_at:
          type: string
          format: date-time
        warehouse_id:
          type: string
          format: uuid
        notes:
          anyOf:
            - type: string
            - type: 'null'
        items:
          type: array
          items:
            $ref: '#/components/schemas/ApiSharedObject6e43ba6466'
      required:
        - object
        - id
        - order_number
        - formatted_order_number
        - status
        - order_date
        - expected_date
        - currency
        - supplier
        - warehouse
        - created_at
        - warehouse_id
        - notes
        - items
      additionalProperties: false
    ApiSharedObjectc671832641:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        field:
          type: string
      required:
        - code
        - message
      additionalProperties: false
    ApiSharedEnumf2073aa092:
      type: string
      enum:
        - draft
        - sent
        - partially_received
        - received
        - closed
        - cancelled
    ApiSharedObjectaa12edb924:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        description:
          anyOf:
            - type: string
            - type: 'null'
        email:
          anyOf:
            - type: string
            - type: 'null'
        phone:
          anyOf:
            - type: string
            - type: 'null'
        tax_id_type:
          anyOf:
            - type: string
            - type: 'null'
        tax_id:
          anyOf:
            - type: string
            - type: 'null'
        tax_category:
          anyOf:
            - type: string
            - type: 'null'
        payment_term_id:
          anyOf:
            - type: string
            - type: 'null'
        payment_term_days:
          anyOf:
            - type: integer
              minimum: 0
              maximum: 365
              description: >-
                Cantidad de días hasta el vencimiento. Usá 0 para Contado. Se
                prefiere sobre paymentTermId.
            - type: 'null'
        address:
          anyOf:
            - type: string
            - type: 'null'
        apartment:
          anyOf:
            - type: string
            - type: 'null'
        city:
          anyOf:
            - type: string
            - type: 'null'
        province:
          anyOf:
            - type: string
            - type: 'null'
        postal_code:
          anyOf:
            - type: string
            - type: 'null'
      required:
        - id
        - name
        - description
        - email
        - phone
        - tax_id_type
        - tax_id
        - tax_category
        - payment_term_id
        - payment_term_days
        - address
        - apartment
        - city
        - province
        - postal_code
      additionalProperties: false
    ApiSharedObject8aeeceaf0f:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
      required:
        - id
        - name
      additionalProperties: false
    ApiSharedObject6e43ba6466:
      type: object
      properties:
        id:
          type: string
          format: uuid
        ordered_quantity:
          type: number
        received_quantity:
          type: number
        expected_unit_cost:
          anyOf:
            - type: integer
              minimum: 0
            - type: 'null'
        product:
          $ref: '#/components/schemas/ApiSharedObjectf4b2e97eb9'
      required:
        - id
        - ordered_quantity
        - received_quantity
        - expected_unit_cost
        - product
      additionalProperties: false
    ApiSharedObjectf4b2e97eb9:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        sku:
          anyOf:
            - type: string
            - type: 'null'
        product_type:
          anyOf:
            - $ref: '#/components/schemas/ApiSharedEnumff49232140'
            - type: 'null'
        variant_options:
          anyOf:
            - type: object
              additionalProperties:
                type: string
            - type: 'null'
        option_names:
          anyOf:
            - type: array
              items:
                type: string
            - type: 'null'
      required:
        - id
        - name
        - sku
        - product_type
        - variant_options
        - option_names
      additionalProperties: false
    ApiSharedEnumff49232140:
      type: string
      enum:
        - product
        - service
        - combo
        - kit
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: Incluí tu API key en el header Authorization con el prefijo Bearer.

````