> ## Documentation Index
> Fetch the complete documentation index at: https://devs.tapipay.la/llms.txt
> Use this file to discover all available pages before exploring further.

# Consultar orden de pago

> Devuelve la orden creada con ese externalRequestId y su estado actual.



## OpenAPI

````yaml /api-reference/openapi.yaml get /v2/debts/orders
openapi: 3.0.0
info:
  title: TapiPay API
  version: 1.0.0
  description: >
    API pública de la plataforma de cobranzas TapiPay.  Ofrece un contrato
    limpio y desacoplado del modelo interno de la plataforma, permitiendo a los
    clientes crear y gestionar cobros (deudas puntuales,  suscripciones
    recurrentes, links de pago, productos y contactos)  sin conocer detalles
    internos de Company, Modalities o GenerationData.
  contact:
    name: TapiPay Team
    url: https://www.tapipay.com
  license:
    name: Proprietary
servers:
  - url: https://tapipay-facade.homo.tapila.cloud
    description: Homologación
security:
  - apiKeyAuth: []
    tapiAuth: []
paths:
  /v2/debts/orders:
    get:
      tags:
        - Payment orders
      summary: Consultar orden de pago
      description: Devuelve la orden creada con ese externalRequestId y su estado actual.
      operationId: getDebtOrder
      parameters:
        - name: externalRequestId
          in: query
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 250
          description: El mismo externalRequestId que enviaste al crear la orden.
        - name: companyCode
          in: query
          required: false
          schema:
            type: string
          description: Solo si tu cliente tiene varias companies.
      responses:
        '200':
          description: Orden encontrada
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/DebtOrder'
                  requestId:
                    type: string
        '400':
          description: INVALID_REQUEST si falta externalRequestId o supera 250 caracteres.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            RESOLUTION_ERROR (con envelope de error) si el companyCode no
            pertenece a tu cliente.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: RESOURCE_NOT_FOUND si no existe una orden con ese externalRequestId.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: >-
            INTERNAL_ERROR si la orden no se pudo leer en este momento.
            Reintenta más tarde.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    DebtOrder:
      type: object
      required:
        - orderId
        - status
        - amount
        - currency
        - paymentMethod
        - estimatedProcessingDate
      properties:
        orderId:
          type: string
          example: 6f1c2b9e-4d3a-4b8e-9a71-2c5d8e0f1a23
        status:
          type: string
          enum:
            - PROCESSING
            - PAID
            - FAILED
            - CHARGED_BACK
          description: >-
            PROCESSING: el cargo se pidió y no se confirmó todavía. PAID: se
            cobró. FAILED: no se pudo cobrar. CHARGED_BACK: se cobró y después
            se revirtió. El cargo es asíncrono: consulta el estado con GET
            /v2/debts/orders.
        amount:
          type: number
        currency:
          type: string
          example: MXN
        paymentMethod:
          type: object
          required:
            - externalPaymentMethodId
            - paymentMethodType
          properties:
            externalPaymentMethodId:
              type: string
              nullable: true
              description: Referencia opaca a la cuenta con la que se cobra.
            paymentMethodType:
              type: string
              nullable: true
              enum:
                - BANK_ACCOUNT
        estimatedProcessingDate:
          type: string
          format: date
          nullable: true
          description: >-
            Fecha estimada del cargo (YYYY-MM-DD). Por ahora siempre viene en
            null.
    Error:
      type: object
      required:
        - error
        - requestId
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              enum:
                - INVALID_REQUEST
                - BAD_REQUEST
                - RESOURCE_NOT_FOUND
                - RESOURCE_CONFLICT
                - RESOLUTION_ERROR
                - BUSINESS_RULE_VIOLATION
                - RATE_LIMITED
                - INTERNAL_ERROR
                - PARTIAL_UPDATE
                - NO_ACTIVE_PAYMENT_METHOD
                - COMPANY_WITHOUT_PRODUCT_MODALITY
                - CONTACT_NOT_FOUND
                - COMPANY_WITHOUT_DEBT_ID_MODALITY
                - PAYMENT_METHODS_NOT_ENABLED
                - ORDER_NOT_CREATED
                - PAYMENT_METHOD_NOT_AVAILABLE
              description: >-
                Código de error estándar. BAD_REQUEST se usa cuando tu cliente
                tiene varias companies y no se envía `companyCode`.
                NO_ACTIVE_PAYMENT_METHOD y COMPANY_WITHOUT_PRODUCT_MODALITY
                aparecen en POST /adhesions (el primero también en POST
                /v2/debts/orders). CONTACT_NOT_FOUND,
                COMPANY_WITHOUT_DEBT_ID_MODALITY, PAYMENT_METHODS_NOT_ENABLED,
                ORDER_NOT_CREATED y PAYMENT_METHOD_NOT_AVAILABLE solo aparecen
                en POST /v2/debts/orders. PARTIAL_UPDATE solo aparece en el 207
                de PATCH /subscriptions/{id}: la suscripción se actualizó, pero
                alguna de sus deudas no. Los 401 y 403 los emite el API Gateway
                y no usan este envelope (ver GatewayError). Excepción: en
                /v2/debts/orders, RESOLUTION_ERROR responde 403 con este
                envelope.
            message:
              type: string
              description: >-
                Mensaje legible del error. Es informativo: no lo parsees, usa
                `code` y `details[].field`.
            details:
              type: array
              description: >-
                Array de detalles adicionales (validaciones por campo, etc.). Un
                JSON malformado devuelve `[{ "field": "body", "issue": "Invalid
                JSON syntax" }]`.
              items:
                type: object
                properties:
                  field:
                    type: string
                    description: Campo que falló la validación
                  issue:
                    type: string
                    description: Descripción del problema
                  index:
                    type: integer
                    description: >-
                      Solo en el modo lote de POST /v2/debts. Posición del item
                      en `debts`.
                  externalRequestId:
                    type: string
                    description: >-
                      Solo en el modo lote de POST /v2/debts. externalRequestId
                      del item.
        requestId:
          type: string
          pattern: ^req_[a-zA-Z0-9]+$
          description: ID único del request para trazabilidad
    GatewayError:
      type: object
      description: >-
        Respuesta de error emitida por el API Gateway, antes de llegar al
        servicio. No lleva el envelope `error` ni `requestId`. Casos: token
        faltante o inválido en `x-authorization-token` devuelve `401 {"message":
        "Unauthorized"}`; `x-api-key` faltante o inválida devuelve `403
        {"message": "Forbidden"}`; token válido sin permiso sobre el recurso
        devuelve `403 {"Message": "User is not authorized to access this
        resource with an explicit deny"}`. Ojo al tipar: en este último caso el
        campo viene con mayúscula (`Message`), no `message`.
      properties:
        message:
          type: string
          example: Unauthorized
        Message:
          type: string
          description: Solo en el 403 de explicit deny (con mayúscula).
          example: User is not authorized to access this resource with an explicit deny
  responses:
    Unauthorized:
      description: >-
        No autenticado. Lo emite el API Gateway cuando falta o es inválido el
        token en `x-authorization-token`. Body `{"message": "Unauthorized"}`,
        sin envelope `error` ni `requestId`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GatewayError'
          example:
            message: Unauthorized
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >
        API key del API Gateway de Tapi. Requerida en todas las operaciones.
        Distinta por ambiente (desarrollo, homologación, producción).
    tapiAuth:
      type: apiKey
      in: header
      name: x-authorization-token
      description: >
        Token TAPI JWT. Requerido en todas las operaciones. Se envía sin prefijo
        "Bearer". Ej: x-authorization-token: eyJhbGci...

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.