Skip to content

Subscriptions Endpoints

Subscriptions API endpoints.


Overview

Method Endpoint Description
GET /api/v1/subscriptions/ Read Subscriptions
PUT /api/v1/subscriptions/{subscription_id} Update Subscription
GET /api/v1/subscriptions/{subscription_id} Read Subscription
POST /api/v1/subscriptions/{subscription_id}/renew Renew Subscription
POST /api/v1/subscriptions/{user_id} Create User Subscription

API Reference

Sartiq Backend Server - Subscriptions 0.1.0

subscriptions


POST /api/v1/subscriptions/{user_id}

Create User Subscription

Description

Create a subscription for a user (superuser only).

Input parameters

Parameter In Type Default Nullable Description
OAuth2PasswordBearer header string N/A No
user_id path string No

Request body

{
    "service_type": "SELF_SERVICE",
    "tier": "START",
    "payment_id": null
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the request body
{
    "properties": {
        "service_type": {
            "$ref": "#/components/schemas/ServiceType"
        },
        "tier": {
            "$ref": "#/components/schemas/SubscriptionTier"
        },
        "payment_id": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Payment Id"
        }
    },
    "type": "object",
    "required": [
        "service_type",
        "tier"
    ],
    "title": "SubscriptionCreate"
}

Responses

{
    "id": "a3f468c5-36f5-475b-bc48-f18433eca434",
    "created_at": "2022-04-13T15:42:05.901Z",
    "updated_at": "2022-04-13T15:42:05.901Z",
    "user_id": "74c5ffce-6519-4118-8550-17b9df60accd",
    "service_type": "SELF_SERVICE",
    "tier": "START",
    "start_date": "2022-04-13T15:42:05.901Z",
    "end_date": "2022-04-13T15:42:05.901Z",
    "grace_period_end": "2022-04-13T15:42:05.901Z",
    "credits_total": 0,
    "credits_used": 0,
    "credits_remaining": 0,
    "is_active": true,
    "payment_status": "PENDING",
    "base_price": 10.12,
    "actual_price": 10.12,
    "currency": "string"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
        },
        "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
        },
        "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
        },
        "user_id": {
            "type": "string",
            "format": "uuid",
            "title": "User Id"
        },
        "service_type": {
            "$ref": "#/components/schemas/ServiceType"
        },
        "tier": {
            "$ref": "#/components/schemas/SubscriptionTier"
        },
        "start_date": {
            "type": "string",
            "format": "date-time",
            "title": "Start Date"
        },
        "end_date": {
            "type": "string",
            "format": "date-time",
            "title": "End Date"
        },
        "grace_period_end": {
            "type": "string",
            "format": "date-time",
            "title": "Grace Period End"
        },
        "credits_total": {
            "type": "integer",
            "title": "Credits Total"
        },
        "credits_used": {
            "type": "integer",
            "title": "Credits Used"
        },
        "credits_remaining": {
            "type": "integer",
            "title": "Credits Remaining"
        },
        "is_active": {
            "type": "boolean",
            "title": "Is Active"
        },
        "payment_status": {
            "$ref": "#/components/schemas/PaymentStatus"
        },
        "base_price": {
            "type": "number",
            "title": "Base Price"
        },
        "actual_price": {
            "type": "number",
            "title": "Actual Price"
        },
        "currency": {
            "type": "string",
            "title": "Currency"
        }
    },
    "type": "object",
    "required": [
        "id",
        "user_id",
        "service_type",
        "tier",
        "start_date",
        "end_date",
        "grace_period_end",
        "credits_total",
        "credits_used",
        "credits_remaining",
        "is_active",
        "payment_status",
        "base_price",
        "actual_price",
        "currency"
    ],
    "title": "SubscriptionPublic"
}

{
    "detail": [
        {
            "loc": [
                null
            ],
            "msg": "string",
            "type": "string",
            "input": null,
            "ctx": {}
        }
    ]
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "detail": {
            "items": {
                "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
        }
    },
    "type": "object",
    "title": "HTTPValidationError"
}

PUT /api/v1/subscriptions/{subscription_id}

Update Subscription

Description

Update a subscription (superuser only). Handles upgrades/downgrades.

Input parameters

