On this page
No Headings
Last updated: June 16, 2026
Integrate subscriptions to bill customers at regular intervals.
Note: You can also create and manage subscriptions directly in your PayPal business account.
To create a product for your subscription plan, copy and modify the following code:
API endpoint used: Create product
curl -v -X POST https://api-m.sandbox.paypal.com/v1/catalogs/products
-H "Content-Type: application/json" -H "Authorization: Bearer ACCESS-TOKEN" -H "PayPal-Request-Id: REQUEST-ID" -d '{
"name": "Video Streaming Service",
"description": "A video streaming service",
"type": "SERVICE",
"category": "SOFTWARE",
"image_url": "https://example.com/streaming.jpg",
"home_url": "https://example.com/home"
}'After you copy the code in the sample request, modify the following:
ACCESS-TOKEN to your access token.REQUEST-ID with a unique ID that you generate. This ID helps prevent duplicate requests if the API call is disrupted.name and description to represent your product.A successful request results in the following:
201 Created.id for the product. Use this ID to complete other actions through the REST API, such as creating a subscription plan.{
"id": "PROD-5FD60555F23244316",
"name": "Video Streaming Service",
"description": "A video streaming service",
"create_time": "2023-01-21T16:04:39Z",
"links": [
{
"href": "https://api-m.sandbox.paypal.com/v1/catalogs/products/PROD-5FD60555F23244316",
"rel": "self",
"method": "GET"
},
{
"href": "https://api-m.sandbox.paypal.com/v1/catalogs/products/PROD-5FD60555F23244316",
"rel": "edit",
"method": "PATCH"
}
]
}The following sample request is an example of a subscription plan. Modify the code to fit your subscription model.
Review the following topics to help understand how to modify the code for your use case:
This sample request creates a subscription plan that:
Important: Only one currency_code is allowed per subscription plan. Make a new subscription plan to offer a subscription in another currency.
API endpoint used: Create plan
curl -v -k -X POST https://api-m.sandbox.paypal.com/v1/billing/plans -H "Accept: application/json" -H "Authorization: Bearer ACCESS-TOKEN" -H "Content-Type: application/json" -H "PayPal-Request-Id: REQUEST-ID" -d '{
"product_id": "PROD-5FD60555F23244316",
"name": "Basic Plan",
"description": "Basic plan",
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "TRIAL",
"sequence": 1,
"total_cycles": 1
},
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 2,
"total_cycles": 12,
"pricing_scheme": {
"fixed_price": {
"value": "10",
"currency_code": "USD"
}
}
}
],
"payment_preferences": {
"auto_bill_outstanding": true,
"setup_fee": {
"value": "10",
"currency_code": "USD"
},
"setup_fee_failure_action": "CONTINUE",
"payment_failure_threshold": 3
},
"taxes": {
"percentage": "10",
"inclusive": false
}
}'After you copy the code in the sample request, modify the following:
ACCESS-TOKEN to your access token.REQUEST-ID with a unique ID that you generate. This ID helps prevent duplicate requests if the API call is disrupted.product_id parameter to the ID returned when you created the product.A successful request results in the following:
201 Created.id for the subscription plan. Use the subscription plan ID to complete other actions through the REST API, such as editing or deactivating the plan.On status.To see how this API call looks in the seller's account, use your sandbox business account credentials to log in to https://www.sandbox.paypal.com/billing/plans. The subscription plan reflects the plan number from the REST API call you made.
{
"id": "P-17M15335A8501272JLXLLNKI",
"product_id": "PROD-5FD60555F23244316",
"name": "Basic Plan",
"status": "ACTIVE",
"description": "Basic plan",
"create_time": "2023-01-21T16:09:13Z",
"links": [
{
"href": "https://api-m.sandbox.paypal.com/v1/billing/plans/P-17M15335A8501272JLXLLNKI",
"rel": "self",
"method": "GET"
},
{
"href": "https://api-m.sandbox.paypal.com/v1/billing/plans/P-17M15335A8501272JLXLLNKI",
"rel": "edit",
"method": "PATCH"
},
{
"href": "https://api-m.sandbox.paypal.com/v1/billing/plans/P-17M15335A8501272JLXLLNKI/deactivate",
"rel": "self",
"method": "POST"
}
]
}To start a subscription from your website, add the PayPal JavaScript SDK code and modify it. This code adds buttons to your website so your buyers can use PayPal or a debit or credit card.
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Ensures optimal rendering on mobile devices. -->
</head>
<body>
<script src="https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID&vault=true&intent=subscription">
</script> // Add your client_id
<div id="paypal-button-container"></div>
<script>
paypal.Buttons({
createSubscription: function(data, actions) {
return actions.subscription.create({
'plan_id': 'YOUR_PLAN_ID' // Creates the subscription
});
},
onApprove: function(data, actions) {
alert('You have successfully subscribed to ' + data.subscriptionID); // Optional message given to subscriber
}
}).render('#paypal-button-container'); // Renders the PayPal button
</script>
</body>
</html>YOUR_CLIENT_ID to your client ID.YOUR_PLAN_ID to the plan ID returned from the Create Plan API call.
Tip: To render more than one button on a single webpage, see Multiple subscribe buttons for your website.
Test a transaction to see the subscription created in the merchant account:
Select the PayPal button on the page.
Use the sandbox personal login information from the Developer Dashboard to log in and simulate the buyer making a purchase.
In the Checkout window, make a note of the purchase amount in the upper right corner. USD is the default currency. You can customize the JavaScript SDK by adding a different currency code.
Availability: The JavaScript SDK onShippingChange, onShippingAddressChange, and onShippingOptionsChange functions are not compatible with Subscriptions.
Select the arrow next to the purchase amount to view the subscription details: