Create sales order
The Create sales order method is used to create a sales order for purchasing a new subscription at the plan prices for an account of the current reseller or any of its downstream resellers. The standard logic of the platform is used (see ordering subscriptions).
Ordering an SSL certificate or a domain subscription is available in the API v1 method Create an order only (see Создание Заказа).
Ordering a subscription at the individual prices or the individual markup is available in the Operator Control Panel only (see ordering subscriptions).
Ordering a subscription with additional attributes (like Microsoft or Google services) requires several steps to be completed sequentially:
An API token of a manager is required for authorization. To get an API token via the Operator Control Panel, see Viewing and updating manager's information.
The manager's API token specified in an API request determines:
- The role and access level of the manager, which determine the availability of a method.
- The current reseller and downstream resellers accessible within a method.
POST {base_url}/api/v3/resellers/{reseller_id}/sales_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 Viewing and updating manager's information) | ||||
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 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 | ||||
account_id | form | integer | Required | ID of the account | ||||
plan_id | form | integer | Required | ID of the plan | ||||
plan_period_id | form | integer | Required | ID of the period of the plan | ||||
payment_model | form | string | Required | Payment model for the subscription:
| ||||
subscription_credit_limit_use_system | form | bool | Optional | Shows whether the ordered subscription will use the default subscription credit limit value:
For postpaid subscriptions only ( | ||||
subscription_credit_limit | form | number | Optional | The value of the subscription credit limit that is redefined on the subscription level ( For postpaid subscriptions only ( | ||||
provisioning_date | form | string | Optional | The provisioning date for a delayed order (YYYY-MM-DD). It is possible to specify any date between the current date and the current day + 15 days. See Delayed ordering a subscription | ||||
resources | form | object | Optional | List of resources in the order. Required if at least one resource has non-zero included or additional amount | ||||
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 | ||||
additional | form | integer | Optional | Additional amount of the plan resource above included (see Plan Resources) | ||||
account_product_managers | form | object | Optional | Responsible managers of the account (see Managing responsible managers) | ||||
data | form | array | Optional | Information about responsible managers for the account within the product linked to the specified plan | ||||
manager_product_role_id | form | integer | Optional | Manager role ID within the product | ||||
responsible_product_manager_id | form | integer | Optional | Responsible manager ID within the product | ||||
promo_code | form | string | Optional | Promo-code for a discount | ||||
task_id | form | string | Optional | ID of an asynchronous task within which validation of additional attributes was performed — required if ordering a subscription requires additional attributes (like Microsoft or Google services) |
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.
For ordering a postpaid subscription when manual approval of a manager is required for an account (see Managing account's permission to use the Postpay model), if no errors are encountered, the method returns information about the created manual operation.
Name
Data type
Description
postpay_verification object Information about account's permission to use the Postpay model manual_operation_id
integer
Manual operation ID
Errors
Status | Error text | Comment |
---|---|---|
422 | Can not order subscription to plan with id | The plan should have the Active status (see Get list of plans) |
The period id is not available for ordering | The plan period is not available in the plan | |
Account with id is not found | To create an order, specify an existing account of the reseller (see Get list of accounts) | |
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 plan | |
The resource id is not available for ordering in plan | The resource is not available in the 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 order cannot be completed: the monthly payment for the subscription has exceeded the credit limit | To create the order, it is necessary to increase the credit limit of the account or individual credit limit of the subscription | |
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 | |
You cannot order service plan to this account because service plan is unavailable for such account type | To create an order, specify an account with different account type (see available_account_types in Get plan) | |
You cannot order service plan to this account because service plan is trial and this account was blocked | For accounts in the Credit hold status, only paid subscriptions are available for ordering | |
You cannot order service plan to this account because account is in S | For accounts in this status, ordering new subscriptions is not available | |
You cannot order service plan to this account because service plan is singleton and this account already has subscription of this service plan in status S | An account can have only one subscription to a singleton plan | |
You cannot order additional resources for the trial period | To create a sales order for a trial subscription, for all resources, specify the additional amount equal to 0 | |
Trial period can not be ordered: minimum resource quantity greater included resource quantity | Ordering a trial subscription with this configuration of resources is not available | |
Order for the selected account is not available due to restrictions imposed on the account or reseller | The validation service (see Managing the validation service) 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 Managing the validation service) 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 Managing attributes) and then try again | |
The provisioning date can be set as the date from {current date} to {current day + 15 days} | The specified provisioning_date is out of the allowed interval | |
Such role is not configured in product | If it is necessary to attach a responsible manager to an account, specify the following data:
| |
Manager with id is not responsible product manager |
Request example
POST /api/v3/resellers/1/sales_order
Host: test.activeplatform.com
Content-Type: application/vnd.api+json
X-Api-Token: vY5fwetestK3gJXZH5uHCw
Accept: application/vnd.api+jsonon
{
"data": {
"attributes": {
"account_id": "710",
"plan_id": 1598,
"plan_period_id": 2808,
"payment_model": "prepay",
"provisioning_date": "2022-03-01",
"resources": {
"data": [
{
"plan_resource_id": 4340,
"additional": 2
}
]
},
"promo_code": ""
}
}
}
Response example
{
"data": {
"id": "12187",
"type": "sales_orders",
"attributes": {
"created_at": "2020-11-11T09:59:59.644+03:00",
"updated_at": "2020-11-11T09:59:59.875+03:00",
"document_id": "SO006650",
"status": "waiting_for_payment",
"account_id": 710,
"type": "SalesOrder",
"closed_at": null,
"expiration_date": "2022-03-03",
"provisioning_date": "2020-11-11",
"total": "160.0",
"promo_code": "",
"payment_id": 9264,
"manager_id": 225,
"requester_ip": null,
"custom_price": false,
"created_by": "#225 Sales Manager",
"subscription_id": 3007747,
"items": [
{
"id": 35924,
"target_id": 3012374,
"target_type": "Subscription",
"type": "ProvisioningItem::New",
"status": "completed",
"description": "Autoprovisioning Plan 1",
"quantity": 1
},
{
"id": 35925,
"target_id": 49964,
"target_type": "SubscriptionResource",
"type": "ProvisioningItem::Upgrade",
"status": "completed",
"description": "Resource 1",
"quantity": 1,
"resource_id": 152581
}
]
},
"relationships": {
"charges": {
"data": [
{
"id": "312660",
"type": "charges"
}
]
}
}
}
}