Integrate your CMS with Pelcro

Learn how to integrate your CMS with the Pelcro Open API

Connect your CMS to Pelcro by loading the Open API site configuration, authenticating customers, and sending customer tokens for protected customer flows.

Prerequisites

  1. Get your site_id from your Pelcro site settings.
  2. Use the Open API base URL: https://www.pelcro.com/api/v1/sdk.
  3. Send Accept: application/json with each request.

Integration flow

  1. Get the site configuration. Call GET /site with your site_id before rendering customer-facing flows.
  2. Read enabled features and settings. Use the returned Site object to determine available products, paywalls, design settings, payment gateway settings, and enabled features.
  3. Authenticate the customer. Use an authentication endpoint, such as Register or Login, to retrieve a customer resource.
  4. Store the customer token. Use data.auth_token or data.token from the customer resource as the bearer token for protected endpoints.
  5. 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 products to display purchasable products and plans.
  • Use paywalls to apply access rules for protected content.
  • Use design_settings to 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, and ecommerce_enabled to enable or hide customer flows.

Display 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 / month

Authenticate 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.