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

# Customer Cancel Subscription

PATCH https://api-sandbox.coinflow.cash/api/subscription/{merchantId}/subscribers/{subscriptionId}

Cancel a subscription (by customer)

Reference: https://docs.coinflow.cash/api-reference/api-reference/subscription/cancel-customer-subscription

## Authentication

- `x-coinflow-auth-session-key` header (required) — The session key generated for the end user - see https://docs.coinflow.cash/api-reference/api-reference/authentication/get-session-key
- `Authorization` header (required) — The API key of the merchant - see https://docs.coinflow.cash/api-reference/api-reference/authentication/get-session-key
- `x-coinflow-auth-wallet` header (required) — The web3 wallet of the end user - see https://docs.coinflow.cash/api-reference/api-reference/authentication/get-session-key
- `x-coinflow-auth-blockchain` header (required) — The blockchain associated with the end user - see https://docs.coinflow.cash/api-reference/api-reference/authentication/get-session-key

## Request

### Path parameters

- `merchantId` (string, required)
- `subscriptionId` (string, required)

## Examples

**SDK Code**

```python
import requests

url = "https://api-sandbox.coinflow.cash/api/subscription/merchantId/subscribers/subscriptionId"

headers = {"x-coinflow-auth-session-key": "<apiKey>"}

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

print(response.json())
```

```javascript
const url = 'https://api-sandbox.coinflow.cash/api/subscription/merchantId/subscribers/subscriptionId';
const options = {method: 'PATCH', headers: {'x-coinflow-auth-session-key': '<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://api-sandbox.coinflow.cash/api/subscription/merchantId/subscribers/subscriptionId"

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

	req.Header.Add("x-coinflow-auth-session-key", "<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://api-sandbox.coinflow.cash/api/subscription/merchantId/subscribers/subscriptionId")

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

request = Net::HTTP::Patch.new(url)
request["x-coinflow-auth-session-key"] = '<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://api-sandbox.coinflow.cash/api/subscription/merchantId/subscribers/subscriptionId")
  .header("x-coinflow-auth-session-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api-sandbox.coinflow.cash/api/subscription/merchantId/subscribers/subscriptionId', [
  'headers' => [
    'x-coinflow-auth-session-key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api-sandbox.coinflow.cash/api/subscription/merchantId/subscribers/subscriptionId");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-coinflow-auth-session-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["x-coinflow-auth-session-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.coinflow.cash/api/subscription/merchantId/subscribers/subscriptionId")! 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()
```