> This page is for Developer.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.bigcommerce.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.bigcommerce.com/_mcp/server.

# Create Cart Redirect URL

POST https://api.bigcommerce.com/stores/{store_hash}/v3/carts/{cartId}/redirect_urls
Content-Type: application/json

Creates a **Cart** redirect URL for redirecting a shopper to an already created cart using the `cartId`.

**Usage Notes**

* To use redirect URLs, first create the cart using the REST Management API or GraphQL Storefront API.
* Redirect URLs can also be created with **Create a Cart** requests by appending `include=redirect_urls`.
* A **Carts** redirect URL is valid for 30 days and may only be used once.
* Redirect URLs point to either a shared checkout domain or a channel-specific domain, depending on the storefront configuration.
* Once a redirect URL has been visited, it will be invalidated and cannot be used again. 
* If your application requires URLs to be visited more than once, consider generating a fresh one each time you need to restore a cart, and redirecting to the URL from your own application.
* To restore a cart that was created on the storefront, either by a shopper or a Storefront API, first recreate the cart using the **REST Management API**.
* When redirecting the shopper, you can add a set of `query_params` to the URL. The `query_params` feature allows passing additional information to the redirect URL.

Reference: https://docs.bigcommerce.com/developer/api-reference/rest/admin/management/carts/redirects/create-cart-redirect-url

## Authentication

- `X-Auth-Token` header (required) — ### OAuth scopes | UI Name | Permission | Parameter | |:--------|:-----------|:----------| |Carts|modify|`store_cart`| |Carts |read-only|`store_cart_read_only`| |Information & Settings | modify | `store_v2_information`| |Information & Settings | read-only| `store_v2_information`| ### Authentication header | Header | Argument | Description | |:-------|:---------|:------------| | `X-Auth-Token` | `access_token` | For more about API accounts that generate `access_token`s, see our [Guide to API Accounts](/developer/docs/overview/api-fundamentals/api-accounts#api-accounts). | ### Further reading For example requests and more information about authenticating BigCommerce APIs, see [Authentication and Example Requests](/developer/docs/overview/api-fundamentals/api-accounts#x-auth-token-header-example-requests). For more about BigCommerce OAuth scopes, see our [Guide to API Accounts](/developer/docs/overview/api-fundamentals/api-accounts#oauth-scopes). For a list of API status codes, see [API Status Codes](/developer/api-reference/rest/overview#rest-http-status-codes).

## Request

### Path parameters

- `cartId` (string, required) — The identifier of a specific cart.
- `store_hash` (string, required) — Permanent ID of the BigCommerce store.

### Headers

- `Accept` (string, required, default: application/json) — The [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the response body.

### Body (application/json)

This endpoint expects a Redirect_urls_Post.

- `query_params` (RedirectUrlsPostQueryParams, optional)

## Response

### 201

The generated cart redirect URLs.

- `data` (CartsCartIdRedirectUrlsPostResponsesContentApplicationJsonSchemaData, optional)
- `meta` (metaCollection_open, optional) — Response metadata.

## Types

### RedirectUrlsPostQueryParams

- `key` (string, optional)
- `value` (string, optional)

### CartsCartIdRedirectUrlsPostResponsesContentApplicationJsonSchemaData

- `cart_url` (string, optional)
- `checkout_url` (string, optional)
- `embedded_checkout_url` (string, optional)

### metaCollection_open

Response metadata.

## Examples

**Request**

```json
{
  "query_params": {
    "key_1": "value_1",
    "key_2": "value_2"
  }
}
```

**Response**

```json
{
  "data": {
    "cart_url": "https://store.mybigcommerce.com/cart.php?action=load&id=0aa00afa-a000-00a0-00aae-aa0000f000a0&token=00aaaaa0aa0000000000a000a000f0aa0000afa00aa00afa0a000000000aa0a0",
    "checkout_url": "https://store.mybigcommerce.com/cart.php?action=loadInCheckout&id=1ea11efe-b111-11d1-11ee-cd1110f111b1&token=00aaaaa0aa0000000000a000a000f0aa0000afa00aa00afa0a000000000aa0a0",
    "embedded_checkout_url": "https://store.mybigcommerce.com/cart.php?embedded=1&action=loadInCheckout&id=0aa00afa-a000-00a0-00aae-aa0000f000a0&token=00aaaaa0aa0000000000a000a000f0aa0000afa00aa00afa0a000000000aa0a0"
  },
  "meta": {
    "$ref": "#/components/schemas/metaCollection_open"
  }
}
```

**SDK Code**

```python Create a cart redirect URL
import requests

url = "https://api.bigcommerce.com/stores/store_hash/v3/carts/cartId/redirect_urls"

payload = { "query_params": {
        "key_1": "value_1",
        "key_2": "value_2"
    } }
headers = {
    "Accept": "application/json",
    "X-Auth-Token": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Create a cart redirect URL
const url = 'https://api.bigcommerce.com/stores/store_hash/v3/carts/cartId/redirect_urls';
const options = {
  method: 'POST',
  headers: {
    Accept: 'application/json',
    'X-Auth-Token': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"query_params":{"key_1":"value_1","key_2":"value_2"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Create a cart redirect URL
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.bigcommerce.com/stores/store_hash/v3/carts/cartId/redirect_urls"

	payload := strings.NewReader("{\n  \"query_params\": {\n    \"key_1\": \"value_1\",\n    \"key_2\": \"value_2\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Accept", "application/json")
	req.Header.Add("X-Auth-Token", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Create a cart redirect URL
require 'uri'
require 'net/http'

url = URI("https://api.bigcommerce.com/stores/store_hash/v3/carts/cartId/redirect_urls")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/json'
request["X-Auth-Token"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"query_params\": {\n    \"key_1\": \"value_1\",\n    \"key_2\": \"value_2\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Create a cart redirect URL
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.bigcommerce.com/stores/store_hash/v3/carts/cartId/redirect_urls")
  .header("Accept", "application/json")
  .header("X-Auth-Token", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"query_params\": {\n    \"key_1\": \"value_1\",\n    \"key_2\": \"value_2\"\n  }\n}")
  .asString();
```

```php Create a cart redirect URL
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.bigcommerce.com/stores/store_hash/v3/carts/cartId/redirect_urls', [
  'body' => '{
  "query_params": {
    "key_1": "value_1",
    "key_2": "value_2"
  }
}',
  'headers' => [
    'Accept' => 'application/json',
    'Content-Type' => 'application/json',
    'X-Auth-Token' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Create a cart redirect URL
using RestSharp;

var client = new RestClient("https://api.bigcommerce.com/stores/store_hash/v3/carts/cartId/redirect_urls");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("X-Auth-Token", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"query_params\": {\n    \"key_1\": \"value_1\",\n    \"key_2\": \"value_2\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create a cart redirect URL
import Foundation

let headers = [
  "Accept": "application/json",
  "X-Auth-Token": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["query_params": [
    "key_1": "value_1",
    "key_2": "value_2"
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.bigcommerce.com/stores/store_hash/v3/carts/cartId/redirect_urls")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```