Parameter In Type Default Nullable Description
OAuth2PasswordBearer header string N/A No
subscription_id path string No

Request body

{
    "service_type": null,
    "tier": null
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the request body
{
    "properties": {
        "service_type": {
            "anyOf": [
                {
                    "$ref": "#/components/schemas/ServiceType"
                },
                {
                    "type": "null"
                }
            ]
        },
        "tier": {
            "anyOf": [
                {
                    "$ref": "#/components/schemas/SubscriptionTier"
                },
                {
                    "type": "null"
                }
            ]
        }
    },
    "type": "object",
    "title": "SubscriptionUpdate"
}

Responses

{
    "id": "f34e5f2c-bbf9-45b9-ad82-208ac36f28f7",
    "created_at": "2022-04-13T15:42:05.901Z",
    "updated_at": "2022-04-13T15:42:05.901Z",
    "user_id": "e1ca9c5f-7c69-4f73-8586-16172e1bb94f",
    "service_type": "SELF_SERVICE",
    "tier": "START",
    "start_date": "2022-04-13T15:42:05.901Z",
    "end_date": "2022-04-13T15:42:05.901Z",
    "grace_period_end": "2022-04-13T15:42:05.901Z",
    "credits_total": 0,
    "credits_used": 0,
    "credits_remaining": 0,
    "is_active": true,
    "payment_status": "PENDING",
    "base_price": 10.12,
    "actual_price": 10.12,
    "currency": "string"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
        },
        "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
        },
        "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
        },
        "user_id": {
            "type": "string",
            "format": "uuid",
            "title": "User Id"
        },
        "service_type": {
            "$ref": "#/components/schemas/ServiceType"
        },
        "tier": {
            "$ref": "#/components/schemas/SubscriptionTier"
        },
        "start_date": {
            "type": "string",
            "format": "date-time",
            "title": "Start Date"
        },
        "end_date": {
            "type": "string",
            "format": "date-time",
            "title": "End Date"
        },
        "grace_period_end": {
            "type": "string",
            "format": "date-time",
            "title": "Grace Period End"
        },
        "credits_total": {
            "type": "integer",
            "title": "Credits Total"
        },
        "credits_used": {
            "type": "integer",
            "title": "Credits Used"
        },
        "credits_remaining": {
            "type": "integer",
            "title": "Credits Remaining"
        },
        "is_active": {
            "type": "boolean",
            "title": "Is Active"
        },
        "payment_status": {
            "$ref": "#/components/schemas/PaymentStatus"
        },
        "base_price": {
            "type": "number",
            "title": "Base Price"
        },
        "actual_price": {
            "type": "number",
            "title": "Actual Price"
        },
        "currency": {
            "type": "string",
            "title": "Currency"
        }
    },
    "type": "object",
    "required": [
        "id",
        "user_id",
        "service_type",
        "tier",
        "start_date",
        "end_date",
        "grace_period_end",
        "credits_total",
        "credits_used",
        "credits_remaining",
        "is_active",
        "payment_status",
        "base_price",
        "actual_price",
        "currency"
    ],
    "title": "SubscriptionPublic"
}

{
    "detail": [
        {
            "loc": [
                null
            ],
            "msg": "string",
            "type": "string",
            "input": null,
            "ctx": {}
        }
    ]
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "detail": {
            "items": {
                "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
        }
    },
    "type": "object",
    "title": "HTTPValidationError"
}

GET /api/v1/subscriptions/{subscription_id}

Read Subscription

Description

Get a specific subscription. Superuser can access any subscription, users can only access their own.

Input parameters

Parameter In Type Default Nullable Description
OAuth2PasswordBearer header string N/A No
subscription_id path string No

Responses

