Create switch order

The Create switch order method is used to create a switch plan order for a subscription for the current reseller or any of its downstream resellers. The standard logic of the platform is used (see ).

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 a manager that performs the operation (see


)

Content-Type

header

string

Required

Media type of the request. Specify the following: application/vnd.api+json

Accept

header

string

Required

Supported media types of the answer. Specify the following: application/vnd.api+json

base_url

path

string

Required

ActivePlatform URL

reseller_id

path

integer

Required

ID of the current reseller or any of its downstream resellers (see 


)

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

Optional

List of resources in the order. Required if at least one resource has non-zero included or additional amount (see


)




data

form

array

Optional

Information about resources in the order. Required for resources with non-zero included or additional amount





plan_resource_id

form

integer

Optional

ID of the plan resource





quantity

form

integer

Optional

Target amount of the plan resource



promo_code

form

string

Optional

Promo-code for a discount



switch_type

form

string

Required

The type of switch (see ):

  • immediate_switch — the immediate switch.

  • delayed_switch — the delayed switch.

Response model

If no errors are encountered, the method returns data as the information about the created order (see the response model in Get order). Status: 201 Created.

Errors

Status

Error text

Comment

403

This action is forbidden

Check the list of available operations for the subscription (see 

Get subscription

)

422

Can not switch to plan with id

The target plan should have the Active status and be among the switchable plans (see 

Get list of 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:

  • The plan period is not available in the target plan.

  • The plan period with the specified ID does not exist.

  • The plan period is trial.

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 


) or individual credit limit of the subscription (see 


)

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

Order for the selected account is not available due to restrictions imposed on the account or reseller

The validation service (see


) determined that restrictions are imposed on the reseller or account. Creating an order is not available for the product linked to the specified plan (see

Get plan

)

Order for the selected service is not available. service for checking the restrictions imposed on the account or reseller is not available. Please try to place order later

The validation service (see


) failed to check the reseller and account. To create an order, try again later or contact the support team

The account or reseller does not have the INN attribute

To create an order, create and specify the INN attribute for the reseller or account (see


) and then try again

Request example

XML
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
JSON
{
    "data": {
        "attributes": {
            "subscription_id": 3007437,
            "plan_id": 18,
            "plan_period_id": 2545,
            "resources": {
                "data": [
                    {
                        "plan_resource_id": 1577,
                        "quantity": 2
                    }
                ]
            },
            "promo_code": "",
            "switch_type": "immediate_switch"
        }
    }
}

Response example

JSON
{
    "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": 49964,
                    "target_type": "SubscriptionResource",
                    "type": "ProvisioningItem::Upgrade",
                    "status": "completed",
                    "description": "res2",
                    "quantity": 2,
                    "resource_id": 152581
                },
                {
                    "id": 17996,
                    "target_id": 3007437,
                    "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"
                    }
                ]
            }
        }
    }
}