Link

Subscriptions

A subscription is a particular subscriber’s access to a subscription plan. It will typically have a start date, and an end date, and may recur at some period. A subscription may have an external id if it came from an earlier CMS, which must be unique. Payment is required to create a subscription.



POST Preview subscription

It returns a preview for a Subscription, without creating a new subscription.

Arguments
key required
The account key
accesstype_jwt required
Used to identify loggedin user. This is the authorized user jwt
subscription_plan_id required
Id of the subscription plan for which subscription is to be previewed
payment required
Consists of payment details. payment_type can be one of Payment Types . amount_cents is the payment transaction amount in cents . amount_currency is payment transaction amount currency.
subscription_type optional
Type of subscription. Can be one of Subscription Types . Defaults to standard
coupon_code optional
Voucher code to be applied
metadata optional
Data that needs to be associated with subscription.
notes optional
Notes that needs to be associated with subscription.
  $ curl -X POST 'https://accesstype.com/api/access/v1/members/me/subscriptions/preview?key=<key>&accesstype_jwt=<accesstype_jwt>'-d {
  "subscription": {
      "subscription_plan_id": 2118,
      "notes": "enter your notes",
      "coupon_code": "UAT",
      "payment": {
          "payment_type": "razorpay",
          "amount_cents": 14400,
          "amount_currency": "INR"
      },
      "metadata": {
          "mobile_number": "76398176X8"
      }
    }
}
Returns

This returns a subscription object and below additonal details.

attempt_token string
It is the identifier of a subscription attempt. It should be sent back with create subscription api to mark an attempt as success.
external_reference_id string
It is the identifier of payment order created with the Payment gateway. It should be used by the client to make payment.

POST Create subscription

Used to create a subscription.

Arguments
key required
The account key
accesstype_jwt required
Used to identify loggedin user. This is the authorized user jwt
attempt_token required
Attempt token received from subscription preview
subscription_plan_id required
Id of the subscription plan for which subscription is to be created
payment required
Consists of payment details. payment_type can be one of Payment Types . amount_cents is the payment transaction amount in cents . amount_currency is payment transaction amount currency. payment_token is the payment transaction id received from the payment gateway.
subscription_type optional
Type of subscription. Can be one of Subscription Types . Defaults to standard
coupon_code optional
Voucher code to be applied
metadata optional
Data that needs to be associated with subscription
notes optional
Notes that needs to be associated with subscription.

The request body is required to be same as that required for preview, with additional payment details and attempt_token.

  $ curl -X POST 'https://accesstype.com/api/access/v1/members/me/subscriptions?key=<key>&accesstype_jwt=<accesstype_jwt>'-d {
  "attempt_token": "WnwxA2AVrE3xqcDUqrSb3sNm",
  "subscription": {
      "subscription_plan_id": 2118,
      "notes": "enter your notes",
      "coupon_code": "UAT",
      "payment": {
          "payment_type": "razorpay",
          "amount_cents": 14400,
          "amount_currency": "INR",
          "payment_token": "pay_afddsgsdfg"
      },
      "metadata": {
          "mobile_number": "76398176X8"
      }
    }
}
Returns

This returns subscription object.


GET all subscriptions

This API will list out all the subscriptions for a subscriber.

Arguments
key required
The account key
accesstype_jwt optional
Used to identify loggedin user. This is the authorized user jwt
  $ curl -X GET 'https://accesstype.com/api/access/v1/members/me/subscriptions?key=<key>&accesstype_jwt=<accesstype_jwt>'
Returns

This returns an Array of subscription objects.


PUT Cancel a subscription

This API can be used to cancel a subscription

Arguments
key required
The account key
accesstype_jwt optional
Used to identify loggedin user. This is the authorized user jwt
subscription-id required
Id of the subscription to be cancelled.
  $ curl -X PUT 'https://accesstype.com/api/access/v1/members/me/subscriptions/<subscription-id>/cancel?key=<key>&accesstype_jwt=<accesstype_jwt>'
