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

# Create an Apple Pay session for a cart

POST https://stg.ttix.io/api/v3/carts/{cartId}/apple-pay-sessions

Mints the merchant session Apple Pay requires before the payment sheet can open, for the merchant account this cart's order is charged through, whatever currency the shopper pays in. Call this when the shopper taps the Apple Pay button on the cart, then pass the returned `merchantSession` unchanged to `ApplePaySession.completeMerchantValidation`. Offer Apple Pay only when the cart lists `APPLE_PAY` in `options.paymentMethods`. Sessions are short-lived, so mint one per payment attempt rather than caching. The `Origin` request header must carry the domain the shopper is paying on, and that domain must be registered with Apple Pay.

Reference: https://docs.todaytixgroup.com/api-reference/purchase/apple-pay-sessions/post-cart-apple-pay-session

## Authentication

- `X-TT-API-Key` header (required) — API Key authentication via header

## Servers

- `https://stg.ttix.io` (Staging Environment, default)
- `https://api.ttix.io` (Production Environment)

## Request

### Path parameters

- `cartId` (string, required) — Cart ID (UUID)

### Headers

- `X-TT-Platform` (enum, required) — Identifies the platform the request comes from.
  - Allowed values: `android`, `api`, `ios`, `web`
- `X-TT-Retailer` (string, required) — Your retailer identifier, provided during onboarding. It must be a retailer your API key was issued for.

## Response

### 200

Apple Pay merchant session.

- `data` (ApplePaySessionResponse, required) — The Apple Pay merchant session a client needs to open the Apple Pay payment sheet.

## Errors

### 400 Bad Request Error

Missing `Origin` header or an invalid cart ID. Also `APPLE_PAY_NOT_AVAILABLE` when the cart does not offer Apple Pay, or the payment gateway rejects the merchant setup. Retrying will not help, so offer another payment method.

- `error` (ErrorResponse, required) — What went wrong: `type` and `code` for your code to act on, `message` to display.

### 401 Unauthorized Error

The request could not be authenticated. Any request gets `UNAUTHORIZED` when the `X-TT-API-Key` header is missing, and `INVALID_API_KEY` when the key is not valid or was revoked, or when the `X-TT-Retailer` header is missing or names a retailer the key cannot be used for.

- `error` (ErrorResponse, required) — What went wrong: `type` and `code` for your code to act on, `message` to display.

### 403 Forbidden Error

The request is not allowed from where it was sent. Any request sent from a web page gets `ORIGIN_NOT_ALLOWED` when the page's origin is not one the API key allows. Add the origin to the key, or use a key that allows it. A request with no `Origin` header, such as one from your server, is never refused for this.

- `error` (ErrorResponse, required) — What went wrong: `type` and `code` for your code to act on, `message` to display.

### 404 Not Found Error

No cart exists for this ID.

- `error` (ErrorResponse, required) — What went wrong: `type` and `code` for your code to act on, `message` to display.

### 409 Conflict Error

`CART_ALREADY_ORDERED` — the cart was converted to an order. `details.orderId` names it.

- `error` (ErrorResponse, required) — What went wrong: `type` and `code` for your code to act on, `message` to display.

### 410 Gone Error

The cart ran out of time, was deleted, or no longer holds inventory. Create a new cart to continue.

- `error` (ErrorResponse, required) — What went wrong: `type` and `code` for your code to act on, `message` to display.

### 429 Too Many Requests Error

Too many requests. Wait at most the number of seconds in the `Retry-After` header when it is present, then send the request again.

- `error` (ErrorResponse, required) — What went wrong: `type` and `code` for your code to act on, `message` to display.

### 503 Service Unavailable Error

`APPLE_PAY_SESSION_UNAVAILABLE`: the merchant session could not be created right now. The payment gateway is down, slow or throttling, or it sent back a session that is empty or unreadable. A retry later can succeed.

- `error` (ErrorResponse, required) — What went wrong: `type` and `code` for your code to act on, `message` to display.

## Types

### ApplePaySessionResponse

The Apple Pay merchant session a client needs to open the Apple Pay payment sheet.

- `merchantSession` (map from string to any, optional) — Opaque, time-limited merchant session issued by Apple. Pass it unchanged to the browser's ApplePaySession.completeMerchantValidation to open the payment sheet. Each value is text or a number.

### ErrorResponse

What went wrong: `type` and `code` for your code to act on, `message` to display.

- `type` (enum, required) — High-level error category.
  - Allowed values: `INVALID_REQUEST_ERROR`, `AUTHENTICATION_ERROR`, `PAYMENT_ERROR`, `PERMISSION_ERROR`, `NOT_FOUND_ERROR`, `CONFLICT_ERROR`, `RESOURCE_GONE_ERROR`, `RATE_LIMIT_ERROR`, `API_ERROR`, `SERVICE_UNAVAILABLE`
