Skip to main content
POST
/
v2
/
subscriptions
Post Subscriptions
curl --request POST \
  --url https://api.pagou.ai/v2/subscriptions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "customer_id": "<string>",
  "token": "<string>",
  "amount": 50000000,
  "interval_count": 1,
  "trial_end": "2023-11-07T05:31:56Z",
  "failure_policy": "retry_then_cancel",
  "retry_offsets_days": [
    15
  ],
  "currency": "BRL",
  "metadata": {},
  "idempotency_key": "<string>",
  "products": [
    {
      "name": "<string>",
      "price": 50000000,
      "quantity": 1,
      "tangible": false,
      "sku": "<string>"
    }
  ]
}
'
{
  "success": true,
  "requestId": "<string>",
  "data": {
    "id": "<string>",
    "customerId": "<string>",
    "intervalCount": 183,
    "amount": 50000000,
    "trialEnd": "2023-11-07T05:31:56Z",
    "currentPeriodStart": "2023-11-07T05:31:56Z",
    "currentPeriodEnd": "2023-11-07T05:31:56Z",
    "cancelAtPeriodEnd": true,
    "canceledAt": "2023-11-07T05:31:56Z",
    "retryOffsetsDays": [
      15
    ],
    "customerEmail": "<string>",
    "cardLast4": "<string>",
    "metadata": {},
    "products": [
      {
        "name": "<string>",
        "price": 50000000,
        "quantity": 500000,
        "tangible": true,
        "sku": "<string>"
      }
    ],
    "createdAt": "2023-11-07T05:31:56Z",
    "updatedAt": "2023-11-07T05:31:56Z",
    "transactions": [
      {
        "id": "<string>",
        "status": "<string>",
        "amount": 50000000,
        "paidAmount": 50000000,
        "refundedAmount": 50000000,
        "externalRef": "<string>",
        "createdAt": "2023-11-07T05:31:56Z",
        "paidAt": "2023-11-07T05:31:56Z"
      }
    ]
  }
}

Documentation Index

Fetch the complete documentation index at: https://developer.pagou.ai/llms.txt

Use this file to discover all available pages before exploring further.

Prerequisites

  1. Create the customer with POST /v2/customers — the response includes the customer_id (UUID) you’ll pass below.
  2. Vault the card through the secure Payment Element flow — this returns a single-use pgct_ payment 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. token must be a single-use pgct_ token. 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. 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
Available options:
day,
week,
month
amount
integer
required

Billing amount in cents (max 100,000,000).

Required range: 0 < x <= 100000000
interval_count
integer
default:1
Required range: 1 <= x <= 365
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)))$
failure_policy
enum<string>
default:retry_then_cancel
Available options:
immediate_cancel,
retry_then_cancel
retry_offsets_days
integer[]
Required array length: 1 - 10 elements
Required range: 1 <= x <= 30
currency
enum<string>
default:BRL
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
idempotency_key
string | null
Required string length: 1 - 255
products
object[]
Maximum array length: 100

Response

HTTP 201 response

success
boolean
required
requestId
string
required
data
object
required