> For a complete page index, fetch https://docs.transak.com/llms.txt

# Transaction Session API

POST https://api-gateway-stg.transak.com/api/v2/transaction-session
Content-Type: application/json

Creates a Headless Apple Pay transaction session. Returns a `sessionId` for your integration. Requires a valid user access token and approved KYC where applicable.

Reference: https://docs.transak.com/api/headless-apple-pay/transaction-session-api

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: headless-apple-pay-api
  version: 1.0.0
paths:
  /api/v2/transaction-session:
    post:
      operationId: transaction-session-api
      summary: Transaction Session API
      description: >-
        Creates a Headless Apple Pay transaction session. Returns a `sessionId`
        for your integration. Requires a valid user access token and approved
        KYC where applicable.
      tags:
        - ''
      parameters:
        - name: x-access-token
          in: header
          description: >-
            Your Partner Access Token. Please refer
            [here](/guides/how-to-create-partner-access-token) for a tutorial
            ongenerating your access token. 
          required: true
          schema:
            type: string
        - name: authorization
          in: header
          description: >-
            Authorization token is the accessToken received from the API -`
            api/v2/auth/verify`



            Note: This is not applicable for [Auth Reliance
            Flows](/features/auth-reliance)
          required: false
          schema:
            type: string
        - name: x-user-identifier
          in: header
          description: >-
            Your authenticated user Email Id address.



            Note: This is applicable only for [Auth Reliance
            Flows](/features/auth-reliance)
          required: false
          schema:
            type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionSessionSuccessResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorBody'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorBody'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorBody'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorBody'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTransactionSessionRequest'
servers:
  - url: https://api-gateway-stg.transak.com
components:
  schemas:
    CreateTransactionSessionRequestConfigColorMode:
      type: string
      enum:
        - DARK
        - LIGHT
      description: UI color mode for the Apple Pay flow.
      title: CreateTransactionSessionRequestConfigColorMode
    CreateTransactionSessionRequestConfig:
      type: object
      properties:
        colorMode:
          $ref: '#/components/schemas/CreateTransactionSessionRequestConfigColorMode'
          description: UI color mode for the Apple Pay flow.
        borderRadius:
          type: string
          description: CSS border radius applied to UI elements (e.g. `8px`).
        height:
          type: string
          description: CSS height applied to the Apple Pay container (e.g. `48px`).
      description: Additional optional UI configuration passed through to the session.
      title: CreateTransactionSessionRequestConfig
    CreateTransactionSessionRequest:
      type: object
      properties:
        quoteId:
          type: string
          description: Quote ID from the pricing API.
        walletAddress:
          type: string
          description: Destination crypto wallet address.
        config:
          $ref: '#/components/schemas/CreateTransactionSessionRequestConfig'
          description: Additional optional UI configuration passed through to the session.
      required:
        - quoteId
        - walletAddress
      title: CreateTransactionSessionRequest
    TransactionSessionData:
      type: object
      properties:
        sessionId:
          type: string
          description: Session token for the Headless Apple Pay flow.
      required:
        - sessionId
      title: TransactionSessionData
    TransactionSessionSuccessResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/TransactionSessionData'
      required:
        - data
      title: TransactionSessionSuccessResponse
    ApiErrorBodyError:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        errorCode:
          type: integer
          description: Machine-readable error code for client handling.
      required:
        - statusCode
        - message
      title: ApiErrorBodyError
    ApiErrorBody:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ApiErrorBodyError'
      required:
        - error
      title: ApiErrorBody

```

## SDK Code Examples

```python Success
import requests

url = "https://api-gateway-stg.transak.com/api/v2/transaction-session"

