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

# Purchase Product

POST https://api.customerhub.com/web_api/products/{id}/purchase

Get a Stripe checkout URL for purchasing a product. Redirects the user to Stripe to complete payment.

**Authentication:** Public with visitor fallback.

**Feature gate:** Requires `products` feature enabled.

**Path parameters:**
- `id` (required) — The PaymentLink ID (not the product ID)

**Response:**
- `redirect_to` — Stripe checkout session URL

**Notes:** The checkout URL is pre-filled with the user's email and includes a `client_reference_id` for tracking.

**Errors:**
- `404` — Payment link not found

Reference: https://customerhub.com/api/api-reference/products-library/purchase-product

## Request

### Path parameters

- `id` (string, required) — PaymentLink ID

## Response

### 200

OK

## Examples

**Response**

```json
{
  "data": {
    "redirect_to": "https://checkout.stripe.com/c/pay/..."
  }
}
```

**SDK Code**

```python Products & Library_purchaseProduct_example
import requests

url = "https://api.customerhub.com/web_api/products/id/purchase"

response = requests.post(url)

print(response.json())
```

```javascript Products & Library_purchaseProduct_example
const url = 'https://api.customerhub.com/web_api/products/id/purchase';
const options = {method: 'POST'};

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

```go Products & Library_purchaseProduct_example
package main

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

func main() {

	url := "https://api.customerhub.com/web_api/products/id/purchase"

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

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

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

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

}
```

```ruby Products & Library_purchaseProduct_example
require 'uri'
require 'net/http'

url = URI("https://api.customerhub.com/web_api/products/id/purchase")

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

request = Net::HTTP::Post.new(url)

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

```java Products & Library_purchaseProduct_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.customerhub.com/web_api/products/id/purchase")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.customerhub.com/web_api/products/id/purchase');

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

```csharp Products & Library_purchaseProduct_example
using RestSharp;

var client = new RestClient("https://api.customerhub.com/web_api/products/id/purchase");
var request = new RestRequest(Method.POST);
IRestResponse response = client.Execute(request);
```

```swift Products & Library_purchaseProduct_example
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.customerhub.com/web_api/products/id/purchase")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"

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()
```