Returns

This returns empty body.


PATCH Update a subscription

This API can be used to update the metadata for a subscription.

Arguments
key required
The account key
accesstype_jwt optional
Used to identify loggedin user. This is the authorized user jwt
subscription-id required
Id of the subscription to be updated.
metadata required
Metadata of the subscription to be updated.
  $ curl -X PATCH 'https://accesstype.com/api/access/v1/members/me/subscriptions/<subscription-id>?key=<key>&accesstype_jwt=<accesstype_jwt>' -d {
    "subscription": {
      "metadata":  {
          "full-name": "hello-world",
          "email": "hello@quintype.com"
      }
    }
  }
Returns

This returns empty body.


Gift Subscriptions

POST Preview subscription for gifting

It returns a preview for a Subscription, without creating a new subscription. To be used when subscription is to be gifted.

Arguments

Below arguments need to be passed in addition to subscription preview arguments

recipient_subscriber required
Object having recipient_identity_provider and recipient_identity_provider. The recipient subscriber should not be same as the gifter
  $ curl -X POST 'https://accesstype.com/api/access/v1/members/me/subscriptions/preview?key=<key>&accesstype_jwt=<accesstype_jwt>'-d {
  "recipient_subscriber": {
    "recipient_identity_provider": "email",
    "recipient_identity": "friend@example.com"
  },
  "subscription": {
      "subscription_plan_id": 2118,
      "notes": "enter your notes",
      "coupon_code": "UAT",
      "payment": {
          "payment_type": "razorpay",
          "amount_cents": 14400,
          "amount_currency": "INR"
      },
      "metadata": {
          "mobile_number": "76398176X8"
      }
    }
}
Returns

This returns a subscription object and additonal details similar to subscription preview response


POST Create subscription for gifting

Used to create a gift subscription.

Arguments

Below arguments need to be passed in addition to subscription create arguments

recipient_subscriber required
Object having recipient_identity_provider and recipient_identity_provider. The recipient subscriber should not be same as the gifter.
  $ curl -X POST 'https://accesstype.com/api/access/v1/members/me/subscriptions?key=<key>&accesstype_jwt=<accesstype_jwt>'-d {
  "recipient_subscriber": {
    "recipient_identity_provider": "email",
    "recipient_identity": "friend@example.com"
  },
  "subscription": {
      "subscription_plan_id": 2118,
      "notes": "enter your notes",
      "coupon_code": "UAT",
      "payment": {
          "payment_type": "razorpay",
          "amount_cents": 14400,
          "amount_currency": "INR"
      },
      "metadata": {
          "mobile_number": "76398176X8"
      }
    }
}
Returns

This returns a subscription object.


GET subscription gifts

Used to list subscriptions gifted by a user

Arguments
key required
The account key
accesstype_jwt optional
Used to identify loggedin user. This is the authorized user jwt
  $ curl -X POST 'https://accesstype.com/api/access/v1/members/me/subscription-gifts?key=<key>&accesstype_jwt=<accesstype_jwt>'
Returns

This returns an array of subscription objects.


Pay Per Asset Subscriptions

POST Preview Pay per asset subscription

It returns a preview for a Subscription, without creating a new subscription. To be used to preview Pay Per Asset subscription.

Arguments

Below arguments need to be passed in addition to subscription preview arguments

dynamic_assets required
Array of objects containing id of the asset to be purchased. This would be story-id if a story is the asset to be purchased.
type required
Its value must be dynamic_assets
  $ curl -X POST 'https://accesstype.com/api/access/v1/members/me/subscriptions/preview?key=<key>&accesstype_jwt=<accesstype_jwt>'-d {
  "subscription": {
      "subscription_plan_id": 2118,
      "notes": "enter your notes",
      "coupon_code": "UAT",
      "payment": {
          "payment_type": "razorpay",
          "amount_cents": 14400,
          "amount_currency": "INR"
      },
      "metadata": {
          "mobile_number": "76398176X8"
      },
      "dynamic_assets": [{
        "id": "some_asset_id"
      }]
    }
}
Returns

