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

# Get Session State

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

Retrieve the current execution state, lifecycle status, and active cursor screen of the flow session.

This endpoint allows synchronous checking of a session's progress. While webhooks (configured via [Create/Update Webhook](api:PATCH/es-public-administration/v1/hooks/update)) are the recommended asynchronous way to track status updates, this endpoint is useful for clients that want to keep their backend state synchronized with INFONITE.

Common use cases include:
- Polling for session completion or terminal failure status when webhooks are not implemented.
- Retrieving the active cursor/screen to display progress or updates in client dashboards.
- Recovering and synchronizing the final session state if a connection is lost during the flow.

<Warning title="A session is finished only when is_closed is true">
  If polling, poll this endpoint for **`is_closed`**, not for anything else. While it is `false` the session is still alive — even if the customer left, even if the widget closed, even if you already received partial results. A source may still be working in the background (the *CIRBE* report from the Banco de España is the usual case), and records can still change or appear.

  `status_code` alone is not the answer: a session sitting on `WAITING` with the cursor at `es-public-administration:connect:wait` is unfinished by design, not stuck.
</Warning>

> 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/api-reference/spain-public-administration/spain-public-administration-api/sessions-management/flows-es-public-administration-v-1-session-state

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: es-public-administration-v1-0-0-openapi
  version: 1.0.0
paths:
  /es-public-administration/v1/manager/{session_id}:
    get:
      operationId: flows:es-public-administration:v1:session-state
      summary: Get Session State
      description: >
        Retrieve the current execution state, lifecycle status, and active
        cursor screen of the flow session.


        This endpoint allows synchronous checking of a session's progress. While
        webhooks (configured via [Create/Update
        Webhook](api:PATCH/es-public-administration/v1/hooks/update)) are the
        recommended asynchronous way to track status updates, this endpoint is
        useful for clients that want to keep their backend state synchronized
        with INFONITE.


        Common use cases include:

        - Polling for session completion or terminal failure status when
        webhooks are not implemented.

        - Retrieving the active cursor/screen to display progress or updates in
        client dashboards.

        - Recovering and synchronizing the final session state if a connection
        is lost during the flow.


        <Warning title="A session is finished only when is_closed is true">
          If polling, poll this endpoint for **`is_closed`**, not for anything else. While it is `false` the session is still alive — even if the customer left, even if the widget closed, even if you already received partial results. A source may still be working in the background (the *CIRBE* report from the Banco de España is the usual case), and records can still change or appear.

          `status_code` alone is not the answer: a session sitting on `WAITING` with the cursor at `es-public-administration:connect:wait` is unfinished by design, not stuck.
        </Warning>


        > This endpoint needs to be executed with an app secret, so should
        always be used in server side without exposing the secret to customers.
      tags:
        - sessionsManagement
      parameters:
        - name: session_id
          in: path
          description: Session ID to fetch
          required: true
          schema:
            type: string
            format: ObjectId
        - name: X-APP-SECRET
          in: header
          description: Application Secret
          required: true
          schema:
            type: string
      responses:
        '200':
          description: '**200 OK**<br>State of the session'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlowStateSchema'
        '404':
          description: '**404 Not Found**<br>Session not found'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: '**429 Too Many Requests**<br>Too many requests. Rate limit exceeded.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '504':
          description: '**504 Gateway Timeout**<br>Lock timeout, retry again'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
servers:
  - url: https://widgets.infonite.tech/api/flows
    description: Production Server
  - url: https://widgets-dev.infonite.tech/api/flows
    description: Development Server
  - url: /api/flows
    description: Local Server