{
    "id": "26d7d8fe-6253-40d6-b36b-e16ed2d16832",
    "created_at": "2022-04-13T15:42:05.901Z",
    "updated_at": "2022-04-13T15:42:05.901Z",
    "user_id": "252fa972-ca71-47be-b183-274dff15f1a5",
    "service_type": "SELF_SERVICE",
    "tier": "START",
    "start_date": "2022-04-13T15:42:05.901Z",
    "end_date": "2022-04-13T15:42:05.901Z",
    "grace_period_end": "2022-04-13T15:42:05.901Z",
    "credits_total": 0,
    "credits_used": 0,
    "credits_remaining": 0,
    "is_active": true,
    "payment_status": "PENDING",
    "base_price": 10.12,
    "actual_price": 10.12,
    "currency": "string"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
        },
        "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
        },
        "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
        },
        "user_id": {
            "type": "string",
            "format": "uuid",
            "title": "User Id"
        },
        "service_type": {
            "$ref": "#/components/schemas/ServiceType"
        },
        "tier": {
            "$ref": "#/components/schemas/SubscriptionTier"
        },
        "start_date": {
            "type": "string",
            "format": "date-time",
            "title": "Start Date"
        },
        "end_date": {
            "type": "string",
            "format": "date-time",
            "title": "End Date"
        },
        "grace_period_end": {
            "type": "string",
            "format": "date-time",
            "title": "Grace Period End"
        },
        "credits_total": {
            "type": "integer",
            "title": "Credits Total"
        },
        "credits_used": {
            "type": "integer",
            "title": "Credits Used"
        },
        "credits_remaining": {
            "type": "integer",
            "title": "Credits Remaining"
        },
        "is_active": {
            "type": "boolean",
            "title": "Is Active"
        },
        "payment_status": {
            "$ref": "#/components/schemas/PaymentStatus"
        },
        "base_price": {
            "type": "number",
            "title": "Base Price"
        },
        "actual_price": {
            "type": "number",
            "title": "Actual Price"
        },
        "currency": {
            "type": "string",
            "title": "Currency"
        }
    },
    "type": "object",
    "required": [
        "id",
        "user_id",
        "service_type",
        "tier",
        "start_date",
        "end_date",
        "grace_period_end",
        "credits_total",
        "credits_used",
        "credits_remaining",
        "is_active",
        "payment_status",
        "base_price",
        "actual_price",
        "currency"
    ],
    "title": "SubscriptionPublic"
}

{
    "detail": [
        {
            "loc": [
                null
            ],
            "msg": "string",
            "type": "string",
            "input": null,
            "ctx": {}
        }
    ]
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "detail": {
            "items": {
                "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
        }
    },
    "type": "object",
    "title": "HTTPValidationError"
}

POST /api/v1/subscriptions/{subscription_id}/renew

Renew Subscription

Description

Renew a subscription (superuser only).

Input parameters

Parameter In Type Default Nullable Description
OAuth2PasswordBearer header string N/A No
payment_id query No
subscription_id path string No

Responses

{
    "id": "391f61c4-58f2-4ade-acb5-bbd39a4f5777",
    "created_at": "2022-04-13T15:42:05.901Z",
    "updated_at": "2022-04-13T15:42:05.901Z",
    "user_id": "a3cc746f-2815-4b55-9e60-21173251ebd5",
    "service_type": "SELF_SERVICE",
    "tier": "START",
    "start_date": "2022-04-13T15:42:05.901Z",
    "end_date": "2022-04-13T15:42:05.901Z",
    "grace_period_end": "2022-04-13T15:42:05.901Z",
    "credits_total": 0,
    "credits_used": 0,
    "credits_remaining": 0,
    "is_active": true,
    "payment_status": "PENDING",
    "base_price": 10.12,
    "actual_price": 10.12,
    "currency": "string"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
        },
        "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
        },
        "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
        },
        "user_id": {
            "type": "string",
            "format": "uuid",
            "title": "User Id"
        },
        "service_type": {
            "$ref": "#/components/schemas/ServiceType"
        },
        "tier": {
            "$ref": "#/components/schemas/SubscriptionTier"
        },
        "start_date": {
            "type": "string",
            "format": "date-time",
            "title": "Start Date"
        },
        "end_date": {
            "type": "string",
            "format": "date-time",
            "title": "End Date"
        },
        "grace_period_end": {
            "type": "string",
            "format": "date-time",
            "title": "Grace Period End"
        },
        "credits_total": {
            "type": "integer",
            "title": "Credits Total"
        },
        "credits_used": {
            "type": "integer",
            "title": "Credits Used"
        },
        "credits_remaining": {
            "type": "integer",
            "title": "Credits Remaining"
        },
        "is_active": {
            "type": "boolean",
            "title": "Is Active"
        },
        "payment_status": {
            "$ref": "#/components/schemas/PaymentStatus"
        },
        "base_price": {
            "type": "number",
            "title": "Base Price"
        },
        "actual_price": {
            "type": "number",
            "title": "Actual Price"
        },
        "currency": {
            "type": "string",
            "title": "Currency"
        }
    },
    "type": "object",
    "required": [
        "id",
        "user_id",
        "service_type",
        "tier",
        "start_date",
        "end_date",
        "grace_period_end",
        "credits_total",
        "credits_used",
        "credits_remaining",
        "is_active",
        "payment_status",
        "base_price",
        "actual_price",
        "currency"
    ],
    "title": "SubscriptionPublic"
}

