# Accept Crypto Subscriptions

**🚀 How It Works**

✅ **Step 1: Create a Product**

Every subscription plan is associated with a product. Create the product first using the following API request:

```bash
curl --request POST \
  --url https://api.copperx.dev/api/v1/products \
  --header 'Authorization: Bearer {API_KEY}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "name": "Pro Membership",
    "description": "Monthly plan for premium users",
    "isActive": true,
    "unitLabel": "month",
    "url": "https://example.com/product",
    "metadata": {
      "category": "SaaS"
    },
    "visibility": 10,
    "defaultPriceData": {
      "currency": "usdc",
      "unitAmount": 50000000,
      "interval": "month",
      "intervalCount": 1,
      "type": "recurring"
    }
  }'
```

The response will include a unique `productId`. Save this for the next step.

***

✅ **Step 2: Create a Subscription Checkout Session**

Using the created product’s ID, generate a checkout session to enable the user to subscribe:

```bash
curl --request POST \
  --url https://api.copperx.dev/api/v1/checkout/sessions \
  --header 'Authorization: Bearer {API_KEY}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "mode": "subscription",
    "lineItems": {
      "data": [
        {
          "priceData": {
            "currency": "usdc",
            "unitAmount": "50000000",
            "interval": "month",
            "productId": "{PRODUCT_ID}"
          }
        }
      ]
    },
    "successUrl": "https://yourapp.com/success?session_id={CHECKOUT_SESSION_ID}",
    "cancelUrl": "https://yourapp.com/cancel"
  }'
```

The API response will provide a hosted **checkout session URL**. Redirect your user to this URL to complete the subscription.

***

✅ **Step 3: Automate Recurring Billing**

Copperx’s smart contracts **automatically handle** the recurring charges based on the interval (`monthly`, `yearly`, etc.) and send blockchain-verified payment confirmations.

***

✅ **Step 4: Stay Updated with Webhooks**

Copperx sends **webhook events** for key actions:

* `customer.subscription.created`
* `customer.subscription.started`
* `customer.subscription.unpaid`

Use these events to manage access and provide real-time updates to your users.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.copperx.io/integrate-payments/accept-crypto-subscriptions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
