Create an order

Creates an order.

To create or update an order with a specified ID, use the Upsert an order operation.

SecurityAPI Key: SecretApiKey or HTTP: JWT
Request
query Parameters
expand
string

Expand a response to receive a full related object in the _embedded path.

To expand multiple objects, use a comma-separated list. Example: expand=recentInvoice,initialInvoice.

Available arguments are:

  • customer
  • leadSource
  • website
  • shippingRate
  • initialInvoice
  • recentInvoice
  • upcomingInvoice
  • paymentInstrument

For more information, see Expand to include embedded objects.

Request Body schema: application/json

Order resource.

orderType
required
string

Specifies the type of order. An order may be a subscription or a one-time purchase.

customerId
required
string (CustomerId) <= 50 characters

ID of the customer resource.

object

Trial details. To use plan defaults do not send the trial key, or send a null value.

isTrialOnly
boolean
Default: false

Specifies if a subscription ends after a trial period. If this value is true, recurring settings are ignored.

(InvoiceTimeShift (object or null)) or null

Shifts issue time and due time of invoices for this subscription.

This setting overrides plan settings. To use plan settings, set this value to null.

To use multiple plans in one subscription, all plans must have the same billing period, this property enables the customer to subscribe to different plans.

object or null

Recurring interval to override plan settings. To use plan settings, set this value to null.

To use multiple plans in one subscription, all plans must have the same recurring period length.

autopay
boolean
Default: true

Specifies if payment attempts are made automatically. If autopay is enabled, the payment is retrieved from the customer on the renewal date using the payment instrument that is set at paymentInstrumentId, or the default payment instrument on the subscription.

startTime
string or null <date-time>

Date and time when the subscription starts. If this value is null, the current time is used. This value cannot be more than one service period in the past.

renewalTime
string or null <date-time>

Date and time when the subscription renews.

paymentInstrumentId
string or null <= 50 characters

ID of the payment instrument to use for autopay. If this value is not provided, or if the payment instrument is inactive, the customer's default payment instrument is used.

websiteId
required
string <= 50 characters
required
Array of objects (SubscriptionOrOneTimeSaleItem) non-empty

Details of items in the order.

ContactObject (object) or null

Delivery address of the order.

ContactObject (object) or null

Billing address of the order.

abandonTime
string or null <date-time>

Date and time when the pending order is automatically abandoned. If this value is not passed during order creation, a pending order TTL setting is used to calculate the value.

delinquencyPeriod
string or null
Default: null

Length of time, in ISO-8601 durations format, which is added to the due time of the order when setting the delinquency time for all related invoices. When the delinquency time of an invoice is reached, the order is automatically canceled.

If the provided value is null, the order does not change state.

couponIds
Array of strings or null

List of coupons to redeem on the customer and restrict to this order.

For more information, see Coupons.

This parameter uses the following logic:

  • If this parameter is not supplied, applied coupons are not changed.
  • If an empty array is supplied, all applied coupon redemptions are canceled.
  • If a list of coupons is supplied, unapplied coupons in the list are applied. Coupons that have already been applied do not change state. Applied coupons that are not supplied in list are canceled.

If the list of applied coupons on a pending order is changed by this parameter during an order update, the invoice for the order is reissued.

poNumber
string or null

Purchase order number displayed on the issued invoices.

object (Shipping)

Shipping settings.

notes
string

Notes for the customer displayed on the order invoice.

riskMetadata
object or null

Risk metadata. If this value is null, this field uses risk metadata that is captured when creating the payment token.

customFields
object (ResourceCustomFields)

Use custom fields to extend a resource scheme to include custom data that is not provided as a common field. For more information, see Custom fields.

