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

# Simular evento do Pix Automático

> Só no sandbox: faça o papel do banco do pagador numa assinatura com Pix Automático.

Disponível só no sandbox (`https://api.sandbox.pagou.ai`). Em produção a rota responde `404`.

No sandbox não existe banco do pagador para autorizar o QR code nem para debitar cada ciclo, então este endpoint faz isso por você. Envie um `event` por chamada: `authorize`, `reject`, `pay` ou `fail`. A assinatura muda exatamente como mudaria em produção, e você recebe os mesmos webhooks `subscription.*`.

Funciona só em assinaturas com Pix Automático criadas no sandbox. Um evento que não cabe na autorização ou no status atual responde `409` com `SUBSCRIPTION_SIMULATION_NOT_APPLICABLE`.

Veja [Assinaturas com Pix Automático → Sandbox](/pt/subscriptions/pix-automatic#sandbox) para o que cada evento faz.


## OpenAPI

````yaml api-reference/openapi-v2.json POST /v2/subscriptions/{id}/simulate
openapi: 3.1.0
info:
  title: Pagou API - v2
  description: API for Pagou.ai Gateway
  version: 2.0.0
  contact:
    name: Support
    url: https://pagou.ai
    email: support@pagou.ai
servers:
  - url: https://api.pagou.ai
    description: Production server
  - url: https://api.sandbox.pagou.ai
    description: Sandbox server for testing
security:
  - BearerAuth: []
  - ApiKeyAuth: []
  - BasicAuth: []
paths:
  /v2/subscriptions/{id}/simulate:
    post:
      tags:
        - Subscriptions
      summary: Simulate a Pix Automático Event
      description: >-
        WARNING: This endpoint is available only in the test environment
        (sandbox).


        Simulate what the payer's bank does to a PIX automatic subscription:
        approve or refuse the recurring authorization, or pay or fail the next
        debit. The subscription moves exactly as it would in production and the
        same `subscription.*` webhooks are sent. Returns 409 when the event does
        not apply to the subscription in its current state.
      operationId: postSubscriptionsByIdSimulate
      parameters:
        - schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
          in: path
          name: id
          required: true
          description: Public subscription id (UUID).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                event:
                  type: string
                  enum:
                    - authorize
                    - reject
                    - pay
                    - fail
                  description: >-
                    `authorize`: the payer approves the recurring authorization
                    (without a trial, the first cycle is paid too). `reject`:
                    the payer refuses it. `pay`: the next debit is paid. `fail`:
                    the next debit fails.
              required:
                - event
              additionalProperties: false
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  requestId:
                    type: string
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        description: Public subscription id (UUID).
                      customerId:
                        type: string
                        description: Public customer id (UUID) the subscription belongs to.
                      status:
                        type: string
                        enum:
                          - incomplete
                          - trialing
                          - active
                          - past_due
                          - cancel_scheduled
                          - canceled
                        description: Current subscription status.
                      paymentMethod:
                        type: string
                        enum:
                          - credit_card
                          - pix_automatic
                        description: How each cycle is paid.
                      billingModel:
                        type: string
                        enum:
                          - merchant_initiated
                          - provider_initiated
                        description: >-
                          `provider_initiated` when each cycle is debited
                          automatically under a recurring authorization the
                          customer approved.
                      billingDayOfMonth:
                        nullable: true
                        description: Day of month cycles are billed, when fixed.
                        type: integer
                        minimum: 1
                        maximum: 31
                      interval:
                        type: string
                        enum:
                          - day
                          - week
                          - month
                        description: Billing interval unit.
                      intervalCount:
                        type: integer
                        minimum: 1
                        maximum: 365
                        description: Number of interval units per billing cycle.
                      amount:
                        type: integer
                        minimum: 0
                        maximum: 100000000
                        description: Billing amount in cents.
                      currency:
                        type: string
                        enum:
                          - BRL
                          - MXN
                          - COP
                          - CLP
                          - ARS
                          - PEN
                          - USD
                          - GTQ
                          - CRC
                          - NIO
                          - PYG
                          - UYU
                          - BOB
                          - PHP
                          - RUB
                          - INR
                          - SAR
                          - AED
                          - KWD
                          - QAR
                          - OMR
                          - KHR
                          - SGD
                          - IDR
                          - KRW
                          - THB
                          - MYR
                          - HKD
                          - CNY
                          - EGP
                          - EUR
                          - GBP
                          - BHD
                          - MAD
                          - AUD
                          - CAD
                          - CHF
                          - NZD
                          - PLN
                          - KZT
                          - UZS
                          - JPY
                          - GLC
                        description: Billing currency.
                      trialEnd:
                        nullable: true
                        description: Trial end timestamp, when applicable.
                        type: string
                        format: date-time
                      currentPeriodStart:
                        description: Start of the current billing period.
                        type: string
                        format: date-time
                      currentPeriodEnd:
                        description: End of the current billing period.
                        type: string
                        format: date-time
                      cancelAtPeriodEnd:
                        type: boolean
                        description: Whether cancellation is scheduled at period end.
                      canceledAt:
                        nullable: true
                        description: Cancellation timestamp, when canceled.
                        type: string
                        format: date-time
                      failurePolicy:
                        type: string
                        enum:
                          - immediate_cancel
                          - retry_then_cancel
                        description: Behavior on a failed billing attempt.
                      retryOffsetsDays:
                        type: array
                        items:
                          type: integer
                          minimum: 1
                          maximum: 30
                        description: Days after a failed attempt to retry.
                      cancellationReason:
                        nullable: true
                        description: Reason for cancellation, when canceled.
                        type: string
                        enum:
                          - user_requested
                          - payment_failure
                          - chargeback
                          - system
                          - admin_requested
                      customerEmail:
                        type: string
                        description: Email of the subscriber.
                      cardLast4:
                        nullable: true
                        description: >-
                          Last four digits of the billing card, for card
                          subscriptions.
                        type: string
                      metadata:
                        nullable: true
                        description: Custom metadata.
                        type: object
                        additionalProperties: {}
                      informations:
                        nullable: true
                        description: >-
                          Custom key/value metadata you attached on create,
                          echoed back.
                        maxItems: 50
                        type: array
                        items:
                          type: object
                          properties:
                            key:
                              type: string
                              minLength: 1
                              maxLength: 64
                              description: Key of the additional information entry.
                            value:
                              type: string
                              minLength: 1
                              maxLength: 255
                              description: Value of the additional information entry.
                          required:
                            - key
                            - value
                          additionalProperties: false
                      products:
                        type: array
                        items:
                          type: object
                          properties:
                            name:
                              type: string
                              maxLength: 255
                              description: Catalog product name.
                            price:
                              type: integer
                              minimum: 0
                              maximum: 100000000
                              description: Unit price in cents.
                            quantity:
                              type: integer
                              minimum: 1
                              maximum: 999999
                              description: Quantity included in the subscription.
                            tangible:
                              type: boolean
                              description: Whether the product is a tangible good.
                            sku:
                              description: Optional SKU.
                              type: string
                              maxLength: 255
                          required:
                            - name
                            - price
                            - quantity
                            - tangible
                          additionalProperties: false
                        description: Snapshot of catalog products billed each cycle.
                      productId:
                        description: >-
                          Public id of the catalog product billed by this
                          subscription. Included on GET and LIST.
                        nullable: true
                        type: string
                      productFamilyId:
                        description: >-
                          Public id of the product family the plan belongs to.
                          Included on GET and LIST.
                        nullable: true
                        type: string
                      pendingChange:
                        description: >-
                          Scheduled plan change, when one is pending. Included
                          on GET and LIST.
                        nullable: true
                        type: object
                        properties:
                          productId:
                            type: string
                            description: >-
                              Public id of the plan that takes effect at the
                              period end.
                          amount:
                            type: integer
                            minimum: 0
                            maximum: 100000000
                            description: >-
                              Amount in cents that the renewal will bill: the
                              scheduled plan plus whatever is billed alongside
                              it.
                          effectiveAt:
                            description: When the scheduled plan takes effect.
                            type: string
                            format: date-time
                        required:
                          - productId
                          - amount
                          - effectiveAt
                        additionalProperties: false
                      authorization:
                        description: >-
                          Pending customer authorization for PIX automatic
                          subscriptions.
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - pix_qr
                          qr_code:
                            type: string
                            description: >-
                              PIX copy-and-paste code the customer uses to
                              authorize the recurring debit.
                          payment_link_url:
                            description: >-
                              Hosted page where the customer can authorize, when
                              provided.
                            type: string
                          expires_at:
                            nullable: true
                            description: When the authorization code expires, when known.
                            type: string
                            format: date-time
                          status:
                            type: string
                            enum:
                              - awaiting_customer
                        required:
                          - type
                          - qr_code
                          - expires_at
                          - status
                        additionalProperties: false
                      recurringAuthorization:
                        nullable: true
                        description: >-
                          Recurring debit authorization, for subscriptions whose
                          cycles are debited automatically.
                        type: object
                        properties:
                          status:
                            type: string
                            enum:
                              - pending
                              - approved
                              - rejected
                              - cancel_pending
                              - canceled
                            description: >-
                              State of the customer's recurring debit
                              authorization.
                          lastDebit:
                            description: Most recent debit attempt. Included on GET by id.
                            nullable: true
                            type: object
                            properties:
                              status:
                                type: string
                                enum:
                                  - succeeded
                                  - failed
                              failureCode:
                                nullable: true
                                type: string
                                enum:
                                  - debit_rejected
                              at:
                                nullable: true
                                type: string
                                format: date-time
                            required:
                              - status
                              - failureCode
                              - at
                            additionalProperties: false
                        required:
                          - status
                        additionalProperties: false
                      transactions:
                        description: >-
                          Transactions billed under this subscription. Included
                          on GET by id.
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              description: Public transaction id.
                            status:
                              type: string
                              description: Transaction status.
                            amount:
                              type: integer
                              minimum: 0
                              maximum: 100000000
                              description: Transaction amount in cents.
                            paidAmount:
                              type: integer
                              minimum: 0
                              maximum: 100000000
                              description: Amount paid in cents.
                            refundedAmount:
                              type: integer
                              minimum: 0
                              maximum: 100000000
                              description: Amount refunded in cents.
                            currency:
                              type: string
                              enum:
                                - BRL
                                - MXN
                                - COP
                                - CLP
                                - ARS
                                - PEN
                                - USD
                                - GTQ
                                - CRC
                                - NIO
                                - PYG
                                - UYU
                                - BOB
                                - PHP
                                - RUB
                                - INR
                                - SAR
                                - AED
                                - KWD
                                - QAR
                                - OMR
                                - KHR
                                - SGD
                                - IDR
                                - KRW
                                - THB
                                - MYR
                                - HKD
                                - CNY
                                - EGP
                                - EUR
                                - GBP
                                - BHD
                                - MAD
                                - AUD
                                - CAD
                                - CHF
                                - NZD
                                - PLN
                                - KZT
                                - UZS
                                - JPY
                                - GLC
                              description: Transaction currency.
                            externalRef:
                              nullable: true
                              description: External reference, when provided.
                              type: string
                            createdAt:
                              description: Transaction creation timestamp.
                              type: string
                              format: date-time
                            paidAt:
                              nullable: true
                              description: Payment confirmation timestamp.
                              type: string
                              format: date-time
                          required:
                            - id
                            - status
                            - amount
                            - paidAmount
                            - refundedAmount
                            - currency
                            - externalRef
                            - createdAt
                            - paidAt
                          additionalProperties: false
                      createdAt:
                        description: Subscription creation timestamp.
                        type: string
                        format: date-time
                      updatedAt:
                        nullable: true
                        description: Last update timestamp.
                        type: string
                        format: date-time
                    required:
                      - id
                      - customerId
                      - status
                      - paymentMethod
                      - billingModel
                      - billingDayOfMonth
                      - interval
                      - intervalCount
                      - amount
                      - currency
                      - trialEnd
                      - currentPeriodStart
                      - currentPeriodEnd
                      - cancelAtPeriodEnd
                      - canceledAt
                      - failurePolicy
                      - retryOffsetsDays
                      - cancellationReason
                      - customerEmail
                      - cardLast4
                      - metadata
                      - informations
                      - products
                      - recurringAuthorization
                      - createdAt
                      - updatedAt
                    additionalProperties: false
                required:
                  - success
                  - requestId
                  - data
                additionalProperties: false
              example:
                success: true
                requestId: 0190a2b4-18a7-7de0-9a43-69b7cf261201
                data:
                  id: string
                  customerId: string
                  status: incomplete
                  paymentMethod: credit_card
                  billingModel: merchant_initiated
                  billingDayOfMonth: 1
                  interval: day
                  intervalCount: 1
                  amount: 0
                  currency: BRL
                  trialEnd: '2026-07-14T12:00:00.000Z'
                  currentPeriodStart: '2026-07-14T12:00:00.000Z'
                  currentPeriodEnd: '2026-07-14T12:00:00.000Z'
                  cancelAtPeriodEnd: false
                  canceledAt: '2026-07-14T12:00:00.000Z'
                  failurePolicy: immediate_cancel
                  retryOffsetsDays:
                    - 1
                  cancellationReason: user_requested
                  customerEmail: string
                  cardLast4: string
                  metadata: {}
                  informations:
                    - key: string
                      value: string
                  products:
                    - name: string
                      price: 0
                      quantity: 1
                      tangible: false
                  recurringAuthorization:
                    status: pending
                  createdAt: '2026-07-14T12:00:00.000Z'
                  updatedAt: '2026-07-14T12:00:00.000Z'
        '404':
          description: HTTP 404 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    description: URI reference identifying the problem type.
                    type: string
                  title:
                    type: string
                    description: Short, human-readable summary of the problem.
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code.
                  detail:
                    description: Human-readable explanation specific to this occurrence.
                    type: string
                  instance:
                    description: URI reference identifying the specific occurrence.
                    type: string
                required:
                  - title
                  - status
                additionalProperties: {}
        '409':
          description: HTTP 409 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    description: URI reference identifying the problem type.
                    type: string
                  title:
                    type: string
                    description: Short, human-readable summary of the problem.
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code.
                  detail:
                    description: Human-readable explanation specific to this occurrence.
                    type: string
                  instance:
                    description: URI reference identifying the specific occurrence.
                    type: string
                required:
                  - title
                  - status
                additionalProperties: {}
        '422':
          description: Validation error (RFC 7807)
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ValidationProblemDetails'
        default:
          description: RFC 7807 Problem Details error response
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
        - BasicAuth: []
components:
  schemas:
    ValidationProblemDetails:
      allOf:
        - $ref: '#/components/schemas/ProblemDetails'
        - type: object
          properties:
            errors:
              type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                  message:
                    type: string
                  code:
                    type: string
                additionalProperties: true
          additionalProperties: true
    ProblemDetails:
      type: object
      description: RFC 7807 Problem Details object.
      properties:
        type:
          type: string
          format: uri-reference
        title:
          type: string
        status:
          type: number
        detail:
          type: string
        instance:
          type: string
          format: uri-reference
      required:
        - type
        - title
        - status
        - detail
      additionalProperties: true
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
    ApiKeyAuth:
      type: apiKey
      in: header
      name: apiKey
    BasicAuth:
      type: http
      scheme: basic
      description: Use Basic auth with username `token` and password `x`.

````