Canvas OneStop REST API

A simple API to integrate Canvas, Stripe, and more.

BASE API URI: api.canvasadmin.educative.tech

Stripe Routes

Creates a new stripe customer on stripe and saves details to local db

POST

Endpoint: /api/stripe/create-stripe-customer

Auth headers required

Expected Params:

{
    "name": string,
    "email": string,
}

Example Response:

{
    "id": customer id,
    "name": customer name,
    "email": customer email,
    "created": date
    code: 201
}

Retrieve Stripe Customer info

GET

Endpoint: /api/stripe/stripe-customer

Auth headers required

Expected Params:

{
    None
}

Example Response:

{
    "id": customer id,
    "name": customer name,
    "email": customer email,
    "created": date,
    "metadata": customer metadata,
    code: 201
}

Creates a stripe subscription session

POST

Endpoint: /api/stripe/create-subscription-session

Auth headers required

Expected Params:

{
    "price_id": string
}

Example Response:

{
    "subscriptionId": string,
    code: 200
}

Get all stripe products

GET

Endpoint: /api/stripe/products

Auth headers required

Expected Params:

{
    None
}

Example Response:

{
    "product_list":[
        {
            "id": 3,
            "name": Starter,
            "currency": USD,
            "description": Starter Pack,
            "price_id": pr_aksjbaIU1231,
            "product_id": prod_asukhbpoiU1231,
            "cost": 300,
            "user_count": 10,
            "interval": MONTH,
        }
    ], 200
}

Registers a new subscription

POST

Endpoint: /api/stripe/register-subscription

Auth headers required

Expected Params:

{
    "email": string,
    "customer_id": string,
    "product_id": string,
    "account_name": string,
}

Example Response:

{
    "message": Subscription logged to db", 200
}

Get all subscriptions for current EdTechUser

GET

Endpoint: /api/stripe/user-subscriptions

Auth headers required

Expected Params:

{
    None
}

Example Response:

{
    "results":[
        {
            "id": 3,
            "subscription": Starter,
            "interval": MONTH,
            "currency": USD,
            "cost": 15,
            "userlimit": 10,
            "activeusers": 5,
            "is_admin": True,
            "subaccount": OneStopTest,
            "start_date": Date("%Y-%m-%d %H:%M:%S"),
            "user_over": 0,
            "product_id": prod_ashdg129387,
            "meter_name": user_overage,
            "dollar_rate": 1.50,
        }
    ], 200
}

Update a subscription plan

PUT

Endpoint: /api/stripe/update-subscription

Auth headers required

Expected Params:

{
    "subscription_id": string,
    "price_id": string,
    "product_id": string,
}

Example Response:

{
    "status": "success",
    "message": "Subscription updated successfully"
}

Cancel a subscription plan

PUT

Endpoint: /api/stripe/cancel-subscription

Auth headers required

Expected Params:

{
    "sub_id": string,
}

Example Response:

{
    "status": "success",
    "message": "Subscription cancelled successfully"
}, 200