Skip to Content

Subscribe a customer to a plan

Starting now (no start_at), the first invoice is issued at once and returned as first_invoice; send its checkout_url to the customer. A later start_at (a trial) issues the first invoice then. Each invoice also comes as an invoice.created webhook.

Authorization

apiKey
headerAuthorizationBearer <token>

lbp_test_... or lbp_live_...

Header Parameters

Idempotency-Key*string
Lengthlength <= 255

Request Body

application/json
  1. body
plan_id*string
customer_name*string

Shown on the checkout page and the VA.

Length1 <= length <= 120
customer_email?string
Lengthlength <= 120
customer_phone?string
Lengthlength <= 40
reference?string

Your customer's id; each invoice's reference is -.

Lengthlength <= 50
start_at?string

When the first period starts: now when left out, at most a year ahead.

Formatdate-time
cycles?integer

Stop after this many invoices.

Range1 <= value <= 1000
end_at?string

No invoice for a period starting at or after this.

Formatdate-time
metadata?

Copied to each invoice.

Response Body

The subscription, with first_invoice

application/json
  1. response
id?string
object?"subscription"
Value in"subscription"
app_id?string
mode?string
Value in"test""live"
plan_id?string
plan?

The plan as it is now (name, amount, period, method, and whether it is on).

status?string
Value in"active""paused""cancelled""completed"
customer?

name, and email and phone when given.

reference?string|null
metadata?
start_at?string
Formatdate-time
cycles?integer|null
end_at?|
Formatdate-time
invoices_issued?integer
next_invoice_at?|

When the next period starts and its invoice is issued; null once cancelled or completed.

Formatdate-time
paused_at?|
Formatdate-time
cancelled_at?|
Formatdate-time
completed_at?|
Formatdate-time
created_at?string
Formatdate-time
first_invoice?|

The first invoice when the subscription starts now; null for a later start_at.

Example Request
curl -X POST 'https://pay.piti.id/v1/billing/subscriptions' \  -H 'Idempotency-Key: string' \  -H 'Content-Type: application/json' \  -d '{  "plan_id": "plan_3G5g...",  "customer_name": "Budi Santoso",  "customer_phone": "0812...",  "reference": "CUST-0042"}'
Example Response
{  "id": "string",  "object": "subscription",  "app_id": "string",  "mode": "test",  "plan_id": "string",  "plan": {    "id": "string",    "name": "string",    "amount": 0,    "active": true,    "interval": {},    "method": "any",    "va_bank": "string"  },  "status": "active",  "customer": {},  "reference": "string",  "metadata": {},  "start_at": "2019-08-24T14:15:22Z",  "cycles": 0,  "end_at": "2019-08-24T14:15:22Z",  "invoices_issued": 0,  "next_invoice_at": "2019-08-24T14:15:22Z",  "paused_at": "2019-08-24T14:15:22Z",  "cancelled_at": "2019-08-24T14:15:22Z",  "completed_at": "2019-08-24T14:15:22Z",  "created_at": "2019-08-24T14:15:22Z",  "first_invoice": {    "id": "string",    "object": "payment",    "app_id": "string",    "mode": "test",    "reference": "string",    "method": "qris",    "status": "pending",    "currency": "IDR",    "amount": 0,    "fee": 0,    "total": 0,    "net": 0,    "fee_payer": "merchant",    "refunded_amount": 0,    "paid_late": true,    "review_reason": "amount_mismatch",    "description": "string",    "customer": {},    "metadata": {},    "return_url": "string",    "checkout_url": "string",    "provider_ref": "string",    "qris": {      "content": "string",      "expires_at": "2019-08-24T14:15:22Z"    },    "va": {      "bank": "mandiri",      "bank_name": "string",      "number": "string"    },    "expires_at": "2019-08-24T14:15:22Z",    "paid_at": "2019-08-24T14:15:22Z",    "created_at": "2019-08-24T14:15:22Z",    "source": "api",    "created_by": {      "id": "string",      "name": "string"    },    "subscription": {      "id": "string",      "cycle": 0,      "period_start": "2019-08-24T14:15:22Z",      "period_end": "2019-08-24T14:15:22Z"    }  }}