> This page is for Spain Public Administration Flow.

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

# Issue a Session Token

PUT https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/{session_id}/session-token

Give an open session a new widget token, and the `widget_url` that carries it.

Every session is born with one: the `session_token` its creation returned, inside its `widget_url`. Call this while the session is open, when that link has to change hands — it leaked into a log, it was sent to the wrong person, your customer moved to another device — or to give a session whose token you [revoked](https://infonite.dev/flows/spain-public-administration/api-reference/spain-public-administration-api/sessions-management/flows-es-public-administration-v-1-session-token-revoke) a new one.

**The token the session had opens nothing from this moment**, and neither does any link built with it: a widget still open on the old link stops at its next step. There is one token per session — issuing is replacing.

**Key technical details:**

* **No request body.** The answer carries the new `session_token`, its `widget_url` and its `expiration_date` — the session's own, which a new token does not move.
* **Only while there is something left to do (`409`).** A closed session, or one past its `date_limit`, gets no new token; its current one can still be revoked.
* **Concurrency lock (`504`).** Issuing holds the session; if it cannot within a few seconds, retry.

The `widget_url` carries no way back of its own: append `completion_url` (and `completion_mode`) to it exactly as to the one the creation returned, when the session sets none.

> This endpoint needs to be executed with an app secret, so should always be used in server side without exposing the secret to customers.

Reference: https://infonite.dev/flows/spain-public-administration/api-reference/spain-public-administration-api/sessions-management/flows-es-public-administration-v-1-session-token-issue

## Authentication

- `X-APP-SECRET` header (required) — Application Secret

## Servers

- `https://widgets.infonite.tech/api/flows` (Legacy, default)
- `https://widgets.infonite.io/api/flows` (Production)

## Request

### Path parameters

- `session_id` (string, required) — Session ID to fetch

## Response

### 200

**200 OK**The new token and its widget link

- `session_token` (string, required) — The token your customer's widget acts on this one session with. It reads no results, and it opens nothing once it is revoked or replaced, or the session's `date_limit` has passed. Deleting the session does not end it: revoke it, before or after the deletion, when the link must stop.
- `widget_url` (string, required) — Where to send the end user, carrying this token: open it in an iframe, a new tab or a web view. When the session sets no way back of its own, you may append one to it: `completion_url` and `completion_mode`.
- `expiration_date` (string, required) — When the token is deleted, with the session: at least a day after its `date_limit`, past which it already opens nothing. Issuing another token does not move it.

## Errors

### 404 Not Found Error

**404 Not Found**Session not found

- `detail` (string, required) — Error message

### 409 Conflict Error

**409 Conflict**The session has closed

- `detail` (string, required) — Error message

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

### 429 Too Many Requests Error

**429 Too Many Requests**Too many requests. Rate limit exceeded.

- `detail` (string, required) — Error message

### 504 Gateway Timeout Error

**504 Gateway Timeout**Lock timeout, retry again

- `detail` (string, required) — Error message

## Types

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `input` (any, optional)
- `ctx` (ValidationErrorCtx, optional)

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

**Response**

```json
{
  "session_token": "st_test_R7fKq2LmW9xNpB3v.Tz8hY4cJ6dS1gA0eU5oQ",
  "widget_url": "https://infonite.app?session_token=st_test_R7fKq2LmW9xNpB3v.Tz8hY4cJ6dS1gA0eU5oQ",
  "expiration_date": "2026-09-19T10:15:02+00:00"
}
```

**SDK Code**

```python A new token, and its widget link
import requests

url = "https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/644599da47847b79c03cc94f/session-token"

headers = {"X-APP-SECRET": "<apiKey>"}

response = requests.put(url, headers=headers)

print(response.json())
```

```javascript A new token, and its widget link
const url = 'https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/644599da47847b79c03cc94f/session-token';
const options = {method: 'PUT', headers: {'X-APP-SECRET': '<apiKey>'}};

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

```go A new token, and its widget link
package main

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

func main() {

	url := "https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/644599da47847b79c03cc94f/session-token"

	req, _ := http.NewRequest("PUT", url, nil)

	req.Header.Add("X-APP-SECRET", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby A new token, and its widget link
require 'uri'
require 'net/http'

url = URI("https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/644599da47847b79c03cc94f/session-token")

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

request = Net::HTTP::Put.new(url)
request["X-APP-SECRET"] = '<apiKey>'

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

```java A new token, and its widget link
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/644599da47847b79c03cc94f/session-token")
  .header("X-APP-SECRET", "<apiKey>")
  .asString();
```

```php A new token, and its widget link
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/644599da47847b79c03cc94f/session-token', [
  'headers' => [
    'X-APP-SECRET' => '<apiKey>',
  ],
]);

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

```csharp A new token, and its widget link
using RestSharp;

var client = new RestClient("https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/644599da47847b79c03cc94f/session-token");
var request = new RestRequest(Method.PUT);
request.AddHeader("X-APP-SECRET", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift A new token, and its widget link
import Foundation

let headers = ["X-APP-SECRET": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/644599da47847b79c03cc94f/session-token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers

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()
```