Available Plans Endpoint
This endpoint provides a list of available subscription plans based on the user type (Company or Student).
Endpoint
- Route:
/api/subscriptions/plans
Accepted Method
GET: Retrieve available subscription plans based on user type.
Request Headers
Authorization: A required header containing an authorization token for accessing the endpoint. The token should match the value ofprocess.env.NEXT_PUBLIC_AUTHfor successful access.
Query Parameters
type: A query parameter specifying the user type. Valid values are'company'or'student'.
Response
The response data is of type IRes, which is an object with the following structure:
type: Indicates whether the request was successful ('success') or encountered an error ('error').data: An array of objects, where each object represents a subscription plan. Each plan object conforms to theIPlaninterface defined below.
Example Response (Success)
{
"type": "success",
"data": [
{
"subscriptions": [],
"pages": [],
"domain": "test",
"name": "Company Premium Plan",
"plan_code": "PLN_company_premium",
"description": "Access to premium features for companies",
"amount": 99.99,
"interval": "monthly",
"invoice_limit": 0,
"send_invoices": true,
"send_sms": true,
"hosted_page": false,
"hosted_page_url": null,
"hosted_page_summary": null,
"currency": "USD",
"migrate": false,
"is_deleted": false,
"is_archived": false,
"id": 12345,
"integration": 67890,
"createdAt": "2023-10-01T09:00:00.000Z",
"updatedAt": "2023-10-01T09:00:00.000Z",
"total_subscriptions": 50,
"active_subscriptions": 45,
"total_subscriptions_revenue": 4999.5
}
// Additional plan objects...
]
}Example Response (Error)
{
"type": "error",
"message": "You are not allowed to view this page"
}Status Codes
- 200 OK: Successful response with a list of available plans.
- 401 Unauthorized: When the provided authorization token is incorrect or missing.
- 500 Internal Server Error: In case of an unhandled error.
Usage
To retrieve available plans for a specific user type, make a GET request to the endpoint with the type query parameter and the Authorization header.
Example Request:
GET /api/subscriptions/plans?type=company
Authorization: AuthorizationToken