- `code` (enum, required) — Machine-readable error code.
  - Allowed values: `INVALID_FIELD_VALUE`, `ACCESS_CARD_NOT_VERIFIED`, `ACCESS_CARD_WRONG_SCHEME`, `ACCESS_VERIFICATION_NOT_SUPPORTED`, `ACCESS_VERIFICATION_UNAVAILABLE`, `TICKET_ALERT_SIGNUP_NOT_SUPPORTED`, `MIXED_ITEM_TYPES_NOT_SUPPORTED`, `INVALID_VOUCHER`, `CURRENCY_NOT_SUPPORTED`, `CURRENCY_TEMPORARILY_UNAVAILABLE`, `MISSING_REQUIRED_HEADER`, `MISSING_REQUIRED_FIELD`, `UNAUTHORIZED`, `INVALID_API_KEY`, `INVALID_ACCESS_TOKEN`, `PAYMENT_AUTHENTICATION_REQUIRED`, `PAYMENT_DECLINED`, `RISK_CHECK_FAILED`, `APPLE_PAY_NOT_AVAILABLE`, `APPLE_PAY_SESSION_UNAVAILABLE`, `INVALID_REQUEST`, `RESOURCE_NOT_FOUND`, `INSUFFICIENT_PERMISSIONS`, `ORIGIN_NOT_ALLOWED`, `RATE_LIMITED`, `INTERNAL_SERVER_ERROR`, `SERVICE_UNAVAILABLE`, `INVENTORY_EXHAUSTED`, `OCCURRENCE_NOT_AVAILABLE`, `OCCURRENCE_NOT_COMPATIBLE`, `ORPHANED_SEATS`, `INVALID_PRICE_OPTION`, `MIXED_OCCURRENCES_NOT_SUPPORTED`, `EVENT_NOT_SELLABLE`, `MIXED_PRODUCT_TYPES_NOT_SUPPORTED`, `MULTIPLE_GIFT_CARDS_NOT_SUPPORTED`, `GIFT_CARD_QUANTITY_NOT_SUPPORTED`, `MINIMUM_QUANTITY_NOT_MET`, `VOUCHER_NOT_APPLICABLE_TO_GIFT_CARD`, `CART_EXPIRED`, `EXPECTED_TOTAL_MISMATCH`, `TICKET_LIMIT_EXCEEDED`, `PAYMENT_METHOD_NOT_AVAILABLE`, `CART_ALREADY_ORDERED`, `CART_ALREADY_CLAIMED`, `INVALID_IDEMPOTENCY_KEY`, `IDEMPOTENCY_KEY_ALREADY_PROCESSING`, `IDEMPOTENCY_KEY_CART_MISMATCH`, `IDEMPOTENCY_KEY_FAILED`, `GRANT_NOT_CLAIMABLE`, `GRANT_NOT_CANCELLABLE`, `ACTION_NOT_AVAILABLE`, `THIRD_PARTY_OUTAGE`
- `message` (string, required) — Human-readable description of the error.
- `param` (string, optional, nullable) — The request field that caused the error, if applicable.
- `details` (map from string to ErrorResponseDetails, optional, nullable) — Additional structured data for client recovery logic.

### ErrorResponseDetails

Additional structured data for client recovery logic.

## Examples

**Response**

```json
{
  "data": {
    "merchantSession": {}
  }
}
```

**SDK Code**

```python
import requests

url = "https://stg.ttix.io/api/v3/carts/6aac14d3-5826-4da8-98b6-9e68c28629d6/apple-pay-sessions"

headers = {
    "X-TT-Platform": "android",
    "X-TT-Retailer": "YOUR_RETAILER_ID",
    "X-TT-API-Key": "<apiKey>"
}

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

print(response.json())
```

```javascript
const url = 'https://stg.ttix.io/api/v3/carts/6aac14d3-5826-4da8-98b6-9e68c28629d6/apple-pay-sessions';
const options = {
  method: 'POST',
  headers: {
    'X-TT-Platform': 'android',
    'X-TT-Retailer': 'YOUR_RETAILER_ID',
    'X-TT-API-Key': '<apiKey>'
  }
};

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

```go
package main

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

func main() {

	url := "https://stg.ttix.io/api/v3/carts/6aac14d3-5826-4da8-98b6-9e68c28629d6/apple-pay-sessions"

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

	req.Header.Add("X-TT-Platform", "android")
	req.Header.Add("X-TT-Retailer", "YOUR_RETAILER_ID")
	req.Header.Add("X-TT-API-Key", "<apiKey>")

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

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

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

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://stg.ttix.io/api/v3/carts/6aac14d3-5826-4da8-98b6-9e68c28629d6/apple-pay-sessions")

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

request = Net::HTTP::Post.new(url)
request["X-TT-Platform"] = 'android'
request["X-TT-Retailer"] = 'YOUR_RETAILER_ID'
request["X-TT-API-Key"] = '<apiKey>'

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://stg.ttix.io/api/v3/carts/6aac14d3-5826-4da8-98b6-9e68c28629d6/apple-pay-sessions")
  .header("X-TT-Platform", "android")
  .header("X-TT-Retailer", "YOUR_RETAILER_ID")
  .header("X-TT-API-Key", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://stg.ttix.io/api/v3/carts/6aac14d3-5826-4da8-98b6-9e68c28629d6/apple-pay-sessions', [
  'headers' => [
    'X-TT-API-Key' => '<apiKey>',
    'X-TT-Platform' => 'android',
    'X-TT-Retailer' => 'YOUR_RETAILER_ID',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://stg.ttix.io/api/v3/carts/6aac14d3-5826-4da8-98b6-9e68c28629d6/apple-pay-sessions");
var request = new RestRequest(Method.POST);
request.AddHeader("X-TT-Platform", "android");
request.AddHeader("X-TT-Retailer", "YOUR_RETAILER_ID");
request.AddHeader("X-TT-API-Key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-TT-Platform": "android",
  "X-TT-Retailer": "YOUR_RETAILER_ID",
  "X-TT-API-Key": "<apiKey>"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://stg.ttix.io/api/v3/carts/6aac14d3-5826-4da8-98b6-9e68c28629d6/apple-pay-sessions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```