Create an order

Request

Creates an order.
Security
SecretApiKey or JWT
Query
expandstring

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

To expand multiple objects, use a comma-separated list. Example: expand=customer,activationInvoice.

Available arguments are:

  • customer
  • activationInvoice
  • recentInvoice
  • upcomingInvoice
  • paymentInstrument
  • website

For more information, see Embedded resources.

Bodyapplication/json
Order resource.
typestringrequired
Type of the order.
Discriminator
Value:"recurring"
customerIdstring, <= 50 characters(CustomerId)required
ID of the customer resource.
Example:"cus_0YV7DDSDD1C8DA64KHH2W33CPF"
websiteIdstring, <= 50 characters(WebsiteId)required
Example:"web_0YV7DE4Z26DQSA1AC92FBJ7SEG"
trialobject

Details of the trial. To use plan defaults, omit the trial key or set this value to null.

isTrialOnlyboolean

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

Default:false
itemsArray of objects, non-emptyrequired
Item in the order.
invoiceIssueTimeShiftstring

Invoice issue time shift interval in ISO-8601 format.

This field adjusts the issue date and time of renewal invoices for the order.

This interval value supports the - symbol.

Default:"+P00Y00M00DT00H00M00S"
Example:"+P00Y00M00DT00H00M00S"
invoiceDueTimeShiftstring

Invoice due time shift interval in ISO-8601 format.

Use this field to adjust when payment is due for the order. If autopay is configured, payment is collected automatically on this date.

This interval value supports the + symbol.

Default:"+P00Y00M00DT00H00M00S"
Example:"+P00Y00M00DT00H00M00S"
paymentInstrumentIdstring 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.
Example:"inst_0YVB8KPKNXCBR9EDX7JHSED75N"
poNumberstring or null
Purchase order number that is displayed on the issued invoices.
Example:"PO123456"
sandboxRetentionobject or null(SandboxRetention)

Sandbox recurring order retention. In the sandbox environment, a recurring order is canceled 90 days after it is created or on the start date of the policy, whichever is later. The order is not canceled if it is retained or if the organization is excluded from the policy. This property is returned in the sandbox environment only, for recurring orders. In the live environment, if the request includes this property with a value, a validation error is returned. A null value in a request does not update the property.

notesstring
Notes for the customer that are displayed on the order invoice.
billingAddressContactObject (object) or null
One of:
Contact's information.
deliveryAddressContactObject (object) or null
One of:
Contact's information.
delinquencyPeriodstring or 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.

Default:null
Example:"+P00Y00M07DT00H00M00S"
couponIdsArray of strings or nullwrite-only

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.

riskMetadataRisk metadata (object) or null
One of:
Risk metadata used for 3D Secure and risk scoring.
startTimestring 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.

Default:null
Example:null
shippingobject(Shipping)
autopayboolean

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 order.

Default:true
abandonTimestring 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.

