# Hosted pages

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


Hosted pages are the easiest way to integrate Chargebee with your website. For card payment methods, they help meet most of your PCI DSS compliance requirements. Chargebee offers hosted pages where your customers can perform the following actions:

-   [Checkout a new subscription](/docs/api/hosted_pages/create-checkout-for-a-new-subscription)
-   [Checkout changes to an existing subscription](/docs/api/hosted_pages/create-checkout-to-update-a-subscription)
-   [Manage payment sources](/docs/api/hosted_pages/manage-payment-sources)
-   [Make payments for all due invoices](/docs/api/hosted_pages/collect-now)
-   [Extending a subscription](/docs/api/hosted_pages/extend-subscription) When you create a hosted page, it is available at a secure and unique URL. This URL can then be provided to your customer on your website or by other means such as email. On successful completion of the hosted page workflow by the customer, they are redirected to the `redirect_url` with the hosted page `id` and `state` passed as query string parameters. As soon as the redirection happens, [retrieve the hosted page](/docs/api/hosted_pages/retrieve-a-hosted-page) to get details of the customer, subscription, invoice etc.

#### Embedding a hosted page[](#embedding-a-hosted-page)

Only the [Checkout](/docs/api/hosted_pages/hosted-page-object#type) hosted page with the full-page [layout](/docs/api/hosted_pages/create-checkout-for-a-new-subscription#layout) supports embedding. To embed checkout in your website or application, use [embedded checkout](https://www.chargebee.com/docs/billing/2.0/hosted-capabilities/embedded-checkout.html) with Chargebee.js to mount checkout in a container on your page. Do not place hosted page URLs in your own [iframe](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/iframe) elements—Chargebee.js creates and manages the iframe for you.

## Sample Hosted page

```json
{
  "created_at": 1517464663,
  "embed": false,
  "expires_at": 1517468263,
  "id": "__one_time_checkout___test__cdqM9MLUubELMycut0Cr9sHq8gOTKEZSdcu",
  "layout": "in_app",
  "object": "hosted_page",
  "resource_version": 1517444863979,
  "state": "created",
  "type": "checkout_one_time",
  "updated_at": 1517444863,
  "url": "https://yourapp.chargebee.com/pages/v4/__one_time_checkout___test__cdqM9MLUubELMycut0Cr9sHq8gOTKEZSdcu/"
}
```

## Hosted pages attributes

## Input Parameters

- `id` (optional, string, max chars=70)
  Unique identifier generated for each hosted page requested.

- `type` (optional, enumerated string)
  Type of the requested hosted page.
  Possible enum values:
    - `checkout_new`
      Checkout new Subscription
    - `checkout_existing`
      Checkout existing Subscription
    - `manage_payment_sources`
      Manage Payments for a customer
    - `collect_now`
      Collect Unpaid Invoices for a Customer
    - `extend_subscription`
      To extend a Subscription period
    - `checkout_one_time`
      Checkout one time
    - `pre_cancel`
      This hosted page is used to help retain customers when they attempt to cancel their account or subscription.
    - `view_voucher`
      View Details of a voucher
    - `accept_quote`
      Accept quote via hosted page

- `url` (optional, string, max chars=250)
  Unique URL for the hosted page that will be included in your website.

- `state` (optional, enumerated string, default=created)
  Indicating the current state of the hosted page resource.
  Possible enum values:
    - `created`
      Indicates the hosted page is just created.
    - `requested`
      Indicates the hosted page is requested by the website
    - `succeeded`
      Indicates the hosted page is successfully submitted by the user and response is sent to the return url.
    - `cancelled`
      Indicates the page is cancelled by the end user after requesting it.
    - `acknowledged`
      Indicates the succeeded hosted page is acknowledged.

- `pass_thru_content` (optional, string, max chars=2048)
  This attribute allows you to store custom information with the `hosted_page` object. You can use it to associate specific data with a hosted page session. For example, you can store the ID of the marketing campaign that initiated the user session. After a successful checkout, when the customer is redirected, you can retrieve the hosted page ID from the [redirect URL](/docs/api/hosted_pages/create-checkout-for-a-new-subscription#redirect_url)'s query parameters. Using this ID, you can fetch the hosted page and perform actions related to the success of the marketing campaign.

- `created_at` (optional, timestamp(UTC) in seconds)
  Indicates when this hosted page url is generated.

- `expires_at` (optional, timestamp(UTC) in seconds)
  The date and time when the hosted page URL expires. After this timestamp, the page can no longer be accessed.
  
  The expiration period depends on the `[type](/docs/api/hosted_pages/hosted_page-object#type)` of hosted page:
  
  -   For `checkout_new`, `checkout_existing`, and `checkout_one_time`, the URL expires 3 hours after the page is created.
  -   For `collect_now` and `manage_payment_sources`, the URL expires 5 days after creation.

- `layout` (optional, enumerated string)
  Specifies the [UI layout](https://www.chargebee.com/docs/billing/2.0/hosted-capabilities/hosted-checkout#ui-layout-options) for the hosted page.
  
  Applicable only when `type` is `checkout_new`, `checkout_existing`, `checkout_one_time`, or `manage_payment_sources`.
  Possible enum values:
    - `in_app`
      The hosted page is rendered in the in-app layout.
    - `full_page`
      The hosted page is rendered in the full-page layout.

- `content` (required, jsonobject)
  This attribute will be returned only during retrieve hosted page API call and also the retrieved hosted page resource state should be either in "succeeded" or "cancelled" state. If hosted page state is "succeeded", then the subscription, customer, card & invoice(optional) resources during checkout can be obtained. If hosted page is state is "cancelled", then it will be empty i.e no information about checkout.

- `updated_at` (optional, timestamp(UTC) in seconds)
  Timestamp indicating when this hosted page was last updated.

- `resource_version` (optional, long)
  The version number of this resource. For every change made to the resource, `resource_version` is updated with a new timestamp in milliseconds.

- `checkout_info` (optional, jsonobject)
  Customer Info (email, first name and last name) given in the checkout page used for tracking abandoned carts. [Learn more](https://www.chargebee.com/docs/abandoned-carts.html)

- `business_entity_id` (optional, string, max chars=50)
  The unique ID of the [business entity](/docs/api/advanced-features) of this `hosted_page`.

