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

# Create Order

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

The **Create Order** is an **authenticated API** that places a **crypto buy order** using Google Pay, based on the `requestId` returned when the user submits their payment details via the [Transak UI SDK](/features/headless-google-pay#load-the-google-pay-component-via-transak-ui-sdk).

Reference: https://docs.transak.com/api/whitelabel/payments/headless-google-pay/create-order-for-google-pay

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: whitelabel-api
  version: 1.0.0
paths:
  /api/v2/orders:
    post:
      operationId: create-order-for-google-pay
      summary: Create Order
      description: >-
        The **Create Order** is an **authenticated API** that places a **crypto
        buy order** using Google Pay, based on the `requestId` returned when the
        user submits their payment details via the [Transak UI
        SDK](/features/headless-google-pay#load-the-google-pay-component-via-transak-ui-sdk).
      tags:
        - headlessGooglePay
      parameters:
        - name: x-user-ip
          in: header
          description: >-
            End user's originating IP. More details
            [here](/guides/mandatory-security-changes#user-ip-header-in-apis)
          required: true
          schema:
            type: string
        - name: x-api-key
          in: header
          description: >-
            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).
          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-access-token
          in: header
          description: >-
            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)
          required: false
          schema:
            type: string
        - name: x-user-identifier
          in: header
          description: >-
            The authenticated user's email 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/headlessGooglePay:OrderCreatedResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/headlessGooglePay:ApiErrorBody'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/headlessGooglePay:ApiErrorBody'
        '404':
          description: Request ID Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/headlessGooglePay:ApiErrorBody'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/headlessGooglePay:ApiErrorBody'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/headlessGooglePay:ApiErrorBody'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/headlessGooglePay:CreateOrderRequest'
servers:
  - url: https://api-gateway-stg.transak.com
    description: Staging
components:
  schemas:
    headlessGooglePay:CreateOrderRequest:
      type: object
      properties:
        requestId:
          type: string
          description: >-
            Request ID returned in the `onSuccess` callback of the [Transak UI
            SDK](/features/headless-google-pay#load-the-google-pay-component-via-transak-ui-sdk).
      required:
        - requestId
      title: CreateOrderRequest
    headlessGooglePay:OrderCreatedResponseDataPaymentDetailsItems:
      type: object
      properties:
        fiatCurrency:
          type: string
        fields:
          type: string
          description: Payment method specific fields (may be truncated).
        name:
          type: string
          description: Display name of the payment method.
        paymentMethod:
          type: string
          description: Payment method identifier.
        redirectUrl:
          type: string
          description: URL to redirect the user for payment authentication.
      title: OrderCreatedResponseDataPaymentDetailsItems
    headlessGooglePay:OrderCreatedResponseDataAddressAdditionalData:
      type: object
      properties:
        name:
          type: string
        displayName:
          type: string
        value:
          type: string
        requestId:
          type: string
      title: OrderCreatedResponseDataAddressAdditionalData
    headlessGooglePay:OrderCreatedResponseData:
      type: object
      properties:
        paymentDetails:
          type: array
          items:
            $ref: >-
              #/components/schemas/headlessGooglePay:OrderCreatedResponseDataPaymentDetailsItems
        orderId:
          type: string
          description: Unique identifier for the created order.
        partnerUserId:
          type: string
          description: Partner's user identifier associated with this order.
        status:
          type: string
          description: Current order status (e.g. AWAITING_PAYMENT_FROM_USER).
        isBuyOrSell:
          type: string
          description: Indicates whether the order is a BUY or SELL.
        fiatCurrency:
          type: string
          description: Fiat currency used for the order.
        cryptoCurrency:
          type: string
          description: Crypto asset being purchased.
        paymentMethod:
          type: string
          description: Payment method used. Always `google_pay` for this flow.
        network:
          type: string
          description: Blockchain network for the crypto asset.
        networkId:
          type: string
          description: Chain ID of the network.
        walletAddress:
          type: string
          description: Destination wallet address for the crypto.
        quoteId:
          type: string
          description: Quote ID used to create this order.
        fiatAmount:
          type: number
          format: double
          description: Fiat amount for the order.
        fiatAmountInUsd:
          type: number
          format: double
          description: Fiat amount converted to USD.
        amountPaid:
          type: number
          format: double
          description: Amount already paid by the user.
        cryptoAmount:
          type: number
          format: double
          description: Crypto amount the user will receive.
        conversionPrice:
          type: number
          format: double
          description: Fiat-to-crypto conversion rate.
        totalFeeInFiat:
          type: number
          format: double
          description: Total fee charged in fiat currency.
        txHash:
          type: string
          description: >-
            Blockchain transaction hash. Empty until the transaction is
            confirmed on-chain.
        walletLink:
          type: string
          description: Block explorer link for the wallet address.
        transactionLink:
          type: string
          description: Block explorer link for the transaction.
        addressAdditionalData:
          $ref: >-
            #/components/schemas/headlessGooglePay:OrderCreatedResponseDataAddressAdditionalData
      required:
        - orderId
        - status
        - isBuyOrSell
        - fiatCurrency
        - cryptoCurrency
        - paymentMethod
        - network
        - fiatAmount
        - fiatAmountInUsd
        - cryptoAmount
      description: >-
        Order details returned after processing the Google Pay transaction
        session.
      title: OrderCreatedResponseData
    headlessGooglePay:OrderCreatedResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/headlessGooglePay:OrderCreatedResponseData'
          description: >-
            Order details returned after processing the Google Pay transaction
            session.
      required:
        - data
      description: Order created successfully.
      title: OrderCreatedResponse
    headlessGooglePay: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
    headlessGooglePay:ApiErrorBody:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/headlessGooglePay:ApiErrorBodyError'
      required:
        - error
      title: ApiErrorBody

```

## Examples



**Request**

```json
{
  "requestId": "a37a22c3-620f-4612-b91e-fc52e83becf9"
}
```

**Response**

```json
{
  "data": {
    "orderId": "86be4fec-aaff-4734-a8d5-ef757b04a75a",
    "status": "AWAITING_PAYMENT_FROM_USER",
    "isBuyOrSell": "BUY",
    "fiatCurrency": "EUR",
    "cryptoCurrency": "ETH",
    "paymentMethod": "google_pay",
    "network": "ethereum",
    "fiatAmount": 50,
    "fiatAmountInUsd": 57.33,
    "cryptoAmount": 0.02976623,
    "paymentDetails": [
      {
        "fiatCurrency": "EUR",
        "fields": "[]",
        "name": "Google Pay",
        "paymentMethod": "google_pay",
        "redirectUrl": "https://authentication-devices.sandbox.checkout.com/sessions-interceptor/sid_tsf3rqybr7eyforc7ke3jsbcrm"
      }
    ],
    "partnerUserId": "c80b828d-732d-4117-8394-2f824cd00095",
    "networkId": "",
    "walletAddress": "0xc850e65151fA2f50636618d4688CF1A011AC04bF",
    "quoteId": "59000ed7-0167-431b-9294-16221a675605",
    "amountPaid": 0,
    "conversionPrice": 0.0006233766403249686,
    "totalFeeInFiat": 2.25,
    "txHash": "",
    "walletLink": "https://sepolia.etherscan.io/address/0xc850e65151fA2f50636618d4688CF1A011AC04bF",
    "transactionLink": "",
    "addressAdditionalData": {
      "name": "",
      "displayName": "",
      "value": "",
      "requestId": "b1f1c8c5-4c11-45e4-a1a0-e991303822df"
    }
  }
}
```

**SDK Code**

```python Success
import requests

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

payload = { "requestId": "a37a22c3-620f-4612-b91e-fc52e83becf9" }
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/orders';
const options = {
  method: 'POST',
  headers: {'x-api-key': '', 'x-user-ip': '', 'Content-Type': 'application/json'},
  body: '{"requestId":"a37a22c3-620f-4612-b91e-fc52e83becf9"}'
};

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/orders"

	payload := strings.NewReader("{\n  \"requestId\": \"a37a22c3-620f-4612-b91e-fc52e83becf9\"\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/orders")

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  \"requestId\": \"a37a22c3-620f-4612-b91e-fc52e83becf9\"\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/orders")
  .header("x-api-key", "")
  .header("x-user-ip", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"requestId\": \"a37a22c3-620f-4612-b91e-fc52e83becf9\"\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/orders', [
  'body' => '{
  "requestId": "a37a22c3-620f-4612-b91e-fc52e83becf9"
}',
  '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/orders");
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  \"requestId\": \"a37a22c3-620f-4612-b91e-fc52e83becf9\"\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 = ["requestId": "a37a22c3-620f-4612-b91e-fc52e83becf9"] as [String : Any]

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

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