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

# Cancel a policy request

> Cancels a policy request that is still waiting for decisions, and its subject with it — the payment or transfer request is cancelled, the spend review declined.

The request's requester and organization admins can cancel it. Every open approval step becomes `CANCELED` and the request `CANCELED`; Portão 3 then cancels the subject. If that last step fails, the request still ends `CANCELED` and nothing retries it — read the subject to confirm its status. Cancelling a request that is already `CANCELED` succeeds again and changes nothing; an approved, denied or expired request can't be cancelled. Send no body.

To cancel a payment that is waiting for approval, you can also cancel the payment itself — its policy request is cancelled with it.


## OpenAPI

````yaml /api-reference/ruleengine.openapi.json post /realms/{realmId}/organizations/{organizationId}/policy-requests/{policyRequestId}/cancel
openapi: 3.0.3
info:
  title: Ruleengine
  version: 1.0.0
  description: >-
    Portão 3 ruleengine API. Every endpoint requires a bearer token in the
    Authorization header (Authorization: Bearer <token>) unless its page states
    otherwise; see the Authentication guide. That requirement is not repeated
    per endpoint. Generated by tools/openapi from code (routes + security) and
    the hand-written spec (request/response bodies). Confidence tiers:
    generated:typed=23 copied:manual=0 unknown=0.
servers:
  - url: https://api.ruleengine.v2.portao3.com.br/
    description: production
  - url: https://api.ruleengine.dev.3pers.com.br/
    description: development
security: []
tags:
  - name: Business Policies
  - name: Policy Requests
paths:
  /realms/{realmId}/organizations/{organizationId}/policy-requests/{policyRequestId}/cancel:
    post:
      tags:
        - Policy Requests
      summary: Cancel a policy request
      description: >-
        Cancels a policy request that is still waiting for decisions, and its
        subject with it — the payment or transfer request is cancelled, the
        spend review declined.
      operationId: >-
        postRealmsByRealmIdOrganizationsByOrganizationIdPolicyRequestsByPolicyRequestIdCancel
      parameters:
        - name: realmId
          in: path
          required: true
          description: |-
            ID of your realm.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: f495ff0c-ab54-4f99-8e92-ca8682e4de9b
        - name: organizationId
          in: path
          required: true
          description: |-
            ID of the organization the policy request belongs to.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
        - name: policyRequestId
          in: path
          required: true
          description: >-
            ID of the policy request. A payment or transfer request sent for
            approval carries it as `policyRequestId`.


            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: 4d2c1b0a-9f8e-4d7c-8b6a-5f4e3d2c1b0a
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: ID of the policy request.
                    example: 4d2c1b0a-9f8e-4d7c-8b6a-5f4e3d2c1b0a
                    format: uuid
                  realmId:
                    type: string
                    description: ID of the realm the request belongs to.
                    example: f495ff0c-ab54-4f99-8e92-ca8682e4de9b
                    format: uuid
                  organizationId:
                    type: string
                    description: ID of the organization the request belongs to.
                    example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
                    format: uuid
                  accountId:
                    type: string
                    description: ID of the account that holds `walletId`.
                    example: 66f2a1c7b4d3e80012c9a0b4
                  walletId:
                    type: string
                    description: >-
                      ID of the subject's wallet — the paying wallet of a
                      payment, the transaction's wallet in a spend review.
                    example: 6710b8e4c9e77b0012a4d6f3
                  walletName:
                    type: string
                    description: >-
                      Name of the wallet when the request was opened. Absent on
                      older requests.
                    example: Marketing
                  cardName:
                    type: string
                    description: >-
                      Name of the card, for a reviewed card transaction. Absent
                      otherwise.
                    example: Cartão Marketing
                  context:
                    type: string
                    enum:
                      - PAYMENT
                      - SPEND_REVIEW
                      - TRAVEL
                    description: >-
                      Which policies govern the subject: `PAYMENT`,
                      `SPEND_REVIEW` or `TRAVEL`.
                    example: PAYMENT
                  subjectType:
                    type: string
                    description: >-
                      What is being approved: `PIX`, `BOLETO`,
                      `WALLET_TRANSFER_REQUEST` (a transfer request between
                      wallets) or `TRANSACTION` (a spend review).
                    example: PIX
                  subjectId:
                    type: string
                    description: >-
                      ID of the subject — the payment's `_id`, the transfer
                      request's or the transaction's ID.
                    example: 6726a4f1b4d3e80012c9a3f1
                  requester:
                    type: object
                    properties:
                      userId:
                        type: string
                        description: ID of the user who asked for the subject.
                        example: 9a1b2c3d-4e5f-4a6b-8c7d-0e1f2a3b4c5d
                      name:
                        type: string
                        description: The requester's full name when the request was opened.
                        example: Ana Souza
                      email:
                        type: string
                        description: The requester's e-mail when the request was opened.
                        example: ana.souza@example.com
                    required:
                      - userId
                      - name
                      - email
                    description: Who asked for the subject.
                  body:
                    type: object
                    additionalProperties: {}
                    description: >-
                      The subject as it was when the request was opened — what
                      the policies evaluated and what the approvers are
                      approving. A payment's approved amount and balance
                      category are in `confirmation`.


                      ---


                      Example: `{"amount":123000,"description":"Folders da
                      campanha de novembro","creditParty":{"name":"Gráfica
                      Aurora
                      Ltda"},"confirmation":{"amount":123000,"category":"FLEX_INTERNATIONAL"}}`
                    example:
                      amount: 123000
                      description: Folders da campanha de novembro
                      creditParty:
                        name: Gráfica Aurora Ltda
                      confirmation:
                        amount: 123000
                        category: FLEX_INTERNATIONAL
                  policyId:
                    type: string
                    description: ID of the business policy that required the approval.
                    example: 3f2e1d0c-9b8a-4c7d-8e6f-5a4b3c2d1e0f
                    format: uuid
                  status:
                    type: string
                    enum:
                      - REQUESTED
                      - APPROVED
                      - DENIED
                      - CANCELED
                      - EXPIRED
                    description: >-
                      Status of the request. `REQUESTED` — waiting for
                      decisions. `APPROVED` — every required approval was given
                      (or an admin force-approved it). `DENIED` — an approver or
                      an admin denied it. `CANCELED` — the requester, an admin
                      or Portão 3 cancelled it. `EXPIRED` — `approvalDeadline`
                      passed while it was waiting. Every status but `REQUESTED`
                      is final.
                    example: CANCELED
                  denialReason:
                    type: string
                    description: >-
                      The reason given by whoever denied the request. Only on a
                      `DENIED` request, and only when a reason was given.
                    example: Fora do orçamento do trimestre
                  resolution:
                    type: string
                    enum:
                      - AUTO
                    description: >-
                      `AUTO` when the policy approves on its own: the request
                      was created already `APPROVED`, with no approvers, to run
                      the policy's top-up. Absent on a request that went through
                      approvers.
                    example: AUTO
                  executionMode:
                    type: string
                    enum:
                      - MOVE_BALANCE_ONLY
                    description: >-
                      `MOVE_BALANCE_ONLY` when only the policy's top-up runs
                      after the approval and the subject is carried out
                      separately. Absent otherwise.
                    example: MOVE_BALANCE_ONLY
                  executionStatus:
                    type: string
                    enum:
                      - WAITING
                      - PROCESSING
                      - EXECUTED
                      - FAILED
                    description: >-
                      What happens after the approval: the policy's top-up, if
                      any, then the subject is carried out (the payment is
                      confirmed, the transfer request confirmed, the spend
                      review approved). `WAITING` — not started: a request that
                      is not approved stays `WAITING`, and an approved one goes
                      back to it while a temporary problem is retried.
                      `PROCESSING` — running. `EXECUTED` — done. `FAILED` —
                      stopped, with the reason in `executionFailReason`.
                    example: WAITING
                  executionFailReason:
                    type: string
                    description: >-
                      Why the execution failed, or why it is being retried — a
                      code such as `MOVE_BALANCE_SOURCE_MISSING` for a problem
                      detected before any money moved, otherwise the error of
                      the step that failed (up to 200 characters).
                    example: MOVE_BALANCE_SOURCE_MISSING
                  approvalDeadline:
                    type: string
                    description: >-
                      When the request expires if it is still waiting for
                      decisions. Set by whoever opened the request — for a Pix
                      or boleto payment, 21:00 (São Paulo time) of the day the
                      payment is for, and at least one hour after it was sent.
                    example: '2026-11-07T00:00:00.000Z'
                    format: date-time
                  executionMoveBalance:
                    type: object
                    properties:
                      addBalance:
                        type: boolean
                        description: >-
                          `true` when the policy tops up the subject's wallet
                          with the subject's amount, from the wallet below,
                          before the subject is carried out.
                        example: true
                      fromAccountId:
                        type: string
                        description: ID of the account the top-up is taken from.
                        example: 66f2a1c7b4d3e80012c9a0b4
                      fromWalletId:
                        type: string
                        description: ID of the wallet the top-up is taken from.
                        example: 66f2a1c7b4d3e80012c9a0b9
                    required:
                      - addBalance
                    description: >-
                      The top-up the matched policy runs after the approval.
                      Absent when it has none.
                  approvalHierarchy:
                    type: boolean
                    description: >-
                      `true` — the approval steps open one at a time, in order.
                      `false` — they are all open at once.
                    example: false
                  approvals:
                    type: array
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - USER
                            - GROUP
                          description: >-
                            `USER` — this one user decides. `GROUP` — any one
                            member of the group decides for it.
                          example: USER
                        id:
                          type: string
                          description: >-
                            ID of the user (`type: USER`) or of the group
                            (`type: GROUP`).
                          example: 0b6f2c1e-8d4a-4f3b-9a7e-5c2d1e0f9a8b
                        name:
                          type: string
                          description: >-
                            Name of the user or group when the request was
                            opened. An organization admin's force-approve or
                            force-deny adds a step of its own, named after the
                            admin.
                          example: Rafael Lima
                        status:
                          type: string
                          enum:
                            - WAITING
                            - REQUESTED
                            - APPROVED
                            - DENIED
                            - CANCELED
                          description: >-
                            Status of the step. `WAITING` — not open yet: with
                            `approvalHierarchy`, steps open one at a time, in
                            order. `REQUESTED` — waiting for a decision.
                            `APPROVED` / `DENIED` — decided. `CANCELED` — no
                            longer needed, because the request was denied,
                            cancelled, expired or decided by an admin.
                          example: CANCELED
                        users:
                          type: array
                          items:
                            type: object
                            properties:
                              userId:
                                type: string
                                description: ID of the user.
                                example: 0b6f2c1e-8d4a-4f3b-9a7e-5c2d1e0f9a8b
                              userName:
                                type: string
                                description: >-
                                  The user's full name when the request was
                                  opened; empty if they had none.
                                example: Rafael Lima
                              userEmail:
                                type: string
                                description: The user's e-mail when the request was opened.
                                example: rafael.lima@example.com
                              status:
                                type: string
                                enum:
                                  - WAITING
                                  - REQUESTED
                                  - APPROVED
                                  - DENIED
                                  - CANCELED
                                description: >-
                                  This user's own decision status. `REQUESTED`
                                  means their decision is awaited; `CANCELED`
                                  means they no longer need to decide — another
                                  member of the group decided first, or the
                                  request was closed.
                                example: CANCELED
                            required:
                              - userId
                              - userName
                              - userEmail
                              - status
                            description: One person who can decide an approval step.
                          description: >-
                            Who can decide this step — one entry for a user, one
                            per member for a group.
                        createdAt:
                          type: string
                          description: When the step was created.
                          example: '2026-11-06T13:42:10.512Z'
                          format: date-time
                        requestedAt:
                          type: string
                          description: >-
                            When the step opened for a decision. Absent while it
                            is `WAITING`.
                          example: '2026-11-06T13:42:10.512Z'
                          format: date-time
                        decisionAt:
                          type: string
                          description: When the step was decided.
                          example: '2026-11-06T15:03:44.207Z'
                          format: date-time
                        decisionReason:
                          type: string
                          description: The reason the decider gave, when they gave one.
                          example: Fora do orçamento do trimestre
                      required:
                        - type
                        - id
                        - name
                        - status
                        - users
                      description: >-
                        One approval step: a user or a group whose decision the
                        policy requires.
                    description: >-
                      The approval steps, in the policy's order. Empty on an
                      `AUTO` request.
                  fundingClaimedAt:
                    type: string
                    description: >-
                      When this request took charge of topping up the subject's
                      wallet — just before the top-up ran. Only on the one
                      request per subject that does it.
                    example: '2026-11-06T15:03:45.031Z'
                    format: date-time
                  fundedAt:
                    type: string
                    description: >-
                      When the top-up for this subject completed. Absent while
                      it has not completed, or when this request moved no money.
                    example: '2026-11-06T15:03:46.418Z'
                    format: date-time
                  fundingClaim:
                    type: boolean
                    description: >-
                      `true` on the one request per subject that took charge of
                      topping up its wallet. It is set before the top-up runs
                      and kept even if the top-up then fails, so it does not
                      mean the money moved — `fundedAt` does. Absent otherwise.
                    example: true
                  executionAttempts:
                    type: number
                    description: >-
                      How many times the execution was retried after a temporary
                      problem that happened before any money moved. Absent when
                      it was never retried.
                    example: 1
                  createdAt:
                    type: string
                    description: When the request was opened.
                    example: '2026-11-06T13:42:10.512Z'
                    format: date-time
                  updatedAt:
                    type: string
                    description: When the request last changed.
                    example: '2026-11-06T13:42:10.512Z'
                    format: date-time
                required:
                  - id
                  - realmId
                  - organizationId
                  - accountId
                  - walletId
                  - context
                  - subjectType
                  - subjectId
                  - requester
                  - body
                  - policyId
                  - status
                  - executionStatus
                  - approvalDeadline
                  - approvalHierarchy
                  - approvals
                  - createdAt
                  - updatedAt
                description: >-
                  A policy request: the approval request of a payment, a
                  transfer request or a reviewed transaction, waiting for the
                  decisions a business policy requires.
        '403':
          description: >-
            `POLICY_REQUEST_FORBIDDEN` — You are neither the request's requester
            nor an organization admin.


            `POLICY_REQUEST_EXPIRED` — The approval deadline passed while the
            request was waiting; it is now `EXPIRED`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - POLICY_REQUEST_FORBIDDEN
                      - POLICY_REQUEST_EXPIRED
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - RULE_ENGINE
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: POLICY_REQUEST_FORBIDDEN
                origin: RULE_ENGINE
                message: You do not have permission to perform this action
        '404':
          description: >-
            `POLICY_REQUEST_NOT_FOUND` — No policy request with this ID exists
            in the organization.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - POLICY_REQUEST_NOT_FOUND
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - RULE_ENGINE
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: POLICY_REQUEST_NOT_FOUND
                origin: RULE_ENGINE
                message: Policy request not found
        '409':
          description: >-
            `POLICY_REQUEST_NOT_CANCELABLE` — The request was already approved,
            denied or expired.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - POLICY_REQUEST_NOT_CANCELABLE
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - RULE_ENGINE
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: POLICY_REQUEST_NOT_CANCELABLE
                origin: RULE_ENGINE
                message: Policy request is not in a cancelable state
        '422':
          description: >-
            `BAD_REQUEST` — A path parameter is not a valid ID; `fields` lists
            each one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - BAD_REQUEST
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - RULE_ENGINE
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                  fields:
                    type: array
                    description: >-
                      One entry per invalid request field (validation errors
                      only).
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                          description: >-
                            Path of the invalid field, e.g. `label` or
                            `values[0].value`.
                          example: label
                        message:
                          type: string
                          description: Why the field was rejected.
                          example: label is required
                        code:
                          type: string
                          description: >-
                            `<FIELD>_<REASON>` — e.g. `LABEL_REQUIRED`,
                            `TYPE_ONE_OF`, `VALUES_VALUE_TYPE_ERROR`.
                          example: LABEL_REQUIRED
                        values:
                          type: array
                          items:
                            type: string
                          description: >-
                            The accepted values, when the field is an
                            enumeration.
                      required:
                        - field
                        - message
                        - code
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: BAD_REQUEST
                origin: RULE_ENGINE
                message: >-
                  Bad Request: Your request is invalid or incomplete. Please
                  make sure you are requesting with the right fields.
                fields:
                  - field: policyRequestId
                    message: Invalid UUID
                    code: POLICYREQUESTID_UUID

````

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