Skip to main content
POST
Create a Subscription

Prerequisites

  1. Create the customer with POST /v2/customers — the response includes the customer_id (UUID) you’ll pass below.
  2. For a card subscription, vault the card through the secure Payment Element flow — this returns a single-use pgct_ payment token. A Pix Automático subscription needs no token.
Subscriptions do not auto-create customers from the request body; passing an unknown customer_id returns 404.

Behavior

customer_id is the customer’s public id (UUID) returned by POST /v2/customers. For a card subscription, token must be a single-use pgct_ token. For a card subscription, when trial_end is supplied, we may charge a small amount and refund it to ensure the payment method is valid, and the subscription is created with status trialing until the trial expires. Without trial_end, the subscription is created with status active after the first charge succeeds. With payment_method: "pix_automatic", do not send token. The subscription is created with status incomplete and an authorization QR code for the payer. It becomes active once the payer authorizes and the first debit is paid, or trialing when trial_end is set and the authorization is approved. See Pix Automático Subscriptions. amount is in cents and is also used to bill every renewal cycle.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
customer_id
string
required

Public customer id (UUID) returned by POST /v2/customers.

Minimum string length: 1
token
string
required
Minimum string length: 6
interval
enum<string>

Required without product_id.

Available options:
day,
week,
month
interval_count
integer

Defaults to 1 without product_id.

Required range: 1 <= x <= 365
failure_policy
enum<string>
default:retry_then_cancel
Available options:
immediate_cancel,
retry_then_cancel,
retry_then_unpaid
retry_offsets_days
integer[]
Required array length: 1 - 10 elements
Required range: 1 <= x <= 30
amount
integer

Billing amount in cents (max 100,000,000). Required without product_id.

Required range: 0 < x <= 100000000
currency
enum<string>

Defaults to BRL without product_id.

Available options:
BRL,
MXN,
COP,
CLP,
ARS,
PEN,
USD,
GTQ,
CRC,
NIO,
PYG,
UYU,
BOB,
PHP,
RUB,
INR,
SAR,
AED,
KWD,
QAR,
OMR,
KHR,
SGD,
IDR,
KRW,
THB,
MYR,
HKD,
CNY,
EGP,
EUR,
GBP,
BHD,
MAD,
AUD,
CAD,
CHF,
NZD,
PLN,
KZT,
UZS,
JPY,
GLC
metadata
object | null
informations
object[]

Custom key/value metadata to attach to the subscription and echo on its webhooks.

Maximum array length: 50
idempotency_key
string | null
Required string length: 1 - 255
products
object[]
Maximum array length: 100
payment_method
enum<string>
default:credit_card
Available options:
credit_card
product_id
string<uuid>

Public id of a recurring catalog product. The plan sets amount, interval, interval_count, currency and max_cycles; sending one of them with a different value returns 422 PLAN_TERMS_MISMATCH.

Pattern: ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
quantity
integer

Quantity of the plan. Requires product_id; defaults to 1.

Required range: 1 <= x <= 999999
ip_address

Public IPv4 or IPv6 address of the buyer, recorded on the first charge.

Pattern: ^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$
Example:

"8.8.8.8"

trial_end
string<date-time> | null

Trial end timestamp (ISO 8601). Must be in the future.

Pattern: ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
max_cycles
integer | null

Number of paid charges after which the subscription ends. Requires a monthly interval, no trial and a failure policy other than retry_then_unpaid. Omit for a subscription with no end.

Required range: 2 <= x <= 120

Response

HTTP 201 response

success
boolean
required
requestId
string
required
data
object
required