Skip to navigation

Create Session

View as Markdown

Initialize a Spain Public Administration flow session to access government portals and retrieve public records.

This endpoint starts the flow lifecycle. Upon successful creation, it returns a session_id and a widget_url. Your frontend application must redirect the customer to the widget_url so they can log in and sign the consent form.

Once the customer completes the widget journey, a webhook notification is delivered (if configured), and the decrypted results can be downloaded using the Get Session Results endpoint.

What the session reads is settings.executions_features, one code per source — ask only for what you need:

To readSend
The Social Security work history and contribution baseslabor_check
The public pensions the person receivespublic_pensions
The Banco de España’s credit registry (CIRBE)credit_registry_data
The driving licence, and the vehicles registered to the persondriver_data, vehicles_data
The yearly tax situation, from the Agencia Tributaria (AEAT)yearly_individual_tax
The academic degrees the person holdsacademic_data
The real estate the person ownsproperties_data
The person’s identity, as the administration holds itcustomer_information_read

So ["credit_registry_data"] reads the CIRBE report alone, and ["labor_check", "credit_registry_data"] both. Left out, the session uses your application’s default features.

A feature goes as its code alone or as an object with its configurations. yearly_individual_tax reads the last three closed fiscal years by default, and up to five with {"code": "yearly_individual_tax", "configurations": {"last_n_years": 5}}.

Each administration the list reaches is one more identification for the person, one after the other: the Social Security first, then the Agencia Tributaria, then the Carpeta Ciudadana (which serves academic_data and properties_data). Ask for what you will use.

settings.sandbox is required: true runs against the sandbox, with no real administration behind it; false is production.

Why a session is refused:

  • 400 — the return URL is not one of your application’s.
  • 403 — a production session from an application that is not in production, or without the capability it needs (insufficient_capabilities@product:es_public_administration); a sandbox session needs none.
  • 409 — a session with that customer_id is already open.

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

Authentication

X-APP-SECRETstring
Application Secret

Request

This endpoint expects an object.
customer_idstringRequired1-64 characters
The external identifier of the customer in your system. Used for auditing and tracking.
settingsobjectRequired
Custom session settings containing requested features, redirection URLs, and webhook extra parameters.
date_limitstringOptionalformat: "datetime"
Custom expiration deadline for this session. After this timestamp, the widget cannot be opened.
fixed_parametersobjectOptional

Restricted credentials/parameters to enforce during user login in the widget.

Response

200 OK
Flow Session created successfully

session_idstringformat: "object-id"
The unique database identifier of the created flow session.
widget_urlstring
The secure redirection URL where the customer should be sent to open the widget.
session_tokenstring
Temporary security token scoped for the widget to interact with backend services during the session.

Errors

403
Forbidden Error
409
Conflict Error
422
Unprocessable Entity Error