Skip to content

Plans

The Plans API allows superusers to manage subscription plans, including creating, reading, updating, and deleting plans. All plan operations require superuser privileges.

Create Plan

Create a new subscription plan.

Endpoint

POST /v1/plans/

Authentication

This endpoint requires authentication with superuser privileges.

Request Body

Parameter Type Required Description
plan_code integer Yes External Plan ID (unique identifier)
label string Yes Human-readable label (1-100 characters)
description string No Optional description of the plan
duration_days integer No Optional duration in days
is_active boolean No Whether plan is active (default: true)

Example Request

curl -X POST https://fav3.vibemobi.com/v1/plans/ \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "plan_code": 1001,
    "label": "Premium Monthly Plan",
    "description": "Premium plan with unlimited favorites and extended features",
    "duration_days": 30,
    "is_active": true
  }'

Response

{
    "plan_code": 1001,
    "label": "Premium Monthly Plan",
    "description": "Premium plan with unlimited favorites and extended features",
    "duration_days": 30,
    "is_active": true,
    "created_at": "2023-12-01T10:00:00Z",
    "updated_at": "2023-12-01T10:00:00Z"
}

Error Responses

Plan Already Exists

{
    "detail": "Plan with this plan_code already exists"
}

List Plans

List all subscription plans with pagination.

Endpoint

GET /v1/plans/

Authentication

This endpoint requires authentication with superuser privileges.

Query Parameters

Parameter Type Required Default Min Max Description
skip integer No 0 0 - Number of plans to skip
limit integer No 50 1 200 Maximum number of plans to return

Example Request

curl -X GET "https://fav3.vibemobi.com/v1/plans/?skip=0&limit=10" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Response

{
    "data": [
        {
            "plan_code": 1001,
            "label": "Premium Monthly Plan",
            "description": "Premium plan with unlimited favorites and extended features",
            "duration_days": 30,
            "is_active": true,
            "created_at": "2023-12-01T10:00:00Z",
            "updated_at": "2023-12-01T10:00:00Z"
        },
        {
            "plan_code": 1002,
            "label": "Basic Weekly Plan",
            "description": "Basic plan with limited features",
            "duration_days": 7,
            "is_active": true,
            "created_at": "2023-11-15T14:20:00Z",
            "updated_at": "2023-11-15T14:20:00Z"
        }
    ],
    "count": 2
}

Error Responses

No Plans Found

{
    "detail": "No plans found"
}

Get Plan by ID

Get a specific plan by its plan code.

Endpoint

GET /v1/plans/{plan_id}

Authentication

This endpoint requires authentication with superuser privileges.

Path Parameters

Parameter Type Required Description
plan_id integer Yes Plan code (external Plan ID)

Example Request

curl -X GET https://fav3.vibemobi.com/v1/plans/1001 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Response

{
    "plan_code": 1001,
    "label": "Premium Monthly Plan",
    "description": "Premium plan with unlimited favorites and extended features",
    "duration_days": 30,
    "is_active": true,
    "created_at": "2023-12-01T10:00:00Z",
    "updated_at": "2023-12-01T10:00:00Z"
}

Error Responses

Plan Not Found

{
    "detail": "Plan not found"
}

Update Plan

Update an existing plan's details.

Endpoint

PUT /v1/plans/{plan_id}

Authentication

This endpoint requires authentication with superuser privileges.

Path Parameters

Parameter Type Required Description
plan_id integer Yes Plan code (external Plan ID)

Request Body

Parameter Type Required Description
label string No New label (1-100 characters)
description string No New description
duration_days integer No New duration in days
is_active boolean No New active status

Example Request

curl -X PUT https://fav3.vibemobi.com/v1/plans/1001 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "label": "Premium Monthly Plan (Updated)",
    "description": "Updated premium plan with enhanced features",
    "duration_days": 31,
    "is_active": true
  }'

Response

{
    "plan_code": 1001,
    "label": "Premium Monthly Plan (Updated)",
    "description": "Updated premium plan with enhanced features",
    "duration_days": 31,
    "is_active": true,
    "created_at": "2023-12-01T10:00:00Z",
    "updated_at": "2023-12-01T15:30:00Z"
}

Error Responses

Plan Not Found

{
    "detail": "Plan not found"
}

Unique Constraint Violation

{
    "detail": "Update violates a unique constraint"
}

Delete Plan

Delete a plan by its plan code.

Endpoint

DELETE /v1/plans/{plan_id}

Authentication

This endpoint requires authentication with superuser privileges.

Path Parameters

Parameter Type Required Description
plan_id integer Yes Plan code (external Plan ID)

Example Request

curl -X DELETE https://fav3.vibemobi.com/v1/plans/1001 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Response

{
    "message": "Plan deleted successfully"
}

Error Responses

Plan Not Found

{
    "detail": "Plan not found"
}

Plan Status Codes

Plans can have different statuses that affect their availability:

Status Description
true Plan is active and available for new subscriptions
false Plan is inactive and not available for new subscriptions

Business Rules

Plan Management Rules

Plan Codes - Plan codes must be unique across the system - Plan codes are external identifiers, not auto-generated - Plan codes cannot be changed after creation

Plan Status - Inactive plans cannot be assigned to new customers - Existing customers with inactive plans retain their subscriptions - Plan status changes affect future assignments only

Plan Duration - Duration is specified in days - Duration is optional and can be null for unlimited plans - Duration affects subscription expiration calculations

Plan Deletion - Plans with active subscriptions may not be deletable - Consider deactivating plans instead of deleting them - Deletion is permanent and cannot be undone

Superuser Access Required

All plan management operations require superuser privileges. Regular users and staff members cannot access these endpoints.

Common Use Cases

Creating a New Plan

  1. Define the plan details (code, label, description)
  2. Set appropriate duration and active status
  3. Use POST /v1/plans/ to create the plan
  4. Verify creation with GET /v1/plans/{plan_id}

Deactivating a Plan

  1. Use PUT /v1/plans/{plan_id} with "is_active": false
  2. Existing customers retain access
  3. New customers cannot select this plan

Plan Lifecycle Management

  1. Active: Plan is available for new subscriptions
  2. Inactive: Plan is hidden from new customers but existing subscriptions continue
  3. Deleted: Plan is permanently removed (use with caution)

Bulk Plan Operations

For bulk operations, iterate through individual API calls:

```bash

Example: Deactivate multiple plans

for plan_id in 1001 1002 1003; do curl -X PUT "https://fav3.vibemobi.com/v1/plans/$plan_id" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"is_active": false}' done