Create New Commerce Orders ========================== Prerequisites ^^^^^^^^^^^^^ - Credentials as described in :doc:`/getting-started/authentication` - For Product information PartNumber, BillingCycle and TermDuration go to :doc:`/scenarios/agreementproducts-get`. :doc:`/scenarios/subscription-create` endpoint also works with Nce subscriptions, but users can use this simplified endpoint to purchase a new commerce subscription, which combines the :doc:`/scenarios/ordering-verify` and :doc:`/scenarios/ordering-checkout` endpoints into a single call. Request ^^^^^^^ Request Syntax: +---------+------------------------------------------------------------------+ | Method | Request URI | +=========+==================================================================+ | POST | https://api.crayon.com/api/v1/subscriptions/new-commerce-orders | +---------+------------------------------------------------------------------+ Request Body: .. literalinclude:: /scenarios/_static/SubscriptionNceOrderRequest.json :language: json Properties: +-------------------------+------------------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------+ | Name | Type | Required | Description | +=========================+==========================================+================+==========================================================================================================================================+ | CustomerTenantId | int | Yes | | +-------------------------+------------------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------+ | BillingCycle | BillingCycleType | Yes | Billing cycle. Unknown = 0, Monthly = 1, Annual = 2, None = 3, OneTime = 4, Triennial = 5 | +-------------------------+------------------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------+ | PartNumber | string | Yes | | +-------------------------+------------------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------+ | Quantity | int | Yes | | +-------------------------+------------------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------+ | TermDuration | string | Yes | An ISO 8601 representation of the term's duration. Supported values are: "P1M" for (1 month), "P1Y" for (1 year) and "P3Y" for (3 years).| +-------------------------+------------------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------+ | CustomTermEndDate | DateTime | No | Applicable for coterminosity scenarios. Supported values are returned by the get coterminosity dates endpoint | +-------------------------+------------------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------+ | ScheduledDate | DateTime | No | Provide date if you want schedule the processing of your order. Do not fill / leave empty (null) if you want to place regular order. | +-------------------------+------------------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------+ Response ^^^^^^^^ If successful, the following json is returned in the response body. .. literalinclude:: /scenarios/_static/SubscriptionNceOrderResponse.json :language: json Response success and error codes: Each response comes with an HTTP status code that indicates success or failure and additional debugging information. Use a network trace tool to read this code, error type, and additional parameters. +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Error Codes | Description | +================================+===========================================================================================================================================================================================================================================================================================+ | 200 Ok | The request has succeeded. | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 400 Bad Request | The request could not be understood by the server due to malformed syntax, missing required properties, properties that couldn't be parsed according to their type (and length). It is a non-retryable error condition. The client should not repeat the request without modifications. | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 401 Unauthorized | The request requires user authentication. If the request already included Authorization credentials, then the 401 (Unauthorized) status code means that authorization has been refused for those credentials. It is a non-retryable error condition. | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 404 Not Found | The server has not found anything matching the request. | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Get id of newly created subscription ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A user can use below endpoint to retrieve the subscription id of the newly created subscription. :doc:`/scenarios/subscriptions-new-commerce-orders-get-by-id`