payload = {
    "quoteId": "q1234567890abcdef",
    "walletAddress": "0xAbC1234dEf567890aBcD1234567890EfABcDeF12"
}
headers = {
    "x-access-token": "",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Success
const url = 'https://api-gateway-stg.transak.com/api/v2/transaction-session';
const options = {
  method: 'POST',
  headers: {'x-access-token': '', 'Content-Type': 'application/json'},
  body: '{"quoteId":"q1234567890abcdef","walletAddress":"0xAbC1234dEf567890aBcD1234567890EfABcDeF12"}'
};

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

```go Success
package main

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

func main() {

	url := "https://api-gateway-stg.transak.com/api/v2/transaction-session"

	payload := strings.NewReader("{\n  \"quoteId\": \"q1234567890abcdef\",\n  \"walletAddress\": \"0xAbC1234dEf567890aBcD1234567890EfABcDeF12\"\n}")

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

	req.Header.Add("x-access-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 Success
require 'uri'
require 'net/http'

url = URI("https://api-gateway-stg.transak.com/api/v2/transaction-session")

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

request = Net::HTTP::Post.new(url)
request["x-access-token"] = ''
request["Content-Type"] = 'application/json'
request.body = "{\n  \"quoteId\": \"q1234567890abcdef\",\n  \"walletAddress\": \"0xAbC1234dEf567890aBcD1234567890EfABcDeF12\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api-gateway-stg.transak.com/api/v2/transaction-session")
  .header("x-access-token", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"quoteId\": \"q1234567890abcdef\",\n  \"walletAddress\": \"0xAbC1234dEf567890aBcD1234567890EfABcDeF12\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-gateway-stg.transak.com/api/v2/transaction-session', [
  'body' => '{
  "quoteId": "q1234567890abcdef",
  "walletAddress": "0xAbC1234dEf567890aBcD1234567890EfABcDeF12"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-access-token' => '',
  ],
]);

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

```csharp Success
using RestSharp;

var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/transaction-session");
var request = new RestRequest(Method.POST);
request.AddHeader("x-access-token", "");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"quoteId\": \"q1234567890abcdef\",\n  \"walletAddress\": \"0xAbC1234dEf567890aBcD1234567890EfABcDeF12\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Success
import Foundation

let headers = [
  "x-access-token": "",
  "Content-Type": "application/json"
]
let parameters = [
  "quoteId": "q1234567890abcdef",
  "walletAddress": "0xAbC1234dEf567890aBcD1234567890EfABcDeF12"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/transaction-session")! 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()
```

```python transaction-session-api_example
import requests

url = "https://api-gateway-stg.transak.com/api/v2/transaction-session"

payload = {
    "quoteId": "q1234567890abcdef",
    "walletAddress": "0xAbC1234dEf567890aBcD1234567890EfABcDeF12"
}
headers = {
    "x-access-token": "",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript transaction-session-api_example
const url = 'https://api-gateway-stg.transak.com/api/v2/transaction-session';
const options = {
  method: 'POST',
  headers: {'x-access-token': '', 'Content-Type': 'application/json'},
  body: '{"quoteId":"q1234567890abcdef","walletAddress":"0xAbC1234dEf567890aBcD1234567890EfABcDeF12"}'
};

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

```go transaction-session-api_example
package main

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

func main() {

	url := "https://api-gateway-stg.transak.com/api/v2/transaction-session"

	payload := strings.NewReader("{\n  \"quoteId\": \"q1234567890abcdef\",\n  \"walletAddress\": \"0xAbC1234dEf567890aBcD1234567890EfABcDeF12\"\n}")

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

	req.Header.Add("x-access-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 transaction-session-api_example
require 'uri'
require 'net/http'

url = URI("https://api-gateway-stg.transak.com/api/v2/transaction-session")

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

request = Net::HTTP::Post.new(url)
request["x-access-token"] = ''
request["Content-Type"] = 'application/json'
request.body = "{\n  \"quoteId\": \"q1234567890abcdef\",\n  \"walletAddress\": \"0xAbC1234dEf567890aBcD1234567890EfABcDeF12\"\n}"

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

```java transaction-session-api_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api-gateway-stg.transak.com/api/v2/transaction-session")
  .header("x-access-token", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"quoteId\": \"q1234567890abcdef\",\n  \"walletAddress\": \"0xAbC1234dEf567890aBcD1234567890EfABcDeF12\"\n}")
  .asString();
```

```php transaction-session-api_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-gateway-stg.transak.com/api/v2/transaction-session', [
  'body' => '{
  "quoteId": "q1234567890abcdef",
  "walletAddress": "0xAbC1234dEf567890aBcD1234567890EfABcDeF12"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-access-token' => '',
  ],
]);

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

```csharp transaction-session-api_example
using RestSharp;

var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/transaction-session");
var request = new RestRequest(Method.POST);
request.AddHeader("x-access-token", "");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"quoteId\": \"q1234567890abcdef\",\n  \"walletAddress\": \"0xAbC1234dEf567890aBcD1234567890EfABcDeF12\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift transaction-session-api_example
import Foundation

let headers = [
  "x-access-token": "",
  "Content-Type": "application/json"
]
let parameters = [
  "quoteId": "q1234567890abcdef",
  "walletAddress": "0xAbC1234dEf567890aBcD1234567890EfABcDeF12"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/transaction-session")! 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()
```