This returns a subscription object and additonal details similar to subscription preview response


POST Create Pay per asset subscription

Used to create Pay Per Asset subscription using micro payments.

Arguments

Below arguments need to be passed in addition to subscription create arguments

dynamic_assets required
Array of objects containing id of the asset to be purchased. This would be story-id if a story is the asset to be purchased.
type required
Its value must be dynamic_assets
  $ curl -X POST 'https://accesstype.com/api/access/v1/members/me/subscriptions?key=<key>&accesstype_jwt=<accesstype_jwt>'-d {
  "subscription": {
      "subscription_plan_id": 2118,
      "notes": "enter your notes",
      "coupon_code": "UAT",
      "payment": {
          "payment_type": "razorpay",
          "amount_cents": 14400,
          "amount_currency": "INR"
      },
      "metadata": {
          "mobile_number": "76398176X8"
      },
      "dynamic_assets": [{
        "id": "some_asset_id"
     }]
    }
}
Returns

This returns a subscription object.


Subscription without login

POST Preview subscription without login

It returns a preview for a Subscription, without creating a new subscription. It is to be used when user is not logged in and hence accesstype_jwt is not present.

Arguments

Below arguments need to be passed in addition to subscription preview arguments. accesstype_jwt is not required.

emailAddress required
Used to identify the user. Subscription will be previewed for this email</a>
  $ curl -X POST 'https://accesstype.com/api/access/v1/subscription-without-login/preview?key=<key>'-d {
  "emailAddress": 'jane_doe@gmail.com',
  "subscription": {
      "subscription_plan_id": 2118,
      "notes": "enter your notes",
      "coupon_code": "UAT",
      "payment": {
          "payment_type": "razorpay",
          "amount_cents": 14400,
          "amount_currency": "INR"
      },
      "metadata": {
          "mobile_number": "76398176X8"
      }
    }
}
Returns

This returns a subscription object and below additonal details.

attempt_token string
It is the identifier of a subscription attempt. It should be sent back with create subscription api to mark an attempt as success.
external_reference_id string
It is the identifier of payment order created with the Payment gateway. It should be used by the client to make payment.

POST Create subscription without login

Used to create a subscription when user is not logged in.

Arguments

Below arguments need to be passed in addition to subscription create arguments . accesstype_jwt is not required.

emailAddress required
Used to identify the user. Subscription will be created for this email</a>

The request body is required to be same as that required for preview, with additional payment details and attempt_token.

  $ curl -X POST 'https://accesstype.com/api/access/v1/subscription-without-login?key=<key>'-d {
  "emailAddress": "jane_doe@gmail.com",
  "attempt_token": "WnwxA2AVrE3xqcDUqrSb3sNm",
  "subscription": {
      "subscription_plan_id": 2118,
      "notes": "enter your notes",
      "coupon_code": "UAT",
      "payment": {
          "payment_type": "razorpay",
          "amount_cents": 14400,
          "amount_currency": "INR",
          "payment_token": "pay_afddsgsdfg"
      },
      "metadata": {
          "mobile_number": "76398176X8"
      }
    }
}
Returns

This returns subscription object.


Switch Subscription Plans

GET subscription details with switchable plans

It returns subscription with list of switchable plans and their details.

Arguments
key required
The account key
accesstype_jwt required
Used to identify loggedin user. This is the authorized user jwt
  $ curl -X POST 'https://accesstype.com/api/access/v1/members/me/subscriptions/:subscription_id?key=<key>&accesstype_jwt=<accesstype_jwt>'
Returns

This returns a subscription object which includes additonal below given switch plan details.

