Create a Sales Order

The Create a Sales Order method is used to create a Sales Order for 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 Create an Order).

Ordering a Subscription at the individual prices or the individual markup is available in the Operator Control Panel only (see Ordering subscriptions).

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}/sales_order

Arguments

Name

Parameter Type

Data type

Required/Optional

Description

X-Api-TokenheaderstringRequiredAPI token of the Manager that performs the operation (see Viewing and updating manager's information)
Content-TypeheaderstringRequiredIndicates the media type (text/html or text/JSON) of the request that is sent to the server by the client (browser)
AcceptheaderstringRequired

Information about data types that the client (browser) supports

reseller_idpathintegerRequiredID of the current Reseller or any of its downstream Resellers (see Viewing and updating reseller general information)
dataformobjectRequiredInformation about the attributes of the operation

attributesformobjectRequiredAttributes of the operation


account_idformintegerRequired ID of the Account 


plan_idformintegerRequiredID of the Plan


plan_period_idformintegerRequiredID of the Period of the Plan


payment_modelformstringRequired

Payment model for the Subscription:

  • prepay 
  • postpay


subscription_credit_limit_use_systemformboolOptional

Shows whether the ordered Subscription will use the default Subscription credit limit value:

  • true — the Subscription will use the Subscription credit limit value that is set in the Account class or redefined on the Account level.
  • false — Subscription will use the Subscription credit limit value that is redefined on the Subscription level (see subscription_credit_limit).

For postpaid Subscriptions only (payment_model = postpay)



subscription_credit_limitformfloatOptional

The value of the Subscription credit limit that is redefined on the Subscription level (subscription_credit_limit_use_system = false).

For postpaid Subscriptions only (payment_model = postpay)



resourcesformobjectOptional
List of Resources in the Order. Required if at least one Resource has non-zero included or additional amount



dataformarrayOptionalInformation about Resources in the Order. Required for Resources with non-zero included or additional amount




plan_resource_idformintegerOptionalID of the Plan Resource




additionalformintegerOptionalAdditional amount of the Plan Resource above included (see Plan Resources)


account_product_managersformobjectOptionalResponsible Managers of the Account (see Managing responsible managers)



dataformarrayOptionalInformation about Responsible Managers for the Account within the Product linked to the specified Plan




manager_product_role_idformintegerOptionalManager Role ID within the Product




responsible_product_manager_idformintegerOptionalResponsible Manager ID within the Product


promo_codeformstringOptionalPromo-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). 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_verificationobjectInformation about Account's permission to use the Postpay model


    manual_operation_id

    integer

    Manual Operation ID

Errors

StatusError textComment
422Can not order subscription to plan with idThe Plan should have the Active status (see Get a List of the Reseller's Plans)
The period id is not available for orderingThe Plan period is not available in the Plan
Account with id is not foundTo create an Order, specify an existing Account of the Reseller (see Get a List of the Reseller's Accounts)
There are ordered invalid amount of resourcesIt 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 planThe Resource is not available in the Plan
The order cannot be completed: the order total has exceeded the credit limit for this subscriptionTo 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 limitTo 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 orderedIt 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 typeTo create an Order, specify an Account with different Account type (see available_account_types in Get the Reseller's Plan information by ID)
You cannot order service plan to this account because service plan is trial and this account was blockedFor 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 SFor 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 SAn Account can have only one Subscription to a singleton Plan
You cannot order additional resources for the trial periodTo create a Sales Order for a trial Subscriptionfor all Resources, specify the additional amount equal to 0
Trial period can not be ordered: minimum resource quantity greater included resource quantityOrdering 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 resellerThe Validation Service (see Managing the validation service) determined that sanctions are imposed on the Reseller or Account. Ordering new Subscriptions is not available for the Product linked to the specified Plan (see Get the Reseller's Plan information by ID)
Order for the selected service is not available. Service for checking the restrictions imposed on the account or reseller is not responding. Please try to place order laterThe Validation Service (see Managing the validation service) failed to check the Reseller and Account. To create an Order, contact the support team or try again later
The account or reseller does not have the INN attributeTo create an Order, create and specify the INN attribute for the Reseller or Account first (see Managing attributes) and then try again
Such role is not configured in product

If it is necessary to attach a Responsible Manager to an Account, specify the following data:

  1. ID of a Manager Role existing within the Product linked to the specified Plan (see Managing roles of responsible managers).
  2. ID of a User assigned as a Responsible Manager with the specified Manager Role to the Product linked to the specified Plan (see Managing responsible managers)
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",
            "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": "2020-11-12",
            "provisioning_date": null,
            "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": 20865,
                    "target_id": "Subscription",
                    "target_type": "Subscription",
                    "type": "ProvisioningItem::New",
                    "status": "waiting_for_payment",
                    "description": "Clean CSPmonthly",
                    "quantity": 1
                },
                {
                    "id": 20866,
                    "target_id": "SubscriptionResource",
                    "target_type": "SubscriptionResource",
                    "type": "ProvisioningItem::Upgrade",
                    "status": "waiting_for_payment",
                    "description": "HDD",
                    "quantity": 2
                }
            ]
        },
        "relationships": {
            "charges": {
                "data": [
                    {
                        "id": "312660",
                        "type": "charges"
                    }
                ]
            }
        }
    }
}