customFieldsobject(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.

Default:{}
Example:
{ "foo": "bar" }
currentPeriodEndstring or null, (date-time)
Date and time of the current service period end. If subscriptions have different recurring settings or the order is not active, providing this field causes the request to be rejected with a conflict. This field is ignored if the order is in trial.
curl -i -X POST \
  'https://www.rebilly.com/_mock/catalog/all/orders?expand=string' \
  -H 'Content-Type: application/json' \
  -H 'REB-APIKEY: YOUR_API_KEY_HERE' \
  -d '{
    "type": "recurring",
    "customerId": "cus_0YV7DDSDD1C8DA64KHH2W33CPF",
    "websiteId": "web_0YV7DE4Z26DQSA1AC92FBJ7SEG",
    "trial": {
      "enabled": true,
      "endTime": "2019-08-24T14:15:22Z"
    },
    "isTrialOnly": false,
    "items": [
      {
        "type": "one-time-sale",
        "plan": {
          "id": "4f6cf35x-2c4y-483z-a0a9-158621f77a21"
        },
        "quantity": 0
      }
    ],
    "invoiceIssueTimeShift": "+P00Y00M00DT00H00M00S",
    "invoiceDueTimeShift": "+P00Y00M00DT00H00M00S",
    "paymentInstrumentId": "inst_0YVB8KPKNXCBR9EDX7JHSED75N",
    "poNumber": "PO123456",
    "sandboxRetention": {
      "excluded": false
    },
    "notes": "string",
    "billingAddress": {
      "firstName": "Benjamin",
      "lastName": "Franklin",
      "organization": "Rebilly",
      "address": "36 Craven St",
      "address2": "string",
      "city": "Austin",
      "region": "Texas",
      "country": "GB",
      "postalCode": "WC2N 5NF",
      "phoneNumbers": [
        {
          "label": "main",
          "value": "1-512-777-0269",
          "primary": true
        }
      ],
      "emails": [
        {
          "label": "main",
          "value": "rebilly@example.com",
          "primary": true
        }
      ],
      "dob": "1980-04-01",
      "jobTitle": "CEO"
    },
    "deliveryAddress": {
      "firstName": "Benjamin",
      "lastName": "Franklin",
      "organization": "Rebilly",
      "address": "36 Craven St",
      "address2": "string",
      "city": "Austin",
      "region": "Texas",
      "country": "GB",
      "postalCode": "WC2N 5NF",
      "phoneNumbers": [
        {
          "label": "main",
          "value": "1-512-777-0269",
          "primary": true
        }
      ],
      "emails": [
        {
          "label": "main",
          "value": "rebilly@example.com",
          "primary": true
        }
      ],
      "dob": "1980-04-01",
      "jobTitle": "CEO"
    },
    "delinquencyPeriod": "+P00Y00M07DT00H00M00S",
    "couponIds": [
      "string"
    ],
    "riskMetadata": {
      "ipAddress": "93.92.91.90",
      "fingerprint": "pIUt3xbgX3l9g3YDiLbx",
      "httpHeaders": {
        "Content-Type": "application/json",
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
      },
      "browserData": {
        "colorDepth": 24,
        "isJavaEnabled": true,
        "language": "en-US",
        "screenWidth": 1920,
        "screenHeight": 1080,
        "timeZoneOffset": 300,
        "isAdBlockEnabled": true
      },
      "extraData": {
        "kountFraudSessionId": "abcdefg12345abababab123456789012",
        "payPalMerchantSessionId": "dd65ratxc5qv15iph3vyoq7l6davuowa",
        "threatMetrixSessionId": "dd65ratxc5qv15iph3vyoq7l6davuowadd65ratxc5qv15iph3vyoq7l6davuowa"
      }
    },
    "startTime": null,
    "shipping": {
      "amount": 0.1,
      "calculator": "manual"
    },
    "autopay": true,
    "abandonTime": "2019-08-24T14:15:22Z",
    "customFields": {
      "foo": "bar"
    },
    "currentPeriodEnd": "2019-08-24T14:15:22Z"
  }'

Responses

Order created.
Headers
Locationstring, (uri)
Location of the related resource.
Example:"https://api.rebilly.com/example"
Bodyapplication/json
idstring, <= 50 charactersread-only
ID of the order.
Example:"ord_01HVKA5975PJBSQ1SX72G3MSZC"
typestringrequired
Type of the order.
Discriminator
Value:"recurring"
organizationIdstring, <= 50 charactersread-only

Unique organization identifier. An organization is an entity that represents a company. For more information, see Obtain an organization ID.

Example:"org_0YVDM8RC7GDADADSBSMW124JA8"
customerIdstring, <= 50 characters(CustomerId)required
ID of the customer resource.
Example:"cus_0YV7DDSDD1C8DA64KHH2W33CPF"
websiteIdstring, <= 50 characters(WebsiteId)required
Example:"web_0YV7DE4Z26DQSA1AC92FBJ7SEG"
activationInvoiceIdstring, <= 50 charactersread-only
ID of the activation invoice.
Example:"in_0YVF9605RKC62BP14NE2R7V2XT"
recentInvoiceIdstring or null, <= 50 charactersread-only

ID of the most recently issued invoice. The invoice might not be paid yet.

Example:"in_0YVF9605RKC62BP14NE2R7V2XT"
statusstringread-only
Status of the order.
Enum:"pending""active""canceled""churned""paused""voided""completed""trial-ended""abandoned"
inTrialbooleanread-only
Specifies if the subscription is currently in a trial period.
trialobject

Details of the trial. To use plan defaults, omit the trial key or set this value to null.

isTrialOnlyboolean

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

Default:false
trialConversionTimestring or null, (date-time)read-only
Date and time when the subscription had a trial conversion. Trial conversion occurs when the first successful payment is made after a trial period.
itemsArray of objects, non-emptyrequired
Item in the order.
invoiceIssueTimeShiftstring

Invoice issue time shift interval in ISO-8601 format.

This field adjusts the issue date and time of renewal invoices for the order.

This interval value supports the - symbol.

