Skip to main content

Create Subscription

Create a new subscription with customer information, plan details, and payment method. Supports flexible trial period settings and idempotency guarantees.

POSThttps://api.efundpay.com/v4/subscriptions
This endpoint requires the subscriptions.write scope.

Authorizations

Authorizationstringheaderrequired

Bearer authentication header in the format `Bearer <token>`, where `<token>` is your authentication token.

Headers

x-merchant-account-idstringrequired

Merchant account ID for this request.

Examples:"default"
idempotency-keystring

Unique key to ensure request idempotency. If provided, identical requests will not be processed multiple times.

Examples:"unique-key-123"
X-Forwarded-Forstringrequired

Original IP address of the client connecting to the server.

Examples:"203.0.113.195"

Body

application/json
external_identifierstringrequired

Merchant reference identifier for this subscription. Used to identify the subscription in your system.

Length:1 - 64
Examples:"subscription-12345"
amountintegerrequired

Amount for the first subscription period in cents (smallest currency unit).

Examples:"1000""2999"
currencystringrequired

Currency for the first subscription period (ISO 4217 format).

Examples:"USD""EUR"
customerobjectrequired

Customer information object.

planobjectrequired

Subscription plan details.

payment_methodobjectrequired

Payment method details. If the merchant does not have PCI compliance, use checkout mode to redirect to the payment page to collect card information.

billing_detailsobject

Billing details for this subscription.Required when `payment_method.payment_channel_code` is "J-Pay"

cart_itemsarray

Array of cart items representing subscription line items. Required when `payment_method.payment_channel_code` is "J-Pay".

browser_infoobject

Browser information used by the customer. Required for Direct API mode. This can be used for anti-fraud services.

trial_endstring

Trial period end time (ISO 8601 format).

Examples:"2025-09-01T00:00:00Z"
descriptionstring

Description of the subscription.

Length:1 - 255
Examples:"Premium Plan with trial period"
metadataobject

Custom key-value pairs for additional information.

Examples:"{"campaign": "summer_promotion", "source": "website"}"

Response

application/json

Successful Response

idstringrequired

Unique subscription identifier.

Examples:"sub_0001"
objectstringrequired

Object type, always "subscription".

Examples:"subscription"
external_identifierstringrequired

Merchant reference identifier for this subscription.

Examples:"subscription-12345"
amountintegerrequired

Amount for the first subscription period in cents (smallest currency unit).

Examples:"1000"
currencystringrequired

Currency for the first subscription period (ISO 4217 format).

Examples:"USD"
createdstringrequired

Subscription creation time (ISO 8601).

Examples:"2025-08-12T09:00:00Z"
customerobjectrequired

Customer information.

planobjectrequired

Subscription plan details.

payment_methodobjectrequired

Payment method details.

statusstringrequired

Subscription status: failed, active, past_due, cancelled.

Examples:"failed""active"
current_period_startstringrequired

Current billing period start time.

Examples:"2025-08-12T09:00:00Z"
current_period_endstringrequired

Current billing period end time.

Examples:"2025-09-12T09:00:00Z"
next_billing_datestringrequired

Next billing date (YYYY-MM-DD format).

Examples:"2025-09-01"
trial_startstring | null

Trial period start time (if applicable).

Examples:"2025-08-12T09:00:00Z"
trial_endstring | null

Trial period end time (if applicable).

Examples:"2025-09-01T00:00:00Z"
metadataobject

Custom metadata.

Examples:"{}"
payment_url_linkstring | null

URL to complete payment for this subscription. Provided when using checkout mode or requiring additional payment steps.

Examples:"https://pay.efundpay.com/abc123""null"
curl --request POST \
--url https://api.efundpay.com/v4/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'x-merchant-account-id: <x-merchant-account-id>' \
--header 'Content-Type: application/json' \
--header 'idempotency-key: unique-key-123' \
--header 'X-Forwarded-For: 203.0.113.195' \
--data '{
"external_identifier": "subscription-12345",
"amount": 1000,
"currency": "USD",
"customer": {
"display_name": "John Doe",
"external_identifier": "customer-12345",
"first_name": "John",
"last_name": "Doe",
"email_address": "john@example.com",
"phone_number": "+1234567890",
"account_number": "123456789"
},
"plan": {
"name": "Basic Monthly",
"currency": "USD",
"amount": 1000,
"interval": "month",
"trial_period_days": 14,
"billing_cycle_anchor": "immediate",
"payment_attempts": 3,
"interval_time": 3600
},
"payment_method": {
"payment_channel_code": "card",
"type": "card",
"redirect_url": "https://example.com",
"webhooks_url": "https://merchant.com/webhooks/payment"
},
"cart_items": [{
"name": "Premium Plan",
"description": "Premium subscription plan with advanced features",
"quantity": 1,
"unit_amount": 1000,
"discount_amount": 0,
"tax_amount": 0,
"external_identifier": "premium-plan",
"sku": "PREMIUM001",
"product_url": "https://example.com/catalog/premium-plan",
"image_url": "https://example.com/images/premium-plan.jpg",
"categories": ["subscription", "premium", "feature"],
"product_type": "service"
}],
"browser_info": {
"javascript_enabled": true,
"java_enabled": false,
"language": "en-US",
"color_depth": 24,
"screen_height": 1080,
"screen_width": 1920,
"time_zone_offset": -480,
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"user_device": "desktop",
"accept_header": "*/*"
},
"metadata": {
"campaign": "summer_promotion",
"source": "website"
},
"billing_details": {
"first_name": "John",
"last_name": "Doe",
"email_address": "john@example.com",
"phone_number": "+1234567890",
"address": {
"city": "San Jose",
"country": "US",
"postal_code": "94560",
"state": "California",
"state_code": "US-CA",
"house_number_or_name": "10",
"line1": "Stafford Appartments",
"line2": "29th Street",
"organization": "EFundFlow"
}
}
}'
{
"id": "sub_0001",
"object": "subscription",
"external_identifier": "subscription-12345",
"amount": 1000,
"currency": "USD",
"created": "2025-08-12T09:00:00Z",
"customer": {
"display_name": "John Doe",
"external_identifier": "customer-12345",
"first_name": "John",
"last_name": "Doe",
"email_address": "john@example.com",
"phone_number": "+1234567890",
"account_number": "123456789"
},
"plan": {
"name": "Basic Monthly",
"currency": "USD",
"amount": 1000,
"interval": "month",
"trial_period_days": 14,
"billing_cycle_anchor": "immediate",
"payment_attempts": 3,
"interval_time": 3600
},
"payment_method": {
"type": "card",
"card": {
"last4": "1111",
"expiration_date": "12/27"
}
},
"status": "failed",
"current_period_start": "2025-08-12T09:00:00Z",
"current_period_end": "2025-09-12T09:00:00Z",
"next_billing_date": "2025-09-01",
"trial_start": "2025-08-12T09:00:00Z",
"trial_end": "2025-09-01T00:00:00Z",
"metadata": {
"campaign": "summer_promotion",
"source": "website"
},
"payment_url_link": "https://pay.efundpay.com/abc123"
}
Powered by Docusaurus