Skip to content

Create a Recurring Charge

Creates a subscription charge for your application. The seller must approve the charge once — YouCan then handles renewals automatically at each billing interval.

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

Method: POST

Parameters

ParameterTypeRequiredValidationDescription
namestringYesmax:255Display name shown to the seller on the confirmation page.
return_urlstringYesurl, max:2048URL to redirect the seller to after they approve or decline.
trial_daysintegerNomin:0, max:90Number of free trial days before the first charge. Defaults to 0.
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[].price.amountnumericYes*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.
testbooleanNoMark as a test charge. Defaults to false. Required for non-approved apps and development stores.

* Required when plans[].type is "time_based".

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",
  "plans": [
    {
      "interval": 30,
      "price": {
        "amount": "19.99",
        "currency": "USD"
      }
    }
  ],
  "test": false,
  "trial_days": 7,
  "created_at": 1640995200,
  "period_ends_at": null,
  "confirmation_url": "https://..."
}

Redirect the seller to confirmation_url immediately after receiving this response.

TIP

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

WARNING

Plan upgrades and downgrades go through the same approval flow and create a new recurring charge. If both plans share the same interval (30_days), proration applies. Otherwise, the new plan is deferred to the next billing cycle.

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.
confirmation_urlstringURL for the seller to approve or decline the charge. Only present when status is pending.