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

# Consultar compra

> Retorna valores, estados, cupons e atribuição de flow de uma compra.



## OpenAPI

````yaml /openapi.json get /v1/purchases/{purchase_id}
openapi: 3.1.0
info:
  title: Bevits API
  version: 1.0.0
  description: >-
    API pública somente leitura para consultar dados de CRM, compras e automação
    de uma organização Bevits.
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: https://api.bevits.com
    description: Produção
security:
  - bearerAuth: []
tags:
  - name: Sistema
    description: Disponibilidade da API.
  - name: Identidade
    description: Identidade da organização e da API key.
  - name: Clientes
    description: Clientes e suas relações.
  - name: Segmentos
    description: Segmentos de clientes.
  - name: Compras
    description: Compras importadas das integrações.
  - name: Dados do CRM
    description: Tags e definições de atributos.
  - name: Automações
    description: Flows de automação.
  - name: Campanhas
    description: Campanhas de e-mail.
paths:
  /v1/purchases/{purchase_id}:
    get:
      tags:
        - Compras
      summary: Consultar compra
      description: Retorna valores, estados, cupons e atribuição de flow de uma compra.
      operationId: getPurchase
      parameters:
        - $ref: '#/components/parameters/PurchaseId'
      responses:
        '200':
          $ref: '#/components/responses/Purchase'
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    PurchaseId:
      name: purchase_id
      in: path
      required: true
      description: ID público da compra.
      schema:
        type: string
        pattern: ^pur_[A-Za-z0-9_-]+$
  responses:
    Purchase:
      description: Compra encontrada.
      headers:
        ETag:
          $ref: '#/components/headers/ETag'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Purchase'
    InvalidRequest:
      description: Parâmetro de rota inválido.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: API key ausente, inválida, expirada ou revogada.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: authentication_error
              message: Invalid API key.
              request_id: req_07f6cdc3c20249d6afcd90b4
    NotFound:
      description: Recurso inexistente ou pertencente a outra organização.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    RateLimited:
      description: Limite de requisições excedido.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitErrorResponse'
    InternalError:
      description: Erro inesperado no servidor.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  headers:
    ETag:
      description: Identificador da versão do conteúdo para cache condicional.
      schema:
        type: string
        example: '"v1-4ad31f5efb6b8f35"'
    RetryAfter:
      description: Segundos até uma nova tentativa.
      schema:
        type: integer
        minimum: 1
    RateLimitLimit:
      description: Limite total da janela atual.
      schema:
        type: integer
        example: 600
    RateLimitRemaining:
      description: Requisições restantes na janela atual.
      schema:
        type: integer
        example: 599
    RateLimitReset:
      description: Instante UTC em que a janela atual termina.
      schema:
        type: string
        format: date-time
  schemas:
    Purchase:
      type: object
      required:
        - object
        - id
        - customer_id
        - purchase_value_in_cents
        - created_at
        - updated_at
      properties:
        object:
          type: string
          const: purchase
        id:
          type: string
          pattern: ^pur_[A-Za-z0-9_-]+$
        customer_id:
          type: string
          pattern: ^cus_[A-Za-z0-9_-]+$
        order_id_on_integration_platform:
          type: string
        order_number:
          type: string
        platform:
          type: string
        status:
          type: string
        payment_status:
          type: string
        shipping_status:
          type: string
        currency:
          type: string
          example: BRL
        purchase_value_in_cents:
          type: integer
        subtotal_amount_in_cents:
          type: integer
        total_amount_in_cents:
          type: integer
        discount_in_cents:
          type: integer
        shipping_cost_customer_in_cents:
          type: integer
        coupons:
          type: array
          items:
            $ref: '#/components/schemas/Coupon'
        attributed_flow_ids:
          type: array
          items:
            type: string
            pattern: ^flw_[A-Za-z0-9_-]+$
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/Error'
    RateLimitErrorResponse:
      allOf:
        - $ref: '#/components/schemas/ErrorResponse'
        - type: object
          required:
            - retry_after
          properties:
            retry_after:
              type: integer
              minimum: 1
              description: Segundos até uma nova tentativa.
    Coupon:
      type: object
      required:
        - id
        - code
        - value
        - type
      properties:
        id:
          type: string
        code:
          type: string
        value:
          type: number
        type:
          type: string
    Error:
      type: object
      required:
        - type
        - message
        - request_id
      properties:
        type:
          type: string
          enum:
            - authentication_error
            - conflict
            - internal_error
            - invalid_request
            - not_found
            - permission_denied
            - rate_limited
            - validation_error
        message:
          type: string
        param:
          type: string
        request_id:
          type: string
          pattern: ^req_[a-f0-9]{24}$
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: bvt_live_...
      description: API key criada nas configurações da organização.

````