{
    "original_attempt_token": "B1UXtdYeepwQWZ2TR57qU6tu",
    "upgrade_plan_details": [
        {
            "id": 76,
            "title": "OT switch test plan 2",
            "duration_length": 2,
            "duration_unit": "months",
            "price_cents": 2000,
            "price_currency": "INR",
            "prices": {
                "INR": {
                    "amount_cents": 2000
                },
                "USD": {
                    "amount_cents": 5000
                }
            },
            "prorated_amount_cents": 1000,
            "proration_enabled": true,
            "recurring": false,
            "supported_payment_providers": [
                "razorpay",
                "paytm",
                "stripe"
            ],
            "metadata": {},
            "payment_provider": "razorpay"
        }
    ],
    "downgrade_plan_details": [
        {
            "id": 77,
            "title": "OT plan 3 downgrade",
            "duration_length": 1,
            "duration_unit": "weeks",
            "price_cents": 700,
            "price_currency": "INR",
            "prices": {
                "INR": {
                    "amount_cents": 700
                }
            },
            "prorated_amount_cents": null,
            "proration_enabled": false,
            "recurring": false,
            "supported_payment_providers": [
                "razorpay",
                "paytm",
                "stripe"
            ],
            "metadata": {},
            "payment_provider": "razorpay"
        }
    ],
    "crossgrade_plan_details": [
        {
            "id": 78,
            "title": "OT plan 4 crossgrade",
            "duration_length": 1,
            "duration_unit": "months",
            "price_cents": 260,
            "price_currency": "INR",
            "prices": {
                "INR": {
                    "amount_cents": 260
                }
            },
            "prorated_amount_cents": null,
            "proration_enabled": false,
            "recurring": false,
            "supported_payment_providers": [
                "razorpay",
                "paytm",
                "stripe"
            ],
            "metadata": {},
            "payment_provider": "razorpay"
        }
    ]
}

POST Preview subscription for switching

It returns a preview for a switch, without creating a new subscription. To be used when subscription is to be switched (plan linked to the subscription is to be changed).

Arguments
key required
The account key
accesstype_jwt required
Used to identify loggedin user. This is the authorized user jwt
subscription-id required
Id of the subscription to be switched.
subscription_plan_id required
Id of the subscription plan for which switch is to be previewed (Id of plan to update to)
switch_type required
Type of switch (upgrade | crossgrade | downgrade)
  $ curl -X POST 'https://accesstype.com/api/access/v1/members/me/subscriptions/:subscription_id/switch_plan/preview?key=<key>&accesstype_jwt=<accesstype_jwt>'-d {
    "subscription_plan_id": 2118,
    "switch_type": "upgrade" 
}
Returns

This returns a subscription object and additonal below given details.

attempt_token string
It is the identifier of a subscription attempt. It should be sent back with switch subscription api to mark an attempt as success.
chargeable_amount_cents Number
It is the proration amount to be charged if proration is enabled, this value will be null for recurring subscriptions. It should be used by the client to make payment.

POST Switch subscription

Used to switch a subscription.

Arguments
key required
The account key
accesstype_jwt required
Used to identify loggedin user. This is the authorized user jwt
subscription-id required
Id of the subscription to be switched.
attempt_token required
Attempt token received from subscription switch preview.
payment_token optional
Payment transaction id received from the payment gateway, required only for one time subscription plan switch (not required for recurring subscriptions)
  $ curl -X POST 'https://accesstype.com/api/access/v1/members/me/subscriptions/:subscription_id/switch_plan?key=<key>&accesstype_jwt=<accesstype_jwt>'-d {
  "attempt_token": "WnwxA2AVrE3xqcDUqrSb3sNm",
  "payment_token": "pay_MeUZ59BtjAlGi9"
}
Returns

This returns a subscription object and additonal below given details.

attempt_token string
It is the identifier of a subscription attempt. It should be sent back with switch subscription api to mark an attempt as success.
message string
To convey subscription switch status, ex: "Plan scheduled to update" (when proration is disabled)