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

# Cancel Active Session

<Note>
  This endpoint is not yet released. It will be available soon.
</Note>

Immediately terminate an active e-Transfer session to prevent further user access or resumption.

To successfully call this endpoint, you must have a valid access token from the [/Authorize](/api/pay/endpoints/authorize/authorize) endpoint.

## Cancel Active Session

Use this endpoint to immediately close an active session so the user can no longer access or resume the e-Transfer flow. This is useful when a user abandons the flow in your application and you want to ensure the session cannot be reused.

### When to Use This Endpoint

* User abandons the payment flow in your application
* Need to prevent session reuse for security reasons
* Want to clean up active sessions before their natural timeout
* Implementing session cleanup workflows

### Session Termination Behavior

When you call this endpoint with a valid sessionId:

* **Immediate termination**: The session is terminated immediately
* **Frontend handling**: The hosted front-end will behave as if the session has timed out and display an appropriate error state
* **Status change**: Session status changes to `Cancelled`

## Implementation Notes

**Recommended but not required**:

* If you do not call this endpoint, sessions will automatically expire based on the timeout window defined during onboarding
* If you want to end a session before that timeout, you must call this endpoint

<RequestExample>
  ```bash cURL theme={null}
  curl --location --request POST '{{BaseUri}}/api/v2/sessions/{{sessionId}}/cancel' \
  --header 'Authorization: Bearer {{access_token}}'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - OK theme={null}
  {
    "sessionId": "aadd08f2-83ce-456d-84ed-c68cfed4ee7b",
    "referenceId": "USER12345",
    "status": "Cancelled"
  }
  ```

  ```json 400 - Bad Request theme={null}
  {
    "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
    "title": "Bad Request",
    "status": 400,
    "detail": "Session cannot be Cancelled"
  }
  ```

  ```json 401 - Unauthorized theme={null}
  {
    "type": "https://tools.ietf.org/html/rfc7235#section-3.1",
    "title": "Unauthorized",
    "status": 401,
    "detail": "Valid access token required"
  }
  ```
</ResponseExample>

## Response Fields

* **sessionId** — unique session identifier for the terminated session
* **referenceId** — your internal reference ID (if provided during session creation)
* **status** — session status (always `Cancelled` for successful cancellation)
* **statusDetails** — additional status context indicating the session was cancelled by API request

## Best Practices

### Session Cleanup

* Call this endpoint when users navigate away from the payment flow
* Implement cleanup for abandoned sessions in your application
* Consider batch cleanup for old active sessions

### Error Handling

* Handle cases where the session is already terminated
* Implement retry logic for transient network failures
* Log cancellation events for audit purposes

## Related Endpoints

* [Initiate Session](/api/pay/endpoints/e-transfer/sessions-initiate) — create an e-Transfer session
* [Session Details](/api/pay/endpoints/e-transfer/sessions-details) — retrieve full session information
* [/Authorize](/api/pay/endpoints/authorize/authorize) — obtain an access token


## OpenAPI

````yaml /pay-interac.yaml POST /api/v2/sessions/{sessionId}/cancel
openapi: 3.0.1
info:
  title: Flinks Interac API
  description: Flinks E-Transfer (RFM) API.
  version: v2
servers: []
security: []
paths:
  /api/v2/sessions/{sessionId}/cancel:
    post:
      tags:
        - Sessions
      operationId: CancelSession
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: x-client-id
          in: header
          schema:
            type: string
      responses:
        '200':
          description: Success
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/CancelSessionSetupResponse'
            application/json:
              schema:
                $ref: '#/components/schemas/CancelSessionSetupResponse'
            text/json:
              schema:
                $ref: '#/components/schemas/CancelSessionSetupResponse'
        '400':
          description: Bad Request
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            text/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '401':
          description: Unauthorized
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            text/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
components:
  schemas:
    CancelSessionSetupResponse:
      type: object
      properties:
        sessionId:
          type: string
          format: uuid
        referenceId:
          type: string
          nullable: true
        status:
          $ref: '#/components/schemas/SessionStatus'
        statusDetails:
          type: string
          nullable: true
      additionalProperties: false
    ProblemDetails:
      type: object
      properties:
        type:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        status:
          type: integer
          format: int32
          nullable: true
        detail:
          type: string
          nullable: true
        instance:
          type: string
          nullable: true
      additionalProperties: {}
    SessionStatus:
      enum:
        - Initiated
        - Failed
        - Cancelled
        - Expired
        - Completed
      type: string

````