Skip to main content
POST
/
subscriptions
Create a subscription
curl --request POST \
  --url https://api.paygentic.io/v0/subscriptions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "customerId": "<string>",
  "customer": {
    "name": "<string>",
    "email": "<string>",
    "phone": "<string>",
    "address": {
      "line1": "<string>",
      "line2": "<string>",
      "city": "<string>",
      "state": "<string>",
      "country": "<string>",
      "zipCode": "<string>"
    },
    "taxRates": {}
  },
  "planId": "<string>",
  "name": "<string>",
  "startedAt": "2023-11-07T05:31:56Z",
  "endingAt": "2023-11-07T05:31:56Z",
  "items": [
    {
      "billableMetricId": "<string>",
      "quantity": 123
    }
  ],
  "prefundAmount": "<string>"
}'
{
  "id": "<string>",
  "object": "subscription",
  "customerId": "<string>",
  "planId": "<string>",
  "walletId": "<string>",
  "name": "<string>",
  "status": "pending_payment",
  "createdAt": "2023-11-07T05:31:56Z",
  "updatedAt": "2023-11-07T05:31:56Z",
  "startedAt": "2023-11-07T05:31:56Z",
  "endingAt": "2023-11-07T05:31:56Z",
  "terminatedAt": "2023-11-07T05:31:56Z",
  "terminatedBy": "<string>",
  "terminationReason": "<string>",
  "items": [
    {
      "billableMetricId": "<string>",
      "billableMetricName": "<string>",
      "quantity": 123,
      "unitPrice": "<string>",
      "totalCost": "<string>"
    }
  ],
  "prefundAmount": "<string>",
  "payment": {
    "paymentSessionId": "<string>",
    "checkoutUrl": "<string>",
    "amount": "<string>",
    "status": "pending",
    "breakdown": {
      "upfrontCharges": "<string>",
      "walletPrefund": "<string>"
    }
  }
}

Authorizations

Authorization
string
header
required

API key authentication

Body

application/json
planId
string
required

Unique identifier for a plan

name
string
required

The name of the subscription.

startedAt
string<date-time>
required

The date and time when the subscription started.

customerId
string

Unique identifier for a customer

customer
object

Fields to create a new customer and consumer. Will use an existing consumer if one exists with the same email address. Required if customerId is not provided.

endingAt
string<date-time>

The date and time when the subscription will end.

items
object[]

Array of upfront flat-fee items with quantities

prefundAmount
string

Minimum wallet balance in decimal dollars (e.g., '100.00')

Response

Subscription already exists

id
string
object
enum<string>
Available options:
subscription
customerId
string
planId
string
walletId
string

Optional (virtual) wallet ID for the subscription

name
string
status
enum<string>
Available options:
pending_payment,
active,
terminated
createdAt
string<date-time>
updatedAt
string<date-time>
startedAt
string<date-time>
endingAt
string<date-time>
terminatedAt
string<date-time>
terminatedBy
string

ID of who terminated the subscription (customer ID or merchant ID)

terminationReason
string

Reason for termination

items
object[]

Array of upfront subscription items with quantities and costs

prefundAmount
string

Minimum wallet balance in nanodollars

payment
object

Payment session details when upfront payment is required

I