Default:"+P00Y00M00DT00H00M00S"
Example:"+P00Y00M00DT00H00M00S"
invoiceDueTimeShiftstring

Invoice due time shift interval in ISO-8601 format.

Use this field to adjust when payment is due for the order. If autopay is configured, payment is collected automatically on this date.

This interval value supports the + symbol.

Default:"+P00Y00M00DT00H00M00S"
Example:"+P00Y00M00DT00H00M00S"
paymentInstrumentIdstring 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.
Example:"inst_0YVB8KPKNXCBR9EDX7JHSED75N"
poNumberstring or null
Purchase order number that is displayed on the issued invoices.
Example:"PO123456"
sandboxRetentionobject or null(SandboxRetention)

Sandbox recurring order retention. In the sandbox environment, a recurring order is canceled 90 days after it is created or on the start date of the policy, whichever is later. The order is not canceled if it is retained or if the organization is excluded from the policy. This property is returned in the sandbox environment only, for recurring orders. In the live environment, if the request includes this property with a value, a validation error is returned. A null value in a request does not update the property.

notesstring
Notes for the customer that are displayed on the order invoice.
billingAddressContactObject (object) or null
One of:
Contact's information.
deliveryAddressContactObject (object) or null
One of:
Contact's information.
delinquencyPeriodstring or 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.

Default:null
Example:"+P00Y00M07DT00H00M00S"
riskMetadataRisk metadata (object) or null
One of:
Risk metadata used for 3D Secure and risk scoring.
startTimestring 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.

Default:null
Example:null
activationTimestring or null, (date-time)read-only
Date and time when the order is activated.
currencystring, = 3 characters(CurrencyCode)read-only
Currency of the order.
Example:"USD"
shippingobject(Shipping)
autopayboolean

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 order.

Default:true
abandonTimestring 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.

abandonReminderTimestring or null, (date-time)read-only
Date and time when the abandon order reminder event triggers.
abandonReminderNumberinteger or nullread-only
Number of abandon order reminder events that are triggered.
voidTimestring or null, (date-time)read-only
Date and time when the order is voided.
churnTimestring or null, (date-time)read-only
Date and time when the order is deactivated.
cancellationTimestring or null, (date-time)read-only
Date and time when an order is canceled.
canceledBystring or nullread-only
Specifies who initiated the cancellation.
Enum:"merchant""customer""rebilly"null
cancelCategorystring or nullread-only

Category of the cancellation.

The sandbox-retention value is set only in the sandbox environment when a recurring order is canceled 90 days after creation.

