LayerStack API

Choose a category from the left to browse the available API commands.

Order


Order

Order is the entity that handles purchasing of our service plans.

Endpoints Summary

Endpoint (Click to read full specification) Method Description
/order/ POST places an order.
/order/add-to-cart POST add a cart item. returns the cart item id. Carts items can be added to orders to place
/order/cartItems/delete/{cart_item_id} DELETE deletes the specified cart item
/order/changeorder/ POST Places a Change order, which is for adding add ons to existing subscriptions.
/order/changeorder/total GET Calcuates the change order total before placing the change order. Also check if the change order can be placed. This api call does not actually place a change order.

Create Order

Request: POST /order

Name Type Description
account string (requiried) account id referred to in format of XX-11111111
currency string currency of order. only required if account has no currency set . The currency is set when there is a first order placed in your account and cannot be changed. If the account currency is already set, this field is ignored.
label string label of cloud server
cartItems array array of cart items id, obtained from POST /order/add-to-cart api
payment_type string currently, only credit cart payment is accepted, therefore the value of this parameter is ccard.

Create Cart Item

Request: POST /order/add-to-cart

Name Type Description
billing_cycle int (requiried) 1: monthly, 3: quarterly, 12: annually
plan_id int plan id. Refer to here for available IDs.
plan_type string currrently only cloud_servers_standard(General Purpose Cloud Server), cloud_servers_highmemory (Memory Optimized Cloud Server), cloud_servers_dedicatedcpu (Dedicated CPU Cloud Server), and cloud_servers_highstorage_sas (High Storage Cloud Server) are supported
quantity int the quantity of this item to add to cart
addons array optional "addons":[0: {id: 6, additional_value: 1}] . Refer to here for available IDs.
password string password of Cloud Server if the plan_type is cloud_servers_standard, cloud_servers_highmemory, cloud_servers_highstorage, cloud_servers_highfrequency, cloud_servers_dedicatedcpu or cloud_servers_highstorage_sas. This field is not required if the plan_type are other types.
os_template_id int os template id for cloud servers. this field is not required for other plan types. Refer to this link for os template ids.
custom_ssh_key string base64 encoded string of ssh key. Only default linux templates supports custom_ssh_key. Windows and custom templates do not support ssh keys.
custom_script string base64 encoded string of custom script to run at provisioning time. Only default linux templates supports custom scripts. Windows and custom templates do not support custom scripts.

Sample Response:

{
    "0": 995,   // cart_item_id
    "data": {
        "message": "Cart Items added successfully",
        "code": 200
    }
}

Delete Cart Item

Request: DELETE /order/cartItems/delete/{cart_item_id} where cart_item_id is the cart item id (obtained from POST /order/add-to-cart api) to be deleted.

Change Order

Request: POST /order/changeorder

Name Type Description
subscription_id int subscription id
resources array Key-value array {resource_name: resource->name, delta_value: value} format. Available resources are vm_backup, china_route, vm_antiddos.

Sample Payload:

{
"subscription_id": 4158,
"resources" : [{"resource_name": "vm_backup", "delta_value":"1"}]

}

Change Order Total

Request: PUT /order/changeorder/total

Name Type Description
subscription_id int subscription id
resources array Key-value array {resource_name: resource->name, delta_value: value} format. Available resources are vm_backup, china_route, vm_antiddos.

The payload is the same as Change Order API above.

Sample Response:

{
    "available": true,
    "total": 19.06,
    "currency": "hkd",
    "date_from": "2020-04-23",
    "date_to": "2020-05-22",
    "inapplicable_resources": []
}

Switch Order

Request: PUT /order/switch/{subscription_id}

Name Type Description
plan_id int target plan's id. this plan need to have the same type as current plan

Sample Response:

{
    "available":true,
    "total":118.68,
    "currency":"hkd",
    "date_from":"2021-03-09",
    "date_to":"2021-03-28"
}

Switch Order Total

Request: PUT /order/switch/total

Name Type Description
subscription_id int subscription id
plan_id int target plan's id. this plan need to have the same type as current plan

Sample Response:

{
    "available":true,
    "total":118.68,
    "currency":"hkd",
    "date_from":"2021-03-09",
    "date_to":"2021-03-28"
}