{
    "detail": [
        {
            "loc": [
                null
            ],
            "msg": "string",
            "type": "string",
            "input": null,
            "ctx": {}
        }
    ]
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "detail": {
            "items": {
                "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
        }
    },
    "type": "object",
    "title": "HTTPValidationError"
}

GET /api/v1/subscriptions/

Read Subscriptions

Description

Get subscriptions. Regular users can only see their subscriptions. Superusers can see all subscriptions.

Input parameters

Parameter In Type Default Nullable Description
OAuth2PasswordBearer header string N/A No
limit query integer 100 No
skip query integer 0 No

Responses

{
    "id": "81dcc2f4-aaf1-4605-970c-879c1bf1f5ec",
    "created_at": "2022-04-13T15:42:05.901Z",
    "updated_at": "2022-04-13T15:42:05.901Z",
    "data": [
        {
            "id": "c4a26a2a-ac1c-421e-a546-2f87c7e1f927",
            "created_at": "2022-04-13T15:42:05.901Z",
            "updated_at": "2022-04-13T15:42:05.901Z",
            "user_id": "56f7cd35-f898-43cf-95db-b098c90be9d4",
            "service_type": "SELF_SERVICE",
            "tier": "START",
            "start_date": "2022-04-13T15:42:05.901Z",
            "end_date": "2022-04-13T15:42:05.901Z",
            "grace_period_end": "2022-04-13T15:42:05.901Z",
            "credits_total": 0,
            "credits_used": 0,
            "credits_remaining": 0,
            "is_active": true,
            "payment_status": "PENDING",
            "base_price": 10.12,
            "actual_price": 10.12,
            "currency": "string"
        }
    ],
    "count": 0
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
        },
        "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
        },
        "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
        },
        "data": {
            "items": {
                "$ref": "#/components/schemas/SubscriptionPublic"
            },
            "type": "array",
            "title": "Data"
        },
        "count": {
            "type": "integer",
            "title": "Count"
        }
    },
    "type": "object",
    "required": [
        "data",
        "count"
    ],
    "title": "SubscriptionsPublic"
}

{
    "detail": [
        {
            "loc": [
                null
            ],
            "msg": "string",
            "type": "string",
            "input": null,
            "ctx": {}
        }
    ]
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "detail": {
            "items": {
                "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
        }
    },
    "type": "object",
    "title": "HTTPValidationError"
}

Schemas

HTTPValidationError

Name Type Description
detail Array<ValidationError>

PaymentStatus

Type: string

ServiceType

Type: string

SubscriptionCreate

Name Type Description
payment_id
service_type ServiceType
tier SubscriptionTier

SubscriptionPublic

Name Type Description
actual_price number
base_price number
created_at string(date-time)
credits_remaining integer
credits_total integer
credits_used integer
currency string
end_date string(date-time)
grace_period_end string(date-time)
id string(uuid)
is_active boolean
payment_status PaymentStatus
service_type ServiceType
start_date string(date-time)
tier SubscriptionTier
updated_at string(date-time)
user_id string(uuid)

SubscriptionsPublic

Name Type Description
count integer
created_at string(date-time)
data Array<SubscriptionPublic>
id string(uuid)
updated_at string(date-time)

SubscriptionTier

Type: string

SubscriptionUpdate

Name Type Description
service_type
tier

ValidationError

Name Type Description
ctx
input
loc Array<>
msg string
type string

Security schemes

Name Type Scheme Description
OAuth2PasswordBearer oauth2