# Accept a quote

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


[Idempotency Supported](/docs/api/idempotency)

This API generates a hosted page URL for the customer to accept a quote. If the hosted page URL has expired, a new URL will be generated automatically.

-   Customers with existing subscriptions can generate a quote for new subscriptions. However, Hosted page URL to accept a quote cannot be generated for new subscriptions in V1 and V2 hosted pages.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/hosted_pages/accept_quote \
     -u {site_api_key}:\
     -d "quote[id]"="1"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = HostedPage.AcceptQuote()
		.QuoteId("1")
		.Request();

HostedPage hostedPage = result.HostedPage;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    hostedpageAction "github.com/chargebee/chargebee-go/v3/actions/hostedpage"
    "github.com/chargebee/chargebee-go/v3/models/hostedpage"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := hostedpageAction.AcceptQuote(&hostedpage.AcceptQuoteRequestParams{
        Quote : &hostedpage.AcceptQuoteQuoteParams{
            Id : "1",
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        HostedPage := res.HostedPage
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.HostedPageAcceptQuoteRequest{
    Quote : &chargebee.HostedPageAcceptQuoteQuote{
        Id : "1",
    },
}
  res, err := client.HostedPage.AcceptQuote(req)
      if err != nil {
        fmt.Println(err)
    } else {
        HostedPage := res.HostedPage
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = HostedPage.acceptQuote()
            .quoteId("1")
            .request();

        HostedPage hostedPage = result.hostedPage();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.hostedPage.HostedPage;
import com.chargebee.v4.models.hostedPage.params.HostedPageAcceptQuoteParams;
import com.chargebee.v4.models.hostedPage.responses.HostedPageAcceptQuoteResponse;

public class HostedPageAcceptQuote {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        HostedPageAcceptQuoteParams.QuoteParams quoteParams =
            HostedPageAcceptQuoteParams.QuoteParams.builder()
                .id("1")
                .build();

        HostedPageAcceptQuoteParams params = HostedPageAcceptQuoteParams.builder()
            .quote(quoteParams)
            .build();

        HostedPageAcceptQuoteResponse response = client.hostedPages().acceptQuote(params);

        HostedPage hostedPage = response.getHostedPage();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.hostedPage.acceptQuote({
        quote: {
            id: 1
        }
    });

    console.log(result);
    const hostedPage = result.hosted_page;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->hostedPage()->acceptQuote([
    "quote" => [
        "id" => "1"
    ]
]);
$hostedPage = $result->hosted_page;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.HostedPage.accept_quote(
    cb_client.HostedPage.AcceptQuoteParams(
        quote=cb_client.HostedPage.AcceptQuoteQuoteParams(
            id="1"
        )
    )
)
hosted_page = response.hosted_page
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::HostedPage.accept_quote({
  :quote => {
    :id => "1"
  }
})

hosted_page = result.hosted_page
```

## Sample Response

```json
{
  "hosted_page": {
    "created_at": 1517505980,
    "embed": true,
    "expires_at": 1517596199,
    "id": "__test__IKNpcdSoRFV0hFeci8SSkUbhZYjle2dKh",
    "layout": "full_page",
    "object": "hosted_page",
    "resource_version": 1517505981000,
    "state": "created",
    "type": "accept_quote",
    "updated_at": 1517505981,
    "url": "https://yourapp.chargebee.com/pages/v4/__test__IKNpcdSoRFV0hFeci8SSkUbhZYjle2dKh/?signature=QJ5nyZbOLRv6XvuK6o26cdkLBX2ra8cdTe"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/hosted_pages/accept_quote

## Input Parameters

- `redirect_url` (optional, string, max chars=250)
  The customers will be redirected to this URL upon successful checkout. The hosted page id and state will be passed as parameters to this URL.
  
  **Note** :
  
  -   Although the customer will be redirected to the `redirect_url` after successful checkout, we do not recommend relying on it for completing critical post-checkout actions. This is because redirection may not happen due to unforeseen reasons such as user closing the tab, or exiting the browser, and so on. If there is any synchronization that you are doing after the redirection, you will have to have a backup. Chargebee recommends listening to appropriate webhooks such as [`subscription_created`](/docs/api/events) or [`invoice_generated`](/docs/api/events) to verify a successful checkout.
  -   Redirect URL configured in Settings > Hosted Pages Settings would be overriden by this redirect URL.
  -   _Eg :_ _http://yoursite.com?id=\*\*&state=succeeded_
  -   This parameter is not applicable for iframe messaging.

- `layout` (optional, enumerated string)
  Specifies the UI layout for the hosted page. This overrides [the layout](https://www.chargebee.com/docs/billing/2.0/hosted-capabilities/hosted-checkout#ui-layout-options) configured in Chargebee Billing.
  Possible enum values:
    - `in_app`
      Renders the hosted page in an in-app layout.
    - `full_page`
      Renders the hosted page in a full-page layout.

- `quote` (optional, string)
  Parameters for quote
  - `id` (required, string, max chars=50)
    The quote number. Acts as a identifier for quote and typically generated sequentially.

## Returns

- `hosted_page` (Hosted page object)
  Resource object representing hosted\_page
