> 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-access-token.md).

# Create Access Token

## Overview

The `CreateAccessToken` RPC generates a short-lived authentication token for connector API access. These tokens expire quickly (typically 1 hour) and can be safely used in client applications without exposing your main API credentials.

**Business Use Case:** When building client-side payment flows (browser checkout, mobile apps), you need to give clients limited access to the payment processor without exposing your full API keys. This RPC generates temporary tokens that clients can use for operations like card tokenization.

## Purpose

**Why use short-lived access tokens?**

| Scenario                     | Risk Without Tokens            | Solution                           |
| ---------------------------- | ------------------------------ | ---------------------------------- |
| **Browser checkout**         | API keys exposed in JavaScript | Temporary token with limited scope |
| **Mobile apps**              | API keys in app bundle         | Token generated per session        |
| **Third-party integrations** | Full API access granted        | Scoped token with expiration       |

**Key outcomes:**

* Temporary access token (1 hour typical)
* Limited scope permissions
* Safe for client-side use
* Automatic expiration

## Request Fields

| Field                      | Type         | Required | Description                            |
| -------------------------- | ------------ | -------- | -------------------------------------- |
| `merchant_access_token_id` | string       | Yes      | Your unique token reference            |
| `connector`                | Connector    | Yes      | Target connector (STRIPE, ADYEN, etc.) |
| `metadata`                 | SecretString | No       | Additional metadata for the connector  |
| `connector_feature_data`   | SecretString | No       | Connector-specific metadata            |
| `test_mode`                | bool         | No       | Generate test/sandbox token            |

## Response Fields

| Field                      | Type            | Description                                     |
| -------------------------- | --------------- | ----------------------------------------------- |
| `access_token`             | SecretString    | The access token string (e.g., "pk\_live\_...") |
| `token_type`               | string          | Token type (e.g., "Bearer", "Basic")            |
| `expires_in_seconds`       | int64           | Expiration timestamp (Unix epoch)               |
| `status`                   | OperationStatus | Status of token creation                        |
| `error`                    | ErrorInfo       | Error details if creation failed                |
| `status_code`              | uint32          | HTTP-style status code                          |
| `merchant_access_token_id` | string          | Your token reference (echoed back)              |

## Example

### Request (grpcurl)

```bash
grpcurl -H "x-connector: stripe" \
  -H "x-connector-config: {\"config\":{\"Stripe\":{\"api_key\":\"$STRIPE_API_KEY\"}}}" \
  -d '{
    "merchant_access_token_id": "token_001",
    "connector": "STRIPE",
    "test_mode": true
  }' \
  localhost:8080 \
  types.MerchantAuthenticationService/CreateAccessToken
```

### Response

```json
{
  "access_token": "pk_test_1234567890abcdef",
  "token_type": "Bearer",
  "expires_in_seconds": 1704153600,
  "status": "SUCCESS",
  "status_code": 200
}
```

## Next Steps

* [CreateSessionToken](/integrations/prism/api-reference/merchant-authentication-service/create-session-token.md) - Create session tokens for payment flows
* [CreateSdkSessionToken](/integrations/prism/api-reference/merchant-authentication-service/create-sdk-session-token.md) - Initialize wallet payment sessions


---

# 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-access-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.