post
/subscriptions
Request samples
application/json
{ "orderType": "subscription-order", "customerId": "cus_0YV7DDSDD1C8DA64KHH2W33CPF", "trial": { "enabled": true, "endTime": "2019-08-24T14:15:22Z" }, "isTrialOnly": false, "invoiceTimeShift": null, "recurringInterval": null, "autopay": true, "startTime": null, "renewalTime": "2019-08-24T14:15:22Z", "paymentInstrumentId": "inst_0YVB8KPKNXCBR9EDX7JHSED75N", "websiteId": "web_0YV7DE4Z26DQSA1AC92FBJ7SEG", "currency": "USD", "items": [ ], "deliveryAddress": { "firstName": "Benjamin", "lastName": "Franklin", "organization": "Rebilly", "address": "36 Craven St", "address2": "string", "city": "Austin", "region": "Texas", "country": "GB", "postalCode": "WC2N 5NF", "dob": "1980-04-01", "jobTitle": "CEO" }, "billingAddress": { "firstName": "Benjamin", "lastName": "Franklin", "organization": "Rebilly", "address": "36 Craven St", "address2": "string", "city": "Austin", "region": "Texas", "country": "GB", "postalCode": "WC2N 5NF", "dob": "1980-04-01", "jobTitle": "CEO" }, "abandonTime": "2019-08-24T14:15:22Z", "delinquencyPeriod": "P7D", "couponIds": [ "string" ], "poNumber": "PO123456", "shipping": { "amount": 0.1, "calculator": "manual" }, "notes": "string", "riskMetadata": null, "customFields": { "foo": "bar" } }
Responses

201

Order created.

401

Unauthorized access. Invalid credentials used.

403

Access forbidden.

422

Invalid data sent.

Response samples
application/json
{ "id": "sub_01HRF27SATGE4Z6PBJE6PD8328", "orderId": "ord_01GYJPRKHBD6ZYHH897QCJMBS4", "orderType": "subscription-order", "customerId": "cus_0YV7DDSDD1C8DA64KHH2W33CPF", "renewalReminderTime": "2019-08-24T14:15:22Z", "renewalReminderNumber": 0, "trialReminderTime": "2019-08-24T14:15:22Z", "trialReminderNumber": 0, "abandonReminderTime": "2019-08-24T14:15:22Z", "abandonReminderNumber": 0, "organizationId": "org_0YVDM8RC7GDADADSBSMW124JA8", "status": "pending", "inTrial": true, "trial": { "enabled": true, "endTime": "2019-08-24T14:15:22Z" }, "isTrialOnly": false, "isTrialConverted": true, "invoiceTimeShift": null, "recurringInterval": null, "autopay": true, "startTime": null, "churnTime": "2019-08-24T14:15:22Z", "renewalTime": "2019-08-24T14:15:22Z", "rebillNumber": 0, "lineItems": [ ], "lineItemSubtotal": { "currency": "USD", "amount": 49.95 }, "paymentInstrumentId": "inst_0YVB8KPKNXCBR9EDX7JHSED75N", "billingStatus": "draft", "websiteId": "web_0YV7DE4Z26DQSA1AC92FBJ7SEG", "currency": "USD", "initialInvoiceId": "in_0YVF9605RKC62BP14NE2R7V2XT", "recentInvoiceId": "in_0YVF9605RKC62BP14NE2R7V2XT", "items": [ ], "deliveryAddress": { "firstName": "Benjamin", "lastName": "Franklin", "organization": "Rebilly", "address": "36 Craven St", "address2": "string", "city": "Austin", "region": "Texas", "country": "GB", "postalCode": "WC2N 5NF", "dob": "1980-04-01", "jobTitle": "CEO", "hash": "056ae6d97c788b9e98b049ebafd7b229bf852221" }, "billingAddress": { "firstName": "Benjamin", "lastName": "Franklin", "organization": "Rebilly", "address": "36 Craven St", "address2": "string", "city": "Austin", "region": "Texas", "country": "GB", "postalCode": "WC2N 5NF", "dob": "1980-04-01", "jobTitle": "CEO", "hash": "056ae6d97c788b9e98b049ebafd7b229bf852221" }, "activationTime": "2019-08-24T14:15:22Z", "voidTime": "2019-08-24T14:15:22Z", "abandonTime": "2019-08-24T14:15:22Z", "delinquencyPeriod": "P7D", "poNumber": "PO123456", "shipping": { "amount": 0.1, "calculator": "manual" }, "notes": "string", "canceledBy": "merchant", "cancelCategory": "billing-failure", "cancelDescription": "string", "revision": 0, "riskMetadata": null, "billingPortalToken": "string", "customFields": { "foo": "bar" }, "createdTime": "2019-08-24T14:15:22Z", "updatedTime": "2019-08-24T14:15:22Z", "_links": [ ], "_embedded": { "recentInvoice": { }, "initialInvoice": { }, "customer": { }, "website": { }, "leadSource": { }, "shippingRate": { }, "paymentInstrument": { }, "upcomingInvoice": { } } }