# Preview a purchase Previews a purchase. Use this operation to preview a purchase before completing it. A purchase can be completed both with and without authentication. Purchases that use a pre-created payment instrument must use authentication. > The shipping aspect of this API is experimental and may change to support multiple shipping methods. Endpoint: POST /storefront/preview-purchase Version: latest Security: CustomerJWT, PublishableApiKey ## Request fields (application/json): - `websiteId` (string, required) ID of the website. A website is where an organization obtains a customer. For more information, see [Obtain an organization ID and website ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id). Example: "web_0YV7DE4Z26DQSA1AC92FBJ7SEG" - `items` (array, required) Items details. - `items.planId` (string, required) ID of the plan. Example: "plan_0YV7DENSVGDBW9S71XZNNYYQ0X" - `items.quantity` (integer) Number of product units in the specified plan. - `billingAddress` (object,null) Billing address details. - `billingAddress.firstName` (string,null) Contact's first name. Example: "Benjamin" - `billingAddress.lastName` (string,null) Contact's last name. Example: "Franklin" - `billingAddress.organization` (string,null) Contact's organization. Example: "Rebilly" - `billingAddress.address` (string,null) First line of the contact's street address. Example: "36 Craven St" - `billingAddress.address2` (string,null) Second line of the contact's street address. - `billingAddress.city` (string,null) Contact's city of residence. Example: "Austin" - `billingAddress.region` (string,null) Contact's region of residence. Example: "Texas" - `billingAddress.country` (string,null) Contact's country of residence in ISO 3166 alpha-2 country code. For examples, see [ISO.org](https://www.iso.org/obp/ui/#search/code/). Example: "GB" - `billingAddress.postalCode` (string,null) Contact's postal code. Example: "WC2N 5NF" - `billingAddress.phoneNumbers` (array) List of phone numbers associated with the contact. - `billingAddress.phoneNumbers.label` (string, required) Phone number label or name. Example: "main" - `billingAddress.phoneNumbers.value` (string, required) Phone number value. Example: "1-512-777-0269" - `billingAddress.phoneNumbers.primary` (boolean) Specifies if the phone number is the contact's primary phone number. Example: true - `billingAddress.emails` (array) List of email addresses associated with the contact. - `billingAddress.emails.label` (string, required) Email label or name. Example: "main" - `billingAddress.emails.value` (string, required) Email address value. Example: "rebilly@example.com" - `billingAddress.emails.primary` (boolean) Specifies if the email address is the contact's primary email address. Example: true - `billingAddress.dob` (string,null) Contact's date of birth in ISO-8601 format. Example: "1980-04-01" - `billingAddress.jobTitle` (string,null) Contact's job title. Example: "CEO" - `deliveryAddress` (object,null) Delivery address details. - `couponIds` (array) List of coupons that are applied to the order. - `currency` (string) Currency code in ISO 4217 format. Example: "USD" - `shippingRateId` (string) ID of the shipping rate. If unset the cheapest applicable shipping rate is chosen. Example: "ship_rate_0YVDN408G4DQE9G1RV1QCFHJ3P" ## Response 200 fields (application/json): - `currency` (string) Currency code in ISO 4217 format. Example: "USD" - `lineItems` (array) List of purchase items. - `lineItems.type` (string) Type of transaction. Enum: "debit", "credit" - `lineItems.description` (string) Description of the purchase item. - `lineItems.unitPrice` (number) Unit price of the purchase item. Example: 49.95 - `lineItems.quantity` (number) Total quantity of the purchase item. - `lineItems.price` (number) Total cost of the purchase item. - `lineItems.planId` (string) ID of the related plan. Example: "plan_0YV7DENSVGDBW9S71XZNNYYQ0X" - `lineItems.productId` (string) ID of the related product. Example: "prod_0YV7DES3WPC5J8JD8QTVNZBZNZ" - `shippingRates` (array) Available shipping rates. - `shippingRates.id` (string) ID of the shipping rate. Example: "ship_rate_0YVDN408G4DQE9G1RV1QCFHJ3P" - `shippingRates.name` (string, required) Name of the shipping rate. - `shippingRates.description` (string,null) Description of the shipping rate. - `shippingRates.price` (number, required) Price of the shipping rate. If is , shipping is free. - `taxes` (array) Taxes applied to the purchase. - `taxes.amount` (number) Amount of tax that is due. - `taxes.description` (string) Description of the tax. - `discounts` (array) Discounts applied to the purchase. - `discounts.couponId` (string) ID of a coupon that is associated with the purchase. Example: "cpn_0YVCNKF81GD778N4YNVGDJK558" - `discounts.amount` (number) Total amount of discount from the coupon. - `discounts.description` (string) Description of the discount. - `subtotalAmount` (number) Subtotal amount of the purchase. - `taxAmount` (number) Tax amount of the purchase. - `shippingAmount` (number) Shipping amount of the purchase. - `discountsAmount` (number) Total discount amount of the purchase. - `total` (number) Total amount of the purchase. ## Response 401 fields (application/json): - `status` (integer) HTTP status code. - `type` (string) Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference. It should provide human-readable documentation for the problem type. When this member is not present, its value is assumed to be "about:blank". - `title` (string) Short, human-readable summary of the problem type. Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem. - `detail` (string) Human-readable explanation that is specific to this occurrence of the problem. - `instance` (string) URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced. ## Response 403 fields (application/json): - `status` (integer) HTTP status code. - `type` (string) Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference. It should provide human-readable documentation for the problem type. When this member is not present, its value is assumed to be "about:blank". - `title` (string) Short, human-readable summary of the problem type. Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem. - `detail` (string) Human-readable explanation that is specific to this occurrence of the problem. - `instance` (string) URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced. ## Response 422 fields (application/json): - `status` (integer) HTTP status code. - `type` (string) Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference. It should provide human-readable documentation for the problem type. When this member is not present, its value is assumed to be "about:blank". - `title` (string) Short, human-readable summary of the problem type. Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem. - `detail` (string) Human-readable explanation that is specific to this occurrence of the problem. - `instance` (string) URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced. - `invalidFields` (array) Invalid field details. Example: [{"field":"field1","message":"field1 is invalid"},{"field":"subObject.field2","message":"field2 is invalid"},{"field":"subObject.field2","message":"another error in the field2"}] - `invalidFields.field` (string) Name of the field. Dot notation is used for nested object field names. - `invalidFields.message` (string) Message field. ## Response 429 fields (application/json): - `type` (string) Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference. It should provide human-readable documentation for the problem type. When this member is not present, its value is assumed to be "about:blank". Example: "about:blank" - `title` (string) Short, human-readable summary of the problem type. Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem. Example: "Rate Limit Exceeded" - `status` (integer) HTTP status code. - `detail` (string) Human-readable explanation that is specific to this occurrence of the problem. Example: "A request cannot be executed because the user has sent too many requests within a certain period of time" - `instance` (string) URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.