Load your Pelcro Open API site configuration, authenticate customers, and send customer tokens so your website can run protected customer flows.
Prerequisites
- Get your
site_idfrom your Pelcro site settings. - Use the Open API base URL:
https://www.pelcro.com/api/v1/sdk. - Send
Accept: application/jsonwith each request.
Integration flow
- Get the site configuration. Call
GET /sitewith yoursite_idbefore rendering customer-facing flows. - Read enabled features and settings. Use the returned Site object to determine available products, paywalls, design settings, payment gateway settings, and enabled features.
- Authenticate the customer. Use an authentication endpoint, such as Register or Login, to retrieve a customer resource.
- Store the customer token. Use
data.auth_tokenordata.tokenfrom the customer resource as the bearer token for protected endpoints. - Call protected endpoints. Use the token for customer actions such as creating subscriptions, managing payment methods, updating addresses, or placing e-commerce orders.
Get site configuration
Call the Site configuration endpoint first so your website knows which products, paywalls, payment gateway settings, and feature flags are available.
curl --request GET \
--url "https://www.pelcro.com/api/v1/sdk/site?site_id=123" \
--header "Accept: application/json"Example response
The response contains a Site resource, including general site settings, enabled features, products available for purchase online, paywalls, design settings, and payment gateway settings.
{
"data": {
"account": "12345",
"name": "Example Publication",
"link": "https://example.com",
"default_currency": "usd",
"default_locale": "en_US",
"ecommerce_enabled": true,
"passwordless_enabled": false,
"email_verify_enabled": true,
"taxes_enabled": false,
"tax_inclusive": false,
"logo": [],
"products": [],
"paywalls": [],
"design_settings": [],
"braintree_tokenization": null,
"braintree_currency": null,
"vantiv_gateway_settings": [],
"tap_gateway_settings": [],
"cybersource_gateway_settings": []
},
"status": "success"
}Use the configuration in your website
After loading the Site object, use it to decide which flows to show:
- Use
productsto display purchasable products and plans. - Use
paywallsto apply access rules for protected content. - Use
design_settingsto align the customer experience with your configured UI. - Use payment gateway settings when collecting payment methods.
- Use feature flags such as
passwordless_enabled,email_verify_enabled, andecommerce_enabledto enable or hide customer flows.
Retrieve products and plans
The Site configuration response includes products, and each product can include a nested plans array. Use this data to render subscription products, plan names, prices, trial details, entitlements, and paywall tags without making another request.
For example, a product in data.products can include this shape:
{
"id": 690,
"address_required": true,
"description": "Try 2 weeks free, then only $9.95 / month",
"entitlements": ["premium1"],
"name": "Premium Digital Free Trial",
"image": "https://uploads.pelcro.com/images/site/product/image/690-1752601241.png",
"plans": [
{
"id": 4081,
"product_id": 690,
"amount": 995,
"amount_formatted": "$9.95",
"currency": "usd",
"interval": "month",
"interval_count": 1,
"auto_renew": true,
"trial_period_days": 14,
"nickname": "2 Week Free Trial, then $9.95/month",
"description": "2 Week Free Trial, then $9.95 per month",
"entitlements": ["premium1"],
"type": "regular"
}
],
"paywall": {
"id": 286,
"product_id": 690,
"frequency_limit": 2,
"meter_title": "Subscribe today for unlimited access to best practices, insights, and solutions.",
"tags": "premium1",
"auto_trigger": true
}
}Use data.products to build the product list and flatten each product's plans array when you need plan-level purchase options:
const SITE_ID = 123;
async function getAvailableProductsAndPlans() {
const response = await fetch(
`https://www.pelcro.com/api/v1/sdk/site?site_id=${SITE_ID}`,
{
method: 'GET',
headers: {
Accept: 'application/json',
},
}
);
const payload = await response.json();
if (!response.ok) {
throw new Error(payload?.error?.message || 'Unable to load site configuration.');
}
const products = payload.data.products || [];
return products.map((product) => ({
id: product.id,
name: product.name,
description: product.description,
image: product.image,
addressRequired: product.address_required,
entitlements: product.entitlements || [],
paywallTags: product.paywall?.tags || null,
plans: (product.plans || []).map((plan) => ({
id: plan.id,
productId: plan.product_id,
name: plan.nickname,
description: plan.description,
price: plan.amount_formatted,
currency: plan.currency,
interval: plan.interval,
intervalCount: plan.interval_count,
trialPeriodDays: plan.trial_period_days,
autoRenew: plan.auto_renew,
entitlements: plan.entitlements || [],
type: plan.type,
})),
}));
}
getAvailableProductsAndPlans()
.then((products) => {
for (const product of products) {
console.log(product.name);
for (const plan of product.plans) {
console.log(`- ${plan.name}: ${plan.price} / ${plan.interval}`);
}
}
})
.catch((error) => {
console.error(error.message);
});Expected output for the example product:
Premium Digital Free Trial
- 2 Week Free Trial, then $9.95/month: $9.95 / monthAuthenticate customers
Use the authentication endpoints to register or log in a customer. Successful authentication returns a customer resource with data.auth_token and data.token.
Send that token in the Authorization header when calling protected Open API endpoints:
curl --request POST \
--url "https://www.pelcro.com/api/v1/sdk/customer?site_id=123" \
--header "Accept: application/json" \
--header "Authorization: Bearer eyJ0xxx"Next steps
- Review the Site resource for the full site configuration shape.
- Review Authentication to learn how to send customer tokens.
- Use the Site configuration response before building subscription, payment method, newsletter, and e-commerce flows.
