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

# Withdraw a trip's approval request

> Withdraws the approval request of a trip.

The request is canceled with the approvals service first, and the trip goes back to being reservable, so it can be sent for approval again or issued. Only an organization admin or the user who booked the trip, or sent it for approval, can withdraw it. A request that is still being created can't be withdrawn yet, and one that was already approved, denied or issued can't be withdrawn at all. The answer is `204 No Content` in every case that is not an error: read the trip to see where it is. Withdrawing a trip with no open request does nothing.


## OpenAPI

````yaml /api-reference/travel.openapi.json post /realms/{realmId}/organizations/{organizationId}/trips/{tripId}/request/cancel
openapi: 3.0.3
info:
  title: Travel
  version: 1.0.0
  description: >-
    Portão 3 travel 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). Passenger directory, trips
    and the search proxy (air/hotel/bus/vehicle). Every route validates path,
    query and body through a zod Input class (`travel/src/domain/*/input`),
    which documents its parameters and body; responses are the named interfaces
    in `travel/src/domain/*/response.ts`. Confidence tiers: generated:typed=57
    copied:manual=0 unknown=0.
servers:
  - url: https://api.travel.v2.portao3.com.br/
    description: production
  - url: https://api.travel.dev.3pers.com.br/
    description: development
security: []
tags:
  - name: Passengers
  - name: Trips
  - name: Air search
  - name: Hotel search
  - name: Bus search
  - name: Vehicle search
paths:
  /realms/{realmId}/organizations/{organizationId}/trips/{tripId}/request/cancel:
    post:
      tags:
        - Trips
      summary: Withdraw a trip's approval request
      description: Withdraws the approval request of a trip.
      operationId: >-
        postRealmsByRealmIdOrganizationsByOrganizationIdTripsByTripIdRequestCancel
      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 trip belongs to.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
        - name: tripId
          in: path
          required: true
          description: >-
            ID of the trip whose approval request is withdrawn (24 hexadecimal
            characters).
          schema:
            type: string
            pattern: ^[0-9a-fA-F]{24}$
          example: 6711b4c0d8e1a30012b7c9f2
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                policyRequestId:
                  description: >-
                    ID of the approval request that ended. Only the approval
                    service sends it; leave it out when you withdraw a request
                    yourself.


                    Format: `UUID`
                  example: b7f1c0d2-4e3a-4f8b-9c21-7a6d5e4f3b2a
                  type: string
                  format: uuid
      responses:
        '204':
          description: No Content. The operation succeeded and the response has no body.
        '403':
          description: >-
            `TRAVEL_REQUESTER_OR_ADMIN_REQUIRED` — You can see the trip but you
            are neither an organization admin nor the user who booked it or sent
            it for approval.


            `TRIP_CALLER_FORBIDDEN` — This caller can't withdraw an approval
            request.
          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:
                      - TRAVEL_REQUESTER_OR_ADMIN_REQUIRED
                      - TRIP_CALLER_FORBIDDEN
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - TRAVEL
                    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: TRAVEL_REQUESTER_OR_ADMIN_REQUIRED
                origin: TRAVEL
                message: >-
                  Organization admin or the user who requested the approval
                  required
        '404':
          description: >-
            `TRIP_NOT_FOUND` — No trip with this ID is visible to you in the
            organization: it doesn't exist, belongs to another organization, or
            you are neither an organization admin, a passenger on it nor the
            user who booked it.
          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:
                      - TRIP_NOT_FOUND
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - TRAVEL
                    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: TRIP_NOT_FOUND
                origin: TRAVEL
                message: Trip not found
        '409':
          description: >-
            `TRIP_REQUEST_IN_PROGRESS` — The approval request is still being
            created. Try again in a moment.


            `TRIP_APPROVAL_ALREADY_RESOLVED` — The request was already approved,
            denied or issued, so it can't be withdrawn.
          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:
                      - TRIP_REQUEST_IN_PROGRESS
                      - TRIP_APPROVAL_ALREADY_RESOLVED
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - TRAVEL
                    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: TRIP_REQUEST_IN_PROGRESS
                origin: TRAVEL
                message: The approval request is still being created; try again shortly
        '422':
          description: >-
            `BAD_REQUEST` — A path parameter is not a valid ID or the body
            failed validation; `fields` lists each offending field.
          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:
                      - TRAVEL
                    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: TRAVEL
                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
        '503':
          description: >-
            `POLICY_EVALUATION_UNAVAILABLE` — The approvals service could not be
            reached, so the request was not withdrawn. Retry later.
          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_EVALUATION_UNAVAILABLE
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - TRAVEL
                    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_EVALUATION_UNAVAILABLE
                origin: TRAVEL
                message: >-
                  Business policy evaluation temporarily unavailable, please
                  retry.

````

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