Skip to main content

Subscribe to Plan

Add prepaid credits to your organization. This endpoint initiates the payment flow and returns a redirect URL where the user should complete payment.

Request​

POST /billing/subscribe

Authentication​

Requires an Admin Bearer JWT token.

Authorization: Bearer <access_token>

Request Body​

{
"planId": "660e8400-e29b-41d4-a716-446655440001"
}

Request Fields​

FieldTypeRequiredDescription
planIdUUIDYesThe unique identifier of the plan to subscribe to

Response​

Returns a subscription response with a redirect URL for payment completion.

Success Response​

Status Code: 200 OK

Response Body:

{
"redirectUrl": "https://payment.provider.com/checkout/session_abc123",
"subscription": {
"planName": "paid",
"planDisplayName": "Paid",
"tier": "PAID",
"priceCents": 0,
"currency": "EUR",
"status": "PENDING",
"currentPeriodStart": null,
"currentPeriodEnd": null,
"gracePeriodEnd": null
},
"success": true
}

Response Fields​

FieldTypeDescription
redirectUrlstringURL where the user should be redirected to complete payment
subscriptionobjectSubscription details (status will be PENDING until payment completes)
subscription.planNamestringInternal plan identifier
subscription.planDisplayNamestringHuman-readable plan name
subscription.tierstringPlan tier enum: FREE or PAID
subscription.priceCentsintegerPrice in cents (usage-based)
subscription.currencystringCurrency code (e.g., EUR, USD)
subscription.statusstringSubscription status (initially PENDING)
subscription.currentPeriodStartstringISO timestamp (null until payment completes)
subscription.currentPeriodEndstringISO timestamp (null until payment completes)
subscription.gracePeriodEndstringISO timestamp (null)
successbooleanWhether the subscription initiation was successful

Errors​

Status CodeError CodeDescription
400BAD_REQUESTInvalid plan ID or organization already has an active subscription
401UNAUTHORIZEDMissing or invalid JWT token
403FORBIDDENUser does not have admin privileges
404NOT_FOUNDPlan with the specified ID does not exist
422UNPROCESSABLE_ENTITYCannot subscribe (e.g., insufficient billing details)

Example​

Request​

curl -X POST https://app.entryguard.io/api/v1/billing/subscribe \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json" \
-d '{
"planId": "660e8400-e29b-41d4-a716-446655440001"
}'

Response​

{
"redirectUrl": "https://payment.provider.com/checkout/session_abc123",
"subscription": {
"planName": "paid",
"planDisplayName": "Paid",
"tier": "PAID",
"priceCents": 0,
"currency": "EUR",
"status": "PENDING",
"currentPeriodStart": null,
"currentPeriodEnd": null,
"gracePeriodEnd": null
},
"success": true
}

Notes​

  • After receiving the response, redirect the user to the redirectUrl to complete payment.
  • Payment methods are automatically captured during the checkout flow.
  • Once payment is complete, the user will be redirected back to your application and the subscription status will change to ACTIVE.
  • The subscription will be logged in the audit trail with event type SUBSCRIPTION_CREATED.
  • Billing details must be configured before subscribing (see Update Billing Details endpoint).