components:
  schemas:
    FlowStateSchemaCursor:
      type: string
      enum:
        - es-public-administration:welcome:init
        - es-public-administration:welcome:consent
        - es-public-administration:connect:source
        - es-public-administration:connect:wait
        - es-public-administration:bye:completed
        - es-public-administration:bye:failure
      description: >-
        The current screen identifier where the user is positioned in the widget
        experience.
      title: FlowStateSchemaCursor
    FlowStateSchemaStatusCode:
      type: string
      enum:
        - READY
        - WAITING
        - COMPLETED
        - FAILED
        - SYSTEM_CANCELLED
        - CLIENT_CANCELLED
        - CUSTOMER_CANCELLED
        - TIMED_OUT
        - CONFIGURATION_ERROR
      description: >-
        The current execution status of the flow session (e.g., initialized,
        completed, etc.).
      title: FlowStateSchemaStatusCode
    FlowStateSchemaEndHook:
      type: string
      enum:
        - skipped
        - pending
        - delivered
        - re_delivered
        - doubtful
        - failed
        - ko
      description: Delivery status of the final webhook event callback.
      title: FlowStateSchemaEndHook
    FlowStateSchema:
      type: object
      properties:
        kind:
          type: string
          enum:
            - es-public-administration
          description: The flow type identifier, always 'es-public-administration'.
        cursor:
          $ref: '#/components/schemas/FlowStateSchemaCursor'
          description: >-
            The current screen identifier where the user is positioned in the
            widget experience.
        session_id:
          type: string
          format: ObjectId
          description: The unique database identifier of the created flow session.
        app_id:
          type: string
          format: ObjectId
          description: The identifier of the client application that owns this session.
        customer_id:
          type: string
          description: >-
            The external identifier of the customer in your system. Used for
            auditing and tracking.
        status_code:
          $ref: '#/components/schemas/FlowStateSchemaStatusCode'
          description: >-
            The current execution status of the flow session (e.g., initialized,
            completed, etc.).
        status_message:
          type: string
          description: An informative status message describing the current session state.
        date_created:
          type: string
          format: datetime
          description: The timestamp when this flow session was created.
        date_started:
          type: string
          format: datetime
          description: The timestamp when the customer opened the session widget.
        ping_date:
          type: string
          format: datetime
          description: The timestamp of the last customer interaction or heartbeat.
        date_ended:
          type: string
          format: datetime
          description: The timestamp when the flow session was finalized or closed.
        date_limit:
          type: string
          format: datetime
          description: >-
            Custom expiration deadline for this session. After this timestamp,
            the widget cannot be opened.
        expiration_date:
          type: string
          format: datetime
          description: >-
            The timestamp when this session record will be auto-deleted from the
            database.
        end_hook:
          $ref: '#/components/schemas/FlowStateSchemaEndHook'
          description: Delivery status of the final webhook event callback.
        is_closed:
          type: boolean
          description: Indicates if the flow session has been finalized or closed.
      required:
        - kind
        - cursor
        - session_id
        - app_id
        - customer_id
        - status_code
        - date_created
        - date_limit
        - expiration_date
        - is_closed
      title: FlowStateSchema
    ErrorResponse:
      type: object
      properties:
        detail:
          type: string
          description: Error message
      required:
        - detail
      description: Error response details
      title: ErrorResponse
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationErrorCtx:
      type: object
      properties: {}
      title: ValidationErrorCtx
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
        input:
          description: Any type
        ctx:
          $ref: '#/components/schemas/ValidationErrorCtx'
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError
  securitySchemes:
    Application-Secret:
      type: apiKey
      in: header
      name: X-APP-SECRET
      description: Application Secret

```

## Examples



**Response**

```json
{
  "kind": "string",
  "cursor": "es-public-administration:welcome:init",
  "session_id": "644599da47847b79c03cc94f",
  "app_id": "644599da47847b79c03cc94f",
  "customer_id": "string",
  "status_code": "READY",
  "date_created": "2023-10-05T14:46:36.546596Z",
  "date_limit": "2023-10-05T14:46:36.546596Z",
  "expiration_date": "2023-10-05T14:46:36.546596Z",
  "is_closed": true,
  "status_message": "string",
  "date_started": "2023-10-05T14:46:36.546596Z",
  "ping_date": "2023-10-05T14:46:36.546596Z",
  "date_ended": "2023-10-05T14:46:36.546596Z",
  "end_hook": "skipped"
}
```

**SDK Code**

```python
import requests

url = "https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/session_id"

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

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

print(response.json())
```

```javascript
const url = 'https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/session_id';
const options = {method: 'GET', 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
package main

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

func main() {

	url := "https://widgets.infonite.tech/api/flows/es-public-administration/v1/manager/session_id"

	req, _ := http.NewRequest("GET", 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
require 'uri'
require 'net/http'

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

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

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

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp
using RestSharp;

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

```swift
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/session_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```