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

# Create a Checkout Session

POST https://api.transxact.io/v1/checkout-sessions
Content-Type: application/json

Starts a payment: call this from your server, then redirect the Customer to the returned `hostedUrl`, which takes the payment with any Provider. Don't fulfil on the redirect; wait for the `checkout_session.succeeded` webhook or retrieve the session. The `Idempotency-Key` header is required: a retry with the same key replays the original session instead of creating a second one, so derive it from your order. An `sk_test_` key creates a Test mode session that simulates payment; an `sk_live_` key creates a Live mode session that moves real money.

Reference: https://docs.transxact.io/api-reference/checkout-sessions/create

## Authentication

- `Authorization` header (bearer token, required) — Your secret key: sk_test_... in Test mode, sk_live_... in Live mode.

## Request

### Headers

- `idempotency-key` (string, required) — Client-generated key; a repeated key returns the original session.

### Body (application/json)

This endpoint expects a CreateCheckoutSessionRequest.

- `amount` (integer, optional) — Amount to charge, in FJD cents (minor units). Must be under FJD 5,000.00 (at most 499999), in Test mode and Live mode alike. Send this with `currency`, or send `quote` instead, never both.
- `currency` (enum, optional) — Always FJD in v1. Required with `amount`.
  - Allowed values: `FJD`
- `quote` (CreateCheckoutSessionRequestQuote, optional) — Price the session in USD or AUD instead of sending `amount`. `amount` is in cents of that currency. We convert it to FJD once, now, and lock the rate; the Customer sees and pays FJD only. The converted FJD amount must still be under FJD 5,000.00. Test mode only for now: a Live mode key gets `quote_unavailable_in_live_mode`. Only on Business accounts.
- `successUrl` (string, optional) — Where the hosted checkout sends the Customer after the payment succeeds. HTTPS only. Transxact appends `session_id=<Checkout Session id>`; confirm the outcome with GET /v1/checkout-sessions/\{id} rather than trusting the redirect.
- `cancelUrl` (string, optional) — Where the hosted checkout sends the Customer if they cancel or the payment doesn't go through. HTTPS only. Transxact appends `session_id=<Checkout Session id>`; confirm the outcome with GET /v1/checkout-sessions/\{id} rather than trusting the redirect.
- `metadata` (map from string to string, optional) — Up to 20 string key/value pairs (keys ≤40 chars, values ≤500) for matching the session to your own records. Returned on retrieve and in webhooks; never shown to the Customer. Don't put secrets or personal data here.
- `customerEmail` (string, optional) — The Customer's email. In Live mode, once the payment succeeds, Transxact emails them a receipt from you (branded with your Display name) unless you've turned receipts off in Settings. We keep the address 30 days after the session ends and never return it. In Test mode it is checked and dropped; nothing is sent.
- `expiresAt` (integer, optional) — Unix ms timestamp, 30 minutes to 24 hours from now, after which the session can't be paid and is cancelled. Defaults to 24 hours.

## Response

### 201

Checkout Session created (or replayed from the Idempotency-Key).

- `id` (string, required) — Checkout Session identifier.
- `status` (enum, required) — `pending` until the Customer pays or the session ends. `succeeded`: paid, safe to fulfil. `failed`: the payment was declined or didn't go through. `cancelled`: you cancelled it or it expired unpaid. Only `pending` ever changes, and each change sends the matching `checkout_session.*` webhook.
  - Allowed values: `pending`, `succeeded`, `failed`, `cancelled`
- `mode` (enum, required) — `test` for a session made with an `sk_test_` key, `live` for an `sk_live_` key. Webhook endpoints each hear one mode, and the payload says which it came from.
  - Allowed values: `test`, `live`
- `amount` (integer, required) — Amount to charge, in FJD cents (minor units).
- `currency` (enum, required) — Always FJD in v1.
  - Allowed values: `FJD`
