Create a Switch Order
The Create a Switch Order method is used to create a Switch Order for a Subscription for the current Reseller or any of its downstream Resellers. The standard logic of the platform is used (see Switching a plan).
Access to the current Reseller and downstream Resellers is determined by the Manager's token in the API request.
POST {base_url}/api/v3/resellers/{reseller_id}/switch_order
Arguments
Name | Parameter Type | Data type | Required/Optional | Description | ||||
---|---|---|---|---|---|---|---|---|
X-Api-Token | header | string | Required | API token of the Manager that performs the operation (see Viewing and updating manager's information) | ||||
Content-Type | header | string | Required | Indicates the media type (text/html or text/JSON) of the request that is sent to the server by the client (browser) | ||||
Accept | header | string | Required | Information about data types that the client (browser) supports | ||||
reseller_id | path | integer | Required | ID of the current Reseller or any of its downstream Resellers (see Viewing and updating reseller general information) | ||||
data | form | object | Required | Information about the attributes of the operation | ||||
attributes | form | object | Required | Attributes of the operation | ||||
subscription_id | form | integer | Required | ID of the Subscription | ||||
plan_id | form | integer | Required | ID of the target Plan | ||||
plan_period_id | form | integer | Required | ID of the Period of the target Plan | ||||
resources | form | object | Required | List of Resources in the Order | ||||
data | form | array | Required | Information about a Resource | ||||
plan_resource_id | form | integer | Required | ID of the Plan Resource | ||||
quantity | form | integer | Required | Target amount of the Plan Resource | ||||
promo_code | form | string | Optional | Promo-code for a discount |
Response model
If no errors are encountered, the method returns data as the information about the created Order (see the Response model in Get the Reseller's Order Info by ID).
Errors
Status | Error text | Comment |
---|---|---|
403 | This action is forbidden | Check the list of available operations for the Subscription (see Get the Reseller's Subscription information by ID) |
422 | Can not switch to plan with id | The target Plan should have the Active status and be among the switchable Plans (see Get a List of the Reseller's switchable Plans) |
The period id is not available for ordering in plan | The Plan period is not available for switching due to one of the following reasons:
| |
There are ordered invalid amount of resources | It is necessary to decrease or increase the ordered amount of the Resource to fit the available range specified in the target Plan | |
The order cannot be completed: the order total has exceeded the credit limit for this subscription | To create the Order, it is necessary to increase the Credit limit of the Account (see Viewing and updating account's details) or individual Credit limit of the Subscription (see Viewing and updating subscription's details) | |
The Resource id is not available for ordering in plan | The Resource is not available in the target Plan | |
The Resource id must be ordered | It is necessary to add the required Resource in the Order because, in the target Plan, the Resource has the minimal amount greater than 0 |
Request example
POST /api/v3/resellers/1/switch_order
Host: test.activeplatform.com
Content-Type: application/vnd.api+json
X-Api-Token: vY5fwetestK3gJXZH5uHCw
Accept: application/vnd.api+jsonon
{
"data": {
"attributes": {
"subscription_id": 3007437,
"plan_id": 18,
"plan_period_id": 2545,
"resources": {
"data": [
{
"plan_resource_id": 1577,
"quantity": 2
}
]
},
"promo_code": ""
}
}
}
Response example
{
"data": {
"id": "11716",
"type": "switch_plan_orders",
"attributes": {
"created_at": "2021-01-07T04:40:37.744+03:00",
"updated_at": "2021-01-07T04:40:38.880+03:00",
"document_id": "CH000792",
"status": "completed",
"account_id": 317,
"type": "SwitchPlanOrder",
"closed_at": "2021-01-07T04:40:38.880+03:00",
"expiration_date": "2021-02-05",
"provisioning_date": null,
"total": "-97.43",
"promo_code": "",
"payment_id": null,
"manager_id": 217,
"requester_ip": null,
"custom_price": false,
"created_by": "#217 Vitaly Fox",
"subscription_id": 3007437,
"items": [
{
"id": 17997,
"target_id": "SubscriptionResource",
"target_type": "SubscriptionResource",
"type": "ProvisioningItem::Upgrade",
"status": "completed",
"description": "res2",
"quantity": 2
},
{
"id": 17996,
"target_id": "Subscription",
"target_type": "Subscription",
"type": "ProvisioningItem::SwitchPlan",
"status": "completed",
"description": "Autoprovisioning with res2",
"quantity": "1"
}
]
},
"relationships": {
"charges": {
"data": [
{
"id": "96892",
"type": "charges"
},
{
"id": "96893",
"type": "charges"
}
]
}
}
}
}