> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.useroot.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.useroot.com/_mcp/server.

# Create payee session token

POST https://api.useroot.com/api/session-tokens
Content-Type: application/json

Generate a session token for frontend use.

This endpoint can only be called with an API token context.
It generates a short-lived JWT token with specific scopes for managing payment methods.

The process:
1. API token authenticates the request
2. Payee ID is provided in the request
3. System validates the payee ID belongs to the API token's root entity
4. A session token is created containing the payee's ID, root entity ID, and manage payment methods scopes

This allows frontend applications to make authenticated requests on behalf of a specific payee.

Reference: https://docs.useroot.com/api-reference/session-tokens-api/create-payee-session-token

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: '[Code Generated] Root - Instant Account to Account Money Movement'
  version: 1.0.0
paths:
  /api/session-tokens:
    post:
      operationId: create-payee-session-token
      summary: Create payee session token
      description: >-
        Generate a session token for frontend use.


        This endpoint can only be called with an API token context.

        It generates a short-lived JWT token with specific scopes for managing
        payment methods.


        The process:

        1. API token authenticates the request

        2. Payee ID is provided in the request

        3. System validates the payee ID belongs to the API token's root entity

        4. A session token is created containing the payee's ID, root entity ID,
        and manage payment methods scopes


        This allows frontend applications to make authenticated requests on
        behalf of a specific payee.
      tags:
        - sessionTokensApi
      parameters:
        - name: x-api-key
          in: header
          description: >-
            RootPay API key sent in the x-api-key header. Keys are
            environment-scoped: live_* for production, test_* for sandbox.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionTokenResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SessionTokenRequest'
servers:
  - url: https://api.useroot.com
    description: Production
components:
  schemas:
    SessionTokenRequest:
      type: object
      properties:
        payee_id:
          type: string
          format: uuid
          description: >-
            UUID of the payee to create a token for. This will be used as the
            user identifier in the token.
      required:
        - payee_id
      description: Request to generate a session token.
      title: SessionTokenRequest
    SessionTokenResponse:
      type: object
      properties:
        token:
          type: string
          description: JWT token to be used for further requests
        expires_in_seconds:
          type: integer
          description: Number of seconds until this token expires
        scopes:
          type: array
          items:
            type: string
          description: Permission scopes granted to this token
      required:
        - token
        - expires_in_seconds
        - scopes
      description: Response containing a session token.
      title: SessionTokenResponse
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        RootPay API key sent in the x-api-key header. Keys are
        environment-scoped: live_* for production, test_* for sandbox.

```

## Examples



**Request**

```json
{
  "payee_id": "string"
}
```

**Response**

```json
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expires_in_seconds": 36000,
  "scopes": [
    "list_methods",
    "add_method",
    "set_default",
    "delete_method",
    "view_payee"
  ]
}
```

**SDK Code**

```python Legacy payee session token response
import requests

url = "https://api.useroot.com/api/session-tokens"

payload = { "payee_id": "string" }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Legacy payee session token response
const url = 'https://api.useroot.com/api/session-tokens';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"payee_id":"string"}'
};

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

```go Legacy payee session token response
package main

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

func main() {

	url := "https://api.useroot.com/api/session-tokens"

	payload := strings.NewReader("{\n  \"payee_id\": \"string\"\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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 Legacy payee session token response
require 'uri'
require 'net/http'

url = URI("https://api.useroot.com/api/session-tokens")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"payee_id\": \"string\"\n}"

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

```java Legacy payee session token response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.useroot.com/api/session-tokens")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"payee_id\": \"string\"\n}")
  .asString();
```

```php Legacy payee session token response
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.useroot.com/api/session-tokens', [
  'body' => '{
  "payee_id": "string"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Legacy payee session token response
using RestSharp;

var client = new RestClient("https://api.useroot.com/api/session-tokens");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"payee_id\": \"string\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Legacy payee session token response
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["payee_id": "string"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.useroot.com/api/session-tokens")! 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()
```