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
⚠️ 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": "afb59317-8b2f-4b7c-9aa1-360b212a396e",
"created_at": "2022-04-13T15:42:05.901Z",
"updated_at": "2022-04-13T15:42:05.901Z",
"user_id": "79e97252-b21b-47b7-b916-0df2bf39c93b",
"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"
}
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"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.
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
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.
Responses
{
"id": "c6591091-94b6-4074-a74c-35cdee3a398b",
"created_at": "2022-04-13T15:42:05.901Z",
"updated_at": "2022-04-13T15:42:05.901Z",
"user_id": "8ee4f124-5143-4a7c-aeb9-d89b9a6b59fb",
"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"
}
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"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.
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": "5e9a8fb7-bc60-4725-8122-bcd44b66a9ba",
"created_at": "2022-04-13T15:42:05.901Z",
"updated_at": "2022-04-13T15:42:05.901Z",
"user_id": "1f68e462-6811-4ad9-97ac-6f7e7b8edf47",
"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"
}
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"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.
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": "11ab5e6e-7d27-4f77-90fd-5c1acd4afbdb",
"created_at": "2022-04-13T15:42:05.901Z",
"updated_at": "2022-04-13T15:42:05.901Z",
"user_id": "dad72a8f-21b2-4048-b05e-b713c1193591",
"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"
}
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"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.
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": "98a6fc62-52bf-4df4-b6d4-088fffa08ad2",
"created_at": "2022-04-13T15:42:05.901Z",
"updated_at": "2022-04-13T15:42:05.901Z",
"data": [
{
"id": "e42e2748-68a4-4155-85e4-816ebe3fdec2",
"created_at": "2022-04-13T15:42:05.901Z",
"updated_at": "2022-04-13T15:42:05.901Z",
"user_id": "c7a6aea8-b85c-4c7f-91c7-11f45017e385",
"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
}
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"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.
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 |