Skip to content

Create a Recurring Charge ​

Last updated View as Markdown

Creates a subscription charge for your application. The merchant approves the charge once. YouCan renews it automatically at each billing interval.

Endpoint: https://api.youcan.shop/billing/apps/charges/recurring

Method: POST

Tip

Raw amounts work without any catalog. For your standard tiers, prefer referencing a pricing plan by handle, so your listing and your charges cannot drift apart.

Parameters ​

ParameterTypeRequiredValidationDescription
namestringYesmax:255Display name shown to the merchant on the confirmation page.
return_urlstringYesurl, max:2048URL to redirect the merchant to after they approve or decline. If it has the scheme, host and port of your app URL, the merchant returns to your app inside the admin, with the signed session parameters. Otherwise the merchant is redirected to it with no parameters added.
trial_daysintegerNomin:0, max:90Number of free trial days before the first charge. Defaults to 0. A store gets one trial per app. If the store had a trial for your app before, the trial is ignored. If the store changes plan during a trial, the store pays for the new plan only when the current trial ends.
plansarrayYesmin:1, max:1Array of pricing plans. Currently only one plan is supported.
plans[].typestringYes"time_based"The plan type. Must be "time_based".
plans[].handlestringNomax:64Handle of a pricing plan. Price, interval, and trial come from the plan.
plans[].price.amountnumericYes*decimal:0,2, min:0.00, max:1000.00Price per billing interval, in USD.
plans[].intervalstringYes*"30_days", "365_days"Billing interval. "30_days" for monthly, "365_days" for yearly.
testbooleanNo-Mark as a test charge. Defaults to false. Required for non-approved apps and development stores.

* Required unless plans[].handle is given.

Request ​

json
{
  "name": "Monthly Subscription",
  "return_url": "https://myapp.com/billing/success",
  "trial_days": 7,
  "plans": [
    {
      "type": "time_based",
      "price": {
        "amount": 19.99
      },
      "interval": "30_days"
    }
  ],
  "test": false
}

Response ​

json
[201]
{
  "type": "recurring",
  "id": "arch_01234567890abcdef",
  "store_id": "...",
  "name": "Monthly Subscription",
  "status": "pending",
  "plan_id": null,
  "plans": [
    {
      "interval": 30,
      "price": {
        "amount": "19.99",
        "currency": "USD"
      }
    }
  ],
  "test": false,
  "trial_days": 7,
  "created_at": 1640995200,
  "period_ends_at": null,
  "canceled_at": null,
  "confirmation_url": "https://..."
}

Redirect the merchant to confirmation_url immediately after receiving this response.

Tip

The charge remains in pending status until the merchant approves or declines it. Verify the final status via List charges after the merchant is redirected back to your return_url.

Warning

Plan upgrades and downgrades go through the same approval flow and create a new recurring charge. See Plan upgrades and downgrades for when the new plan is applied.

AppRecurringCharge object ​

FieldTypeDescription
typestringAlways "recurring" for subscription charges.
idstringUnique charge identifier, prefixed with arch_.
store_idstringID of the store this charge belongs to.
namestringName of the recurring charge as provided in the request.
statusstringCurrent charge status. See charge statuses.
plansarrayArray of pricing plans. Currently limited to one entry.
plans[].intervalintegerBilling interval in days (30 or 365).
plans[].priceobjectPrice information object.
plans[].price.amountstringSubscription amount as a decimal string (e.g. "19.99").
plans[].price.currencystringCurrency code. Always "USD".
testbooleanWhether this is a test charge.
trial_daysintegerNumber of trial days (0–90).
created_atintegerUnix timestamp of charge creation.
period_ends_atinteger | nullUnix timestamp of when the current billing period ends. null for pending charges.
canceled_atinteger | nullUnix timestamp of when the charge is or was canceled. Set when the charge is scheduled for cancellation; null otherwise.
confirmation_urlstringURL for the merchant to approve or decline the charge. Only present when status is pending.