Enum:"billing-failure""did-not-use""did-not-want""missing-features""bugs-or-problems""do-not-remember""risk-warning""contract-expired""too-expensive""never-started"
cancelDescriptionstring or null, <= 255 charactersread-only
Description of the cancellation reason in free form.
billingPortalTokenstring or nullread-only
Customer JWT to access a billing portal. This field is presented only if a billing portal exists. This is an experimental field and can be changed or removed in the future.
customFieldsobject(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.

Default:{}
Example:
{ "foo": "bar" }
lineItemsArray of objectsread-only
Order line items that queue until the next renewal, or interim, invoice is issued for the order.
lineItemSubtotalobjectread-only

Subtotal of line items in this order (signed value). If credits exceed debits, this value is a negative number.

mrrnumber, (double)read-only
Monthly recurring revenue of the order.
Example:49.95
revisionintegerread-only
Number of times the order data has been modified. The revision is useful when analyzing webhook data to determine if the change takes precedence over the current representation.
currentPeriodStartstring or null, (date-time)read-only
Date and time of the current service period start.
currentPeriodEndstring or null, (date-time)
Date and time of the current service period end. If subscriptions have different recurring settings or the order is not active, providing this field causes the request to be rejected with a conflict. This field is ignored if the order is in trial.
renewalTimestring or null, (date-time)read-only
Date and time when the next subscription in this recurring order renews.
isNewOrderbooleanread-only
Specifies if the order is a new order.
Example:true
createdTimestring, (date-time)(CreatedTime)read-only
Date and time when the resource is created. This value is set automatically when the resource is created.
updatedTimestring, (date-time)(UpdatedTime)read-only
Date and time when the resource is updated. This value is set automatically when the resource is updated.
_embeddedobjectread-only

Embedded objects that are requested by the expand query parameter.

Response
{ "id": "ord_01HVKA5975PJBSQ1SX72G3MSZC", "type": "recurring", "organizationId": "org_0YVDM8RC7GDADADSBSMW124JA8", "customerId": "cus_0YV7DDSDD1C8DA64KHH2W33CPF", "websiteId": "web_0YV7DE4Z26DQSA1AC92FBJ7SEG", "activationInvoiceId": "in_0YVF9605RKC62BP14NE2R7V2XT", "recentInvoiceId": "in_0YVF9605RKC62BP14NE2R7V2XT", "status": "pending", "inTrial": true, "trial": { "enabled": true, "endTime": "2019-08-24T14:15:22Z" }, "isTrialOnly": false, "trialConversionTime": "2019-08-24T14:15:22Z", "items": [ { … } ], "invoiceIssueTimeShift": "+P00Y00M00DT00H00M00S", "invoiceDueTimeShift": "+P00Y00M00DT00H00M00S", "paymentInstrumentId": "inst_0YVB8KPKNXCBR9EDX7JHSED75N", "poNumber": "PO123456", "sandboxRetention": { "autoCancelTime": "2027-01-10T06:00:00+00:00", "excluded": false }, "notes": "string", "billingAddress": { "firstName": "Benjamin", "lastName": "Franklin", "organization": "Rebilly", "address": "36 Craven St", "address2": "string", "city": "Austin", "region": "Texas", "country": "GB", "postalCode": "WC2N 5NF", "phoneNumbers": [ … ], "emails": [ … ], "dob": "1980-04-01", "jobTitle": "CEO", "hash": "056ae6d97c788b9e98b049ebafd7b229bf852221" }, "deliveryAddress": { "firstName": "Benjamin", "lastName": "Franklin", "organization": "Rebilly", "address": "36 Craven St", "address2": "string", "city": "Austin", "region": "Texas", "country": "GB", "postalCode": "WC2N 5NF", "phoneNumbers": [ … ], "emails": [ … ], "dob": "1980-04-01", "jobTitle": "CEO", "hash": "056ae6d97c788b9e98b049ebafd7b229bf852221" }, "delinquencyPeriod": "+P00Y00M07DT00H00M00S", "riskMetadata": { "ipAddress": "93.92.91.90", "fingerprint": "pIUt3xbgX3l9g3YDiLbx", "httpHeaders": { … }, "browserData": { … }, "extraData": { … }, "isProxy": true, "isVpn": true, "isTor": true, "isHosting": true, "hostingName": "string", "isp": "string", "country": "US", "region": "NY", "city": "New York", "latitude": 0, "longitude": 0, "postalCode": "string", "timeZone": "America/New_York", "accuracyRadius": 0, "distance": 0, "hasMismatchedBillingAddressCountry": true, "hasMismatchedBankCountry": true, "hasMismatchedTimeZone": true, "hasMismatchedHolderName": true, "hasFakeName": true, "isHighRiskCountry": true, "paymentInstrumentVelocity": 0, "declinedPaymentInstrumentVelocity": 0, "deviceVelocity": 0, "ipVelocity": 0, "emailVelocity": 0, "billingAddressVelocity": 0, "paymentInstrumentApprovedTransactionCount": 0, "score": 0 }, "startTime": null, "activationTime": "2019-08-24T14:15:22Z", "currency": "USD", "shipping": { "amount": 0.1, "calculator": "manual" }, "autopay": true, "abandonTime": "2019-08-24T14:15:22Z", "abandonReminderTime": "2019-08-24T14:15:22Z", "abandonReminderNumber": 0, "voidTime": "2019-08-24T14:15:22Z", "churnTime": "2019-08-24T14:15:22Z", "cancellationTime": "2019-08-24T14:15:22Z", "canceledBy": "merchant", "cancelCategory": "billing-failure", "cancelDescription": "string", "billingPortalToken": "string", "customFields": { "foo": "bar" }, "lineItems": [ { … } ], "lineItemSubtotal": { "currency": "USD", "amount": 49.95 }, "mrr": 49.95, "revision": 0, "currentPeriodStart": "2019-08-24T14:15:22Z", "currentPeriodEnd": "2019-08-24T14:15:22Z", "renewalTime": "2019-08-24T14:15:22Z", "isNewOrder": true, "createdTime": "2019-08-24T14:15:22Z", "updatedTime": "2019-08-24T14:15:22Z", "_links": [ { … } ], "_embedded": { "customer": { … }, "activationInvoice": { … }, "recentInvoice": { … }, "upcomingInvoice": { … }, "paymentInstrument": { … }, "website": { … } } }