POST
Create a new subscription for a user
Creates a new subscription for a user after checking for unpaid invoices and valid payment methods.
Authorizations
| Name | Type | Required | Description |
|---|---|---|---|
| bearerAuth | http | Yes | Bearer token for authentication. Include in the Authorization header as 'Bearer <token>'. The token can be obtained through your account dashboard. |
Request Body
Required: Yes
Description: An object containing the plan details for the new subscription.
| Name | Type | Required | Description |
|---|---|---|---|
plan_code string No The code of the plan to subscribe to. | |||
curl --request POST \
--url https://globalbyte.io/api/v1/user/subscriptions \
--header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
--header 'content-type: application/json' \
--data '{"plan_code":"mobile_proxy_2_monthly_extended"}'Responses
Code: 200
Description: Subscription created successfully
Content Type: application/json
| Name | Type | Required | Description |
|---|---|---|---|
success boolean No Indicates the subscription was successfully created. | |||
subscriptionId string No The ID of the newly created subscription. | |||
Code: 302
Description: Redirect due to unpaid invoices or missing payment method
Content Type: application/json
| Name | Type | Required | Description |
|---|---|---|---|
redirect string No A URL or path to which the user should be redirected. | |||
message string No A message explaining the issue blocking subscription creation. | |||
unpaidInvoices string[] No Array of unpaid invoice IDs (UUID v4). Only included when redirect is to invoices page. | |||
Code: 400
Description: Bad request.
Content Type: application/json
| Name | Type | Required | Description |
|---|---|---|---|
message string No Human-readable message describing the bad request. | |||
Code: 401
Description: Unauthorized access.
Content Type: application/json
| Name | Type | Required | Description |
|---|---|---|---|
message string No Human-readable message describing the unauthorized error. | |||
Code: 500
Description: Error response.
Content Type: application/json
| Name | Type | Required | Description |
|---|---|---|---|
message string No Human-readable message describing the error. | |||
{
"success": true,
"subscriptionId": "123e4567-e89b-12d3-a456-426614174000"
}{
"redirect": "/dashboard/account/payment-methods",
"message": "You must add a payment method before creating a subscription."
}{
"message": "Invalid input provided."
}{
"message": "API token missing from headers."
}{
"message": "Error message"
}