> This page is for Financial Rider Flow.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://infonite.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://infonite.dev/_mcp/server.

# Cancel Session

PATCH https://widgets.infonite.tech/api/flows/financial-rider/v1/manager/{session_id}/cancel

Close an open session from your side: the experience stops, and any connection still running is stopped too.

**Key technical details:**

* **No request body.** The cancellation is recorded as yours (`CLIENT_CANCELLED`).
* **Idempotency (`304`).** A session already finished is left as it is.
* **Concurrency lock (`504`).** The cancellation holds the session; if it cannot within a few seconds, retry.

If at least one bank had already been connected when you cancelled, the session ends with `status_code: COMPLETED` and **its data is delivered**: read it from [Get Session Results](https://infonite.dev/flows/financial-rider/api-reference/financial-rider-api/sessions-results/flows-financial-rider-v-1-session-results), and it travels in the end event like any finished session. The session also carries a `cancelled_with_products` warning, so the outcome stays explainable.

`CLIENT_CANCELLED` is recorded only when nothing had been connected.

That data came from a real sign-in your customer consented to: cancelling gives up the banks that were not connected yet, not the ones that were.

> This endpoint needs to be executed with an app secret, so should always be used in server side without exposing the secret to customers.

Reference: https://infonite.dev/flows/financial-rider/api-reference/financial-rider-api/sessions-management/flows-financial-rider-v-1-session-cancel

## Authentication

- `X-APP-SECRET` header (required) — Application Secret

## Servers

- `https://widgets.infonite.tech/api/flows` (Legacy, default)
- `https://widgets.infonite.io/api/flows` (Production)

## Request

### Path parameters

- `session_id` (string, required) — The session, as its creation returned it

## Response

### 204

**204 No Content**Cancelled Successfully

## Errors

### 401 Unauthorized Error

**401 Unauthorized**The application secret was not accepted

- `detail` (string, required) — Error message

### 403 Forbidden Error

**403 Forbidden**The application may not act

- `detail` (string, required) — Error message

### 404 Not Found Error

**404 Not Found**Session not found

- `detail` (string, required) — Error message

### 422 Unprocessable Entity Error

**422 Unprocessable Content**The session id in the path is not one

- `detail` (list of ValidationError, required)

### 429 Too Many Requests Error

**429 Too Many Requests**Too many requests. Rate limit exceeded.

- `detail` (string, required) — Error message

### 504 Gateway Timeout Error

**504 Gateway Timeout**Lock timeout, retry again

- `detail` (string, required) — Error message

## Types

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `input` (any, optional)
- `ctx` (ValidationErrorCtx, optional)

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

**SDK Code**

```python
import requests

url = "https://widgets.infonite.tech/api/flows/financial-rider/v1/manager/644599da47847b79c03cc94f/cancel"

headers = {"X-APP-SECRET": "<apiKey>"}

response = requests.patch(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://widgets.infonite.tech/api/flows/financial-rider/v1/manager/644599da47847b79c03cc94f/cancel';
const options = {method: 'PATCH', headers: {'X-APP-SECRET': '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://widgets.infonite.tech/api/flows/financial-rider/v1/manager/644599da47847b79c03cc94f/cancel"

	req, _ := http.NewRequest("PATCH", url, nil)

	req.Header.Add("X-APP-SECRET", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://widgets.infonite.tech/api/flows/financial-rider/v1/manager/644599da47847b79c03cc94f/cancel")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["X-APP-SECRET"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://widgets.infonite.tech/api/flows/financial-rider/v1/manager/644599da47847b79c03cc94f/cancel")
  .header("X-APP-SECRET", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://widgets.infonite.tech/api/flows/financial-rider/v1/manager/644599da47847b79c03cc94f/cancel', [
  'headers' => [
    'X-APP-SECRET' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://widgets.infonite.tech/api/flows/financial-rider/v1/manager/644599da47847b79c03cc94f/cancel");
var request = new RestRequest(Method.PATCH);
request.AddHeader("X-APP-SECRET", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["X-APP-SECRET": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://widgets.infonite.tech/api/flows/financial-rider/v1/manager/644599da47847b79c03cc94f/cancel")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```