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

# Obtener orden de compra por ID

> Devuelve el detalle de una orden de compra.



## OpenAPI

````yaml /api-reference/openapi.json get /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}:
    get:
      tags:
        - API
      summary: Obtener orden de compra por ID
      description: Devuelve el detalle de una orden de compra.
      operationId: getApiPurchaseOrderById
      parameters:
        - name: purchase_order_id
          in: path
          description: ID de la orden de compra
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Orden de compra obtenida exitosamente
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiPurchaseOrderDetailResponse'
        '400':
          description: Parámetros inválidos
          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: Parámetros inválidos
                      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: []
        '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 purchaseOrder = await
            lapyme.purchaseOrders.getPurchaseOrderById({
              purchaseOrderId: "9c692e8b-0f9a-4f7c-8b99-061a2eb188ae",
            });
components:
  schemas:
    ApiPurchaseOrderDetailResponse:
      type: object
      properties:
        request_id:
          type: string
        data:
          $ref: '#/components/schemas/ApiSharedObject3ebe26c85a'
      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
    ApiSharedObject3ebe26c85a:
      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
        tags:
          type: array
          items:
            $ref: '#/components/schemas/ApiSharedObject8a94344083'
        warehouse_id:
          type: string
          format: uuid
        notes:
          anyOf:
            - type: string
            - type: 'null'
        items:
          type: array
          items:
            $ref: '#/components/schemas/ApiSharedObjecte6c529b31e'
      required:
        - object
        - id
        - order_number
        - formatted_order_number
        - status
        - order_date
        - expected_date
        - currency
        - supplier
        - warehouse
        - created_at
        - tags
        - 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
    ApiSharedObject8a94344083:
      type: object
      properties:
        object:
          type: string
          const: tag
        id:
          type: string
          format: uuid
        scope:
          $ref: '#/components/schemas/ApiSharedEnum09f8155a9a'
        name:
          type: string
        slug:
          type: string
        color:
          anyOf:
            - $ref: '#/components/schemas/ApiSharedEnum599647cb76'
            - type: 'null'
        description:
          anyOf:
            - type: string
            - type: 'null'
        archived_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - object
        - id
        - scope
        - name
        - slug
        - color
        - description
        - archived_at
        - created_at
        - updated_at
      additionalProperties: false
    ApiSharedObjecte6c529b31e:
      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/ApiSharedObject92e940f6ec'
      required:
        - id
        - ordered_quantity
        - received_quantity
        - expected_unit_cost
        - product
      additionalProperties: false
    ApiSharedEnum09f8155a9a:
      type: string
      enum:
        - customer
        - supplier
        - product
        - sale
        - purchase
        - purchase_order
        - transfer
    ApiSharedEnum599647cb76:
      type: string
      enum:
        - slate
        - red
        - orange
        - amber
        - yellow
        - lime
        - green
        - teal
        - cyan
        - blue
        - indigo
        - violet
        - pink
    ApiSharedObject92e940f6ec:
      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
              propertyNames:
                type: string
              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.

````