Setu Account Aggregator FIU API client.
Flow
- Consent —
create_consent/2,get_consent/3,revoke_consent/2,create_multi_consent/2 - Data fetch —
create_data_session/2,get_data_session/2,fetch_fi_data/2 - Utilities —
get_last_fetch_status/2,list_data_sessions/2
Example
{:ok, consent} = SetuClient.Data.AA.create_consent(cfg, %{
vua: "9999999999",
fetch_type: "ONETIME",
consent_types: ["TRANSACTIONS"],
fi_types: ["DEPOSIT"],
consent_duration: %{unit: "MONTH", value: 1},
data_range: %{from: from_dt, to: to_dt}
})
# Redirect customer to consent["url"]
{:ok, session} = SetuClient.Data.AA.create_data_session(cfg, %{consent_id: consent["id"]})
{:ok, fi_data} = SetuClient.Data.AA.fetch_fi_data(cfg, session["id"])Setu docs: https://docs.setu.co/data/account-aggregator
Summary
Functions
Creates an AA consent request.
Creates a data fetch session against an ACTIVE consent.
Merges two consent requests into a single approval flow.
Fetches FI data for a COMPLETED or PARTIAL session.
Retrieves the status of a consent request.
Retrieves the current status of a data session.
Returns the timestamp and FIP list of the most recent data fetch.
Lists all non-expired data sessions for a consent.
Revokes an active consent.
Returns a context param for account selection mode ("single" | "multi" | "multi-opt-out").
Returns a context param filtering by account type ("SAVINGS" | "CURRENT").
Returns a context param excluding specific FIP IDs (comma-separated).
Returns a context param restricting consent to specific FIP IDs (comma-separated).
Returns a context param with a custom consent purpose description.
Returns a context param filtering by transaction type ("debit" | "credit").
Functions
@spec create_consent(SetuClient.Config.t(), map()) :: {:ok, map()} | {:error, SetuClient.Error.t()}
Creates an AA consent request.
Redirect the customer to the url in the response.
Required
:vua— mobile"9999999999"or handle"9999999999@onemoney":fetch_type—"ONETIME"or"PERIODIC":consent_types— list:"PROFILE","SUMMARY","TRANSACTIONS":fi_types— list:"DEPOSIT","MUTUAL_FUNDS", etc.- One of
:consent_duration%{unit, value}or:consent_date_range%{from, to} :data_range— required when"TRANSACTIONS"is in:consent_types
POST /consents
@spec create_data_session(SetuClient.Config.t(), map()) :: {:ok, map()} | {:error, SetuClient.Error.t()}
Creates a data fetch session against an ACTIVE consent.
Poll get_data_session/2 or wait for SESSION_STATUS_UPDATE webhook.
Required
:consent_id
POST /v2/sessions
@spec create_multi_consent(SetuClient.Config.t(), map()) :: {:ok, map()} | {:error, SetuClient.Error.t()}
Merges two consent requests into a single approval flow.
POST /v2/consents/collection
@spec fetch_fi_data(SetuClient.Config.t(), String.t()) :: {:ok, map()} | {:error, SetuClient.Error.t()}
Fetches FI data for a COMPLETED or PARTIAL session.
GET /v2/sessions/:id/fetch
@spec get_consent(SetuClient.Config.t(), String.t(), boolean()) :: {:ok, map()} | {:error, SetuClient.Error.t()}
Retrieves the status of a consent request.
Pass expanded: true for the full consent configuration.
GET /consents/:id[?expanded=true]
@spec get_data_session(SetuClient.Config.t(), String.t()) :: {:ok, map()} | {:error, SetuClient.Error.t()}
Retrieves the current status of a data session.
GET /v2/sessions/:id
@spec get_last_fetch_status(SetuClient.Config.t(), String.t()) :: {:ok, map()} | {:error, SetuClient.Error.t()}
Returns the timestamp and FIP list of the most recent data fetch.
GET /v2/consents/:id/fetch/status
@spec list_data_sessions(SetuClient.Config.t(), String.t()) :: {:ok, map()} | {:error, SetuClient.Error.t()}
Lists all non-expired data sessions for a consent.
GET /v2/consents/:id/data-sessions
@spec revoke_consent(SetuClient.Config.t(), String.t()) :: {:ok, map()} | {:error, SetuClient.Error.t()}
Revokes an active consent.
POST /v2/consents/:id/revoke
Returns a context param for account selection mode ("single" | "multi" | "multi-opt-out").
Returns a context param filtering by account type ("SAVINGS" | "CURRENT").
Returns a context param excluding specific FIP IDs (comma-separated).
Returns a context param restricting consent to specific FIP IDs (comma-separated).
Returns a context param with a custom consent purpose description.
Returns a context param filtering by transaction type ("debit" | "credit").