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

# Cancelar pedido



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/orders/{order_id}/cancel
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/orders/{order_id}/cancel:
    post:
      tags:
        - API
      summary: Cancelar pedido
      operationId: cancelApiOrder
      parameters:
        - name: order_id
          in: path
          description: ID del pedido
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Pedido cancelado
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiOrderWriteResponse'
        '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: []
      x-codeSamples:
        - lang: typescript
          label: La Pyme SDK
          source: |
            import { Lapyme } from "lapyme";

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

            const order = await lapyme.orders.cancel({
              orderId: "9c692e8b-0f9a-4f7c-8b99-061a2eb188ae",
            });
components:
  schemas:
    ApiOrderWriteResponse:
      type: object
      properties:
        request_id:
          type: string
        data:
          type: object
          properties:
            order:
              $ref: '#/components/schemas/ApiSharedObject1cf33bb430'
            idempotent_replay:
              type: boolean
            result: {}
          required:
            - order
          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
    ApiSharedObject1cf33bb430:
      type: object
      properties:
        object:
          type: string
          const: order
        id:
          type: string
          format: uuid
        order_number:
          type: string
        raw_order_number:
          type: integer
        order_date:
          type: string
          format: date-time
        customer_id:
          type: string
          format: uuid
        customer_name:
          type: string
        customer_tax_id:
          anyOf:
            - type: string
            - type: 'null'
        items_count:
          type: integer
        total_units:
          type: integer
        discount_amount:
          type: integer
          minimum: 0
        subtotal:
          type: integer
          minimum: 0
        tax_amount:
          type: integer
          minimum: 0
        total:
          type: integer
          minimum: 0
        currency:
          $ref: '#/components/schemas/ApiSharedEnum6cfb146157'
        order_status:
          $ref: '#/components/schemas/ApiSharedEnum4ac9200c4a'
        preparation_status:
          $ref: '#/components/schemas/ApiSharedEnumb49e56b125'
        invoicing_status:
          $ref: '#/components/schemas/ApiSharedEnum2f67ddf0e8'
        notes:
          anyOf:
            - type: string
            - type: 'null'
        created_at:
          type: string
          format: date-time
        created_by_name:
          type: string
        created_by:
          type: string
          format: uuid
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/ApiSharedObject57439fd94e'
        active_warehouses:
          type: array
          items:
            $ref: '#/components/schemas/ApiSharedObject6e2450633e'
        pending_preparation_warehouse_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
        preparations:
          type: array
          items:
            $ref: '#/components/schemas/ApiSharedObjectc7aa334b79'
        invoices:
          type: array
          items:
            $ref: '#/components/schemas/ApiSharedObject4fb237ae51'
      required:
        - object
        - id
        - order_number
        - raw_order_number
        - order_date
        - customer_id
        - customer_name
        - customer_tax_id
        - items_count
        - total_units
        - discount_amount
        - subtotal
        - tax_amount
        - total
        - currency
        - order_status
        - preparation_status
        - invoicing_status
        - notes
        - created_at
        - created_by_name
        - created_by
        - line_items
        - active_warehouses
        - pending_preparation_warehouse_id
        - preparations
        - invoices
      additionalProperties: false
    ApiSharedObjectc671832641:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        field:
          type: string
      required:
        - code
        - message
      additionalProperties: false
    ApiSharedEnum6cfb146157:
      type: string
      enum:
        - PES
        - DOL
    ApiSharedEnum4ac9200c4a:
      type: string
      enum:
        - open
        - completed
        - cancelled
    ApiSharedEnumb49e56b125:
      type: string
      enum:
        - unfulfilled
        - in_progress
        - partially_fulfilled
        - fulfilled
        - cancelled
    ApiSharedEnum2f67ddf0e8:
      type: string
      enum:
        - pending
        - partially_invoiced
        - invoiced
    ApiSharedObject57439fd94e:
      type: object
      properties:
        id:
          type: string
          format: uuid
        line_number:
          type: integer
        product_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
        product_name:
          type: string
        sku:
          type: string
        ordered_quantity:
          type: integer
        allocated_quantity:
          type: integer
        fulfilled_quantity:
          type: integer
        invoiced_quantity:
          type: integer
        cancelled_quantity:
          type: integer
        unit_price:
          type: integer
          minimum: 0
        tax_rate_id:
          type: integer
        discount_amount:
          anyOf:
            - type: integer
            - type: 'null'
        discount_percentage:
          anyOf:
            - type: number
            - type: 'null'
        subtotal:
          type: integer
          minimum: 0
      required:
        - id
        - line_number
        - product_id
        - product_name
        - sku
        - ordered_quantity
        - allocated_quantity
        - fulfilled_quantity
        - invoiced_quantity
        - cancelled_quantity
        - unit_price
        - tax_rate_id
        - discount_amount
        - discount_percentage
        - subtotal
      additionalProperties: false
    ApiSharedObject6e2450633e:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        is_default:
          type: boolean
      required:
        - id
        - name
        - is_default
      additionalProperties: false
    ApiSharedObjectc7aa334b79:
      type: object
      properties:
        object:
          type: string
          const: order_preparation
        id:
          type: string
          format: uuid
        prepared_at:
          type: string
          format: date-time
        warehouse_name:
          type: string
        delivery_method:
          $ref: '#/components/schemas/ApiSharedEnumcc76b6d63a'
        remito_delivery_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
        formatted_remito_number:
          anyOf:
            - type: string
            - type: 'null'
        lines:
          type: array
          items:
            $ref: '#/components/schemas/ApiSharedObjectb1bb980a27'
      required:
        - object
        - id
        - prepared_at
        - warehouse_name
        - delivery_method
        - remito_delivery_id
        - formatted_remito_number
        - lines
      additionalProperties: false
    ApiSharedObject4fb237ae51:
      type: object
      properties:
        object:
          type: string
          const: order_invoice
        id:
          type: string
          format: uuid
        formatted_invoice_number:
          anyOf:
            - type: string
            - type: 'null'
        invoice_date:
          type: string
        created_at:
          type: string
          format: date-time
        invoice_status:
          $ref: '#/components/schemas/ApiSharedEnum9ac70a3316'
        items_count:
          type: integer
        total_units:
          type: integer
        total:
          type: integer
          minimum: 0
      required:
        - object
        - id
        - formatted_invoice_number
        - invoice_date
        - created_at
        - invoice_status
        - items_count
        - total_units
        - total
      additionalProperties: false
    ApiSharedEnumcc76b6d63a:
      type: string
      enum:
        - shipping
        - local_delivery
        - pickup
    ApiSharedObjectb1bb980a27:
      type: object
      properties:
        id:
          type: string
          format: uuid
        order_line_id:
          type: string
          format: uuid
        product_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
        product_name:
          type: string
        sku:
          type: string
        variant_options:
          anyOf:
            - type: object
              additionalProperties:
                type: string
            - type: 'null'
        option_names:
          anyOf:
            - type: array
              items:
                type: string
            - type: 'null'
        quantity:
          type: integer
        ordered_quantity:
          type: integer
        unit_price:
          type: integer
          minimum: 0
        discount_percentage:
          anyOf:
            - type: number
            - type: 'null'
      required:
        - id
        - order_line_id
        - product_id
        - product_name
        - sku
        - variant_options
        - option_names
        - quantity
        - ordered_quantity
        - unit_price
        - discount_percentage
      additionalProperties: false
    ApiSharedEnum9ac70a3316:
      type: string
      enum:
        - not_required
        - pending
        - issued
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: Incluí tu API key en el header Authorization con el prefijo Bearer.

````