> 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 Cards transaction session. Returns a `sessionId` for your integration. Requires a valid partner access token and approved KYC where applicable. **Note:** Ensure the `quoteId` was generated with `paymentMethod` set to `credit_debit_card`. Reference: https://docs.transak.com/api/whitelabel/payments/headless-cards/transaction-session-api ## Request ### Headers - `x-user-ip` (string, required) — End user's originating IP. More details [here](/guides/mandatory-security-changes#user-ip-header-in-apis) - `x-api-key` (string, required) — Your Partner API key. You can find this in the [Partner Dashboard](https://docs.transak.com/guides/how-to-create-partner-dashboard-account#open-the-developers-section). - `x-access-token` (string, optional) — Your Partner Access Token. Please refer [here](/guides/how-to-create-partner-access-token) for a tutorial on generating your access token. Note: This is applicable only for [Auth Reliance Flows](/features/auth-reliance) - `x-user-identifier` (string, optional) — The authenticated user's email address. Note: This is applicable only for [Auth Reliance Flows](/features/auth-reliance). - `authorization` (string, optional) — 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) ### Body (application/json) This endpoint expects a CreateTransactionSessionRequest. - `quoteId` (string, required) — Quote ID from the [Quotes API](/api/whitelabel/lookup/get-quote). - `walletAddress` (string, required) — Destination crypto wallet address. - `successUrl` (string, required) — Redirect URL on payment success. - `failureUrl` (string, required) — Redirect URL on payment failure. - `config` (CreateTransactionSessionRequestConfig, optional) — Additional optional UI configuration passed through to the session. - `billingAddress` (CreateTransactionSessionRequestBillingAddress, optional) — Auto-fetched from user profile if omitted. ## Response ### 200 Success - `data` (TransactionSessionData, required) ## Errors ### 400 Bad Request Error Bad Request - `error` (ApiErrorBodyError, required) ### 401 Unauthorized Error Unauthorized - `error` (ApiErrorBodyError, required) ### 422 Unprocessable Entity Error Unprocessable Entity - `error` (ApiErrorBodyError, required) ### 500 Internal Server Error Internal Server Error - `error` (ApiErrorBodyError, required) ## Types ### CreateTransactionSessionRequestConfig Additional optional UI configuration passed through to the session. - `colorMode` (enum, optional) — UI color mode for the card payment flow. - Allowed values: `DARK`, `LIGHT` - `colors` (CreateTransactionSessionRequestConfigColors, optional) — Custom colors to override the base theme for the card payment flow. ### CreateTransactionSessionRequestBillingAddress Auto-fetched from user profile if omitted. - `addressLine1` (string, optional) - `addressLine2` (string, optional) - `city` (string, optional) - `state` (string, optional) - `postCode` (string, optional) - `country` (string, optional) - `countryCode` (string, optional) ### TransactionSessionData - `sessionId` (string, required) — Session token for the Headless Cards flow. - `expiresAt` (datetime, required) — Session expiration timestamp. ### ApiErrorBodyError - `statusCode` (integer, required) - `message` (string, required) - `errorCode` (integer, optional) — Machine-readable error code for client handling. ### ApiErrorBodyError - `statusCode` (integer, required) - `message` (string, required) - `errorCode` (integer, optional) — Machine-readable error code for client handling. ### CreateTransactionSessionRequestConfigColors Custom colors to override the base theme for the card payment flow. - `widgetBackgroundFillColor` (string, optional) — Background color of the card screen. Only `hex` values are supported. - `brandColor` (string, optional) — Border color of the focused input field. Only `hex` values are supported. - `textPrimaryColor` (string, optional) — Color of the input text. Only `hex` values are supported. - `textSecondaryColor` (string, optional) — Color of field labels and placeholder text. Only `hex` values are supported. - `surfaceFillColor` (string, optional) — Background color of input fields. Only `hex` values are supported. - `borderColor` (string, optional) — Border color of input fields. Only `hex` values are supported. - `redColor` (string, optional) — Color used for error states, applied to borders and text. Only `hex` values are supported. ## Examples **Request** ```json { "quoteId": "", "walletAddress": "", "successUrl": "", "failureUrl": "", "config": { "colorMode": "LIGHT", "colors": { "widgetBackgroundFillColor": "#F4F4F4", "brandColor": "#1461DB", "textPrimaryColor": "#000000", "textSecondaryColor": "#666666", "surfaceFillColor": "#F5F5F5", "borderColor": "#EBEBEB", "redColor": "#F32139" } } } ``` **Response** ```json { "data": { "sessionId": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJvdHQiOiJjOTU4NTQ0MzQzZjI4YjM4NGQ5OGExM2JjZmU3OTk2YSIsImlhdCI6MTc4MDM2ODM3MywiZXhwIjoxNzgwMzY4OTczfQ.BLlwJbGrH-jRBwAWhJgPIDmcDFYvpIOZCMEVaZhhB4RC3LovyeFj8qeT5GYzR5aA6oO6JMOQM419mWYZS53yDg", "expiresAt": "2026-06-02T02:56:13.000Z" } } ``` **SDK Code** ```python Success import requests url = "https://api-gateway-stg.transak.com/api/v2/transaction-session" payload = { "quoteId": "", "walletAddress": "", "successUrl": "", "failureUrl": "", "config": { "colorMode": "LIGHT", "colors": { "widgetBackgroundFillColor": "#F4F4F4", "brandColor": "#1461DB", "textPrimaryColor": "#000000", "textSecondaryColor": "#666666", "surfaceFillColor": "#F5F5F5", "borderColor": "#EBEBEB", "redColor": "#F32139" } } } headers = { "x-api-key": "", "x-user-ip": "", "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-api-key': '', 'x-user-ip': '', 'Content-Type': 'application/json'}, body: '{"quoteId":"","walletAddress":"","successUrl":"","failureUrl":"","config":{"colorMode":"LIGHT","colors":{"widgetBackgroundFillColor":"#F4F4F4","brandColor":"#1461DB","textPrimaryColor":"#000000","textSecondaryColor":"#666666","surfaceFillColor":"#F5F5F5","borderColor":"#EBEBEB","redColor":"#F32139"}}}' }; 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\": \"\",\n \"walletAddress\": \"\",\n \"successUrl\": \"\",\n \"failureUrl\": \"\",\n \"config\": {\n \"colorMode\": \"LIGHT\",\n \"colors\": {\n \"widgetBackgroundFillColor\": \"#F4F4F4\",\n \"brandColor\": \"#1461DB\",\n \"textPrimaryColor\": \"#000000\",\n \"textSecondaryColor\": \"#666666\",\n \"surfaceFillColor\": \"#F5F5F5\",\n \"borderColor\": \"#EBEBEB\",\n \"redColor\": \"#F32139\"\n }\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("x-api-key", "") req.Header.Add("x-user-ip", "") 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-api-key"] = '' request["x-user-ip"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"quoteId\": \"\",\n \"walletAddress\": \"\",\n \"successUrl\": \"\",\n \"failureUrl\": \"\",\n \"config\": {\n \"colorMode\": \"LIGHT\",\n \"colors\": {\n \"widgetBackgroundFillColor\": \"#F4F4F4\",\n \"brandColor\": \"#1461DB\",\n \"textPrimaryColor\": \"#000000\",\n \"textSecondaryColor\": \"#666666\",\n \"surfaceFillColor\": \"#F5F5F5\",\n \"borderColor\": \"#EBEBEB\",\n \"redColor\": \"#F32139\"\n }\n }\n}" response = http.request(request) puts response.read_body ``` ```java Success import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api-gateway-stg.transak.com/api/v2/transaction-session") .header("x-api-key", "") .header("x-user-ip", "") .header("Content-Type", "application/json") .body("{\n \"quoteId\": \"\",\n \"walletAddress\": \"\",\n \"successUrl\": \"\",\n \"failureUrl\": \"\",\n \"config\": {\n \"colorMode\": \"LIGHT\",\n \"colors\": {\n \"widgetBackgroundFillColor\": \"#F4F4F4\",\n \"brandColor\": \"#1461DB\",\n \"textPrimaryColor\": \"#000000\",\n \"textSecondaryColor\": \"#666666\",\n \"surfaceFillColor\": \"#F5F5F5\",\n \"borderColor\": \"#EBEBEB\",\n \"redColor\": \"#F32139\"\n }\n }\n}") .asString(); ``` ```php Success request('POST', 'https://api-gateway-stg.transak.com/api/v2/transaction-session', [ 'body' => '{ "quoteId": "", "walletAddress": "", "successUrl": "", "failureUrl": "", "config": { "colorMode": "LIGHT", "colors": { "widgetBackgroundFillColor": "#F4F4F4", "brandColor": "#1461DB", "textPrimaryColor": "#000000", "textSecondaryColor": "#666666", "surfaceFillColor": "#F5F5F5", "borderColor": "#EBEBEB", "redColor": "#F32139" } } }', 'headers' => [ 'Content-Type' => 'application/json', 'x-api-key' => '', 'x-user-ip' => '', ], ]); 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-api-key", ""); request.AddHeader("x-user-ip", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"quoteId\": \"\",\n \"walletAddress\": \"\",\n \"successUrl\": \"\",\n \"failureUrl\": \"\",\n \"config\": {\n \"colorMode\": \"LIGHT\",\n \"colors\": {\n \"widgetBackgroundFillColor\": \"#F4F4F4\",\n \"brandColor\": \"#1461DB\",\n \"textPrimaryColor\": \"#000000\",\n \"textSecondaryColor\": \"#666666\",\n \"surfaceFillColor\": \"#F5F5F5\",\n \"borderColor\": \"#EBEBEB\",\n \"redColor\": \"#F32139\"\n }\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Success import Foundation let headers = [ "x-api-key": "", "x-user-ip": "", "Content-Type": "application/json" ] let parameters = [ "quoteId": "", "walletAddress": "", "successUrl": "", "failureUrl": "", "config": [ "colorMode": "LIGHT", "colors": [ "widgetBackgroundFillColor": "#F4F4F4", "brandColor": "#1461DB", "textPrimaryColor": "#000000", "textSecondaryColor": "#666666", "surfaceFillColor": "#F5F5F5", "borderColor": "#EBEBEB", "redColor": "#F32139" ] ] ] 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() ```