- `hostedUrl` (string, required) — Transxact-hosted URL to redirect the Customer to.
- `metadata` (map from string to string, required) — Your own key/value data from creation; empty object if none was set.
- `expiresAt` (integer, required) — Unix ms timestamp after which no payment can start; a still-pending session is then cancelled.
- `invoiceNumber` (string, optional) — The Invoice number, such as `INV-0007`, when the session pays one of your Invoices; absent otherwise. Also in the webhook payload.
- `quote` (CheckoutSessionQuote, optional) — Present when you created the session with a `quote`: the USD or AUD price you sent, the FJD rate it was converted at (a decimal string), and the Unix ms time the rate was taken. `amount` is the FJD that is charged. Never shown to the Customer.

## Errors

### 400 Bad Request Error

Invalid request (`invalid_request`), including an amount (or a quote converting to an amount) of FJD 5,000.00 or more.

- `error` (ErrorError, required) — Branch on `code`; `message` is for logs.

### 401 Unauthorized Error

Invalid or missing API key.

- `error` (ErrorError, required) — Branch on `code`; `message` is for logs.

### 409 Conflict Error

Idempotency-Key reused with a different amount/currency/quote (`idempotency_key_reused`), a Live mode key while no Provider takes Live mode payments yet (`live_mode_unavailable`), or a `quote` with a Live mode key (`quote_unavailable_in_live_mode`).

- `error` (ErrorError, required) — Branch on `code`; `message` is for logs.

## Types

### CreateCheckoutSessionRequestQuote

Price the session in USD or AUD instead of sending `amount`. `amount` is in cents of that currency. We convert it to FJD once, now, and lock the rate; the Customer sees and pays FJD only. The converted FJD amount must still be under FJD 5,000.00. Test mode only for now: a Live mode key gets `quote_unavailable_in_live_mode`. Only on Business accounts.

- `amount` (integer, required) — Price in cents of `currency`.
- `currency` (enum, required) — USD or AUD.
  - Allowed values: `USD`, `AUD`

### CheckoutSessionQuote

Present when you created the session with a `quote`: the USD or AUD price you sent, the FJD rate it was converted at (a decimal string), and the Unix ms time the rate was taken. `amount` is the FJD that is charged. Never shown to the Customer.

- `amount` (integer, required) — The price you sent, in cents of `currency`.
- `currency` (enum, required) — USD or AUD.
  - Allowed values: `USD`, `AUD`
- `rate` (string, required) — FJD per 1 unit of `currency`, a decimal string.
- `asOf` (integer, required) — Unix ms time the rate was taken.

### ErrorError

Branch on `code`; `message` is for logs.

- `code` (string, required) — Stable machine-readable error code.
- `message` (string, required) — Human-readable detail, not contractual.

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "id": "cs_3f9c2b1a",
  "status": "pending",
  "mode": "test",
  "amount": 5000,
  "currency": "FJD",
  "hostedUrl": "https://transxact.io/c/cs_3f9c2b1a",
  "metadata": {
    "orderId": "9912"
  },
  "expiresAt": 1717086400000,
  "invoiceNumber": "string",
  "quote": {
    "amount": 1,
    "currency": "USD",
    "rate": "string",
    "asOf": 1
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.transxact.io/v1/checkout-sessions"

payload = {}
headers = {
    "idempotency-key": "a1b2c3d4-order-9912",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.transxact.io/v1/checkout-sessions';
const options = {
  method: 'POST',
  headers: {
    'idempotency-key': 'a1b2c3d4-order-9912',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{}'
};

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"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.transxact.io/v1/checkout-sessions"

	payload := strings.NewReader("{}")

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

	req.Header.Add("idempotency-key", "a1b2c3d4-order-9912")
	req.Header.Add("Authorization", "Bearer <token>")
	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
require 'uri'
require 'net/http'

url = URI("https://api.transxact.io/v1/checkout-sessions")

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

request = Net::HTTP::Post.new(url)
request["idempotency-key"] = 'a1b2c3d4-order-9912'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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://api.transxact.io/v1/checkout-sessions")
  .header("idempotency-key", "a1b2c3d4-order-9912")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.transxact.io/v1/checkout-sessions', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'idempotency-key' => 'a1b2c3d4-order-9912',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.transxact.io/v1/checkout-sessions");
var request = new RestRequest(Method.POST);
request.AddHeader("idempotency-key", "a1b2c3d4-order-9912");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "idempotency-key": "a1b2c3d4-order-9912",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.transxact.io/v1/checkout-sessions")! 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()
```