> For the complete documentation index, see [llms.txt](https://docs.hyperswitch.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyperswitch.io/integrations/prism/api-reference/merchant-authentication-service/create-session-token.md).

# Create Session Token

## Overview

The `CreateSessionToken` RPC creates a session token for payment processing. This token maintains state across multiple payment operations, enabling secure tracking and improved security for multi-step payment flows.

**Business Use Case:** When processing payments that require multiple steps (3DS authentication, redirect flows, wallet payments), you need to maintain session state between requests. This RPC creates a session token that carries context through the entire payment journey.

## Purpose

**Why use session tokens?**

| Scenario                | Session Token Benefit                   |
| ----------------------- | --------------------------------------- |
| **3DS authentication**  | Maintain context through challenge flow |
| **Redirect payments**   | Preserve state during bank redirects    |
| **Multi-step checkout** | Track progress across pages             |
| **Security**            | Bind payment to specific session        |

**Key outcomes:**

* Session-scoped payment context
* Secure state management
* Cross-request continuity
* Enhanced fraud protection

## Request Fields

| Field                    | Type               | Required | Description                           |
| ------------------------ | ------------------ | -------- | ------------------------------------- |
| `merchant_session_id`    | string             | Yes      | Your unique session reference         |
| `amount`                 | Money              | Yes      | Payment amount for this session       |
| `metadata`               | SecretString       | No       | Additional metadata for the connector |
| `connector_feature_data` | SecretString       | No       | Connector-specific metadata           |
| `state`                  | ConnectorState     | No       | Existing state to continue session    |
| `browser_info`           | BrowserInformation | No       | Browser details for fraud detection   |
| `test_mode`              | bool               | No       | Use test/sandbox environment          |

## Response Fields

| Field           | Type      | Description                             |
| --------------- | --------- | --------------------------------------- |
| `error`         | ErrorInfo | Error details if creation failed        |
| `status_code`   | uint32    | HTTP-style status code                  |
| `session_token` | string    | Session token for subsequent operations |

## Example

### Request (grpcurl)

```bash
grpcurl -H "x-connector: stripe" \
  -H "x-connector-config: {\"config\":{\"Stripe\":{\"api_key\":\"$STRIPE_API_KEY\"}}}" \
  -d '{
    "merchant_session_id": "session_001",
    "amount": {
      "minor_amount": 10000,
      "currency": "USD"
    },
    "browser_info": {
      "accept_header": "text/html",
      "user_agent": "Mozilla/5.0..."
    },
    "test_mode": true
  }' \
  localhost:8080 \
  types.MerchantAuthenticationService/CreateSessionToken
```

### Response

```json
{
  "session_token": "sess_1234567890abcdef",
  "status_code": 200
}
```

## Next Steps

* [CreateAccessToken](/integrations/prism/api-reference/merchant-authentication-service/create-access-token.md) - Generate API access tokens
* [CreateSdkSessionToken](/integrations/prism/api-reference/merchant-authentication-service/create-sdk-session-token.md) - Initialize wallet sessions
* [Payment Service](/integrations/prism/api-reference/payment-service.md) - Process payments using session


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hyperswitch.io/integrations/prism/api-reference/merchant-authentication-service/create-session-token.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
