Guide

Assets and asset groups

Declare your assets and the data they share, link them, and remove an asset declared by mistake.

An asset is one loan or receivable of your program. An asset group holds data many assets share, such as an employer, so you send it once.

Assets

An asset is found by your asset_id. It has a currency and details: whatever your records send, checked and cleaned by your program's asset schema. Sending the asset again replaces its details whole; the later record wins.

{"records": [
  {"asset_id": "L-123", "currency": "EUR",
   "details": {"product": "salary_advance", "country": "ES"},
   "asset_groups": [{"asset_group_kind": "employer", "asset_group_id": "0001"}]}
]}

Send it to POST …/submissions/assets. Which fields details must hold is set by your program: see Asset programs and their rules.

Asset groups

A group is named by its asset_group_kind and its asset_group_id: employer G1 and school G1 are two groups. Your program must have a schema for the kind. Fence keeps only a group's latest details.

{"records": [
  {"asset_group_kind": "employer", "asset_group_id": "0001",
   "details": {"name": "Acme Foods S.L.", "tax_id": "B12345678"}}
]}

Send it to POST …/submissions/asset-groups. Sending a group links no asset to it: an asset names its groups.

Link an asset to its groups

An asset record's asset_groups is the full list of the groups the asset belongs to:

  • Leave the list out to keep the groups the asset had.
  • Send [] to take the asset out of every group.
  • The order of the list means nothing.

Every group an asset names must already be held, so send groups before assets. An asset that names a group Fence does not hold is refused asset_group_not_declared.

Remove an asset

Send a record with only the asset's asset_id and a removal_reason:

{"records": [{"asset_id": "L-123", "removal_reason": "Declared by mistake"}]}

The asset then leaves every list and total. Its payments wait with no asset: to place one, send it again naming the right asset. A removed asset_id can never be declared again (asset_removed).

A removal and a declaration of the same asset in one batch refuse the whole batch (duplicate_item): send them in separate batches.

Read them back

To read

Route

Your assets, or one by your id

GET …/assets, GET …/assets?asset_id=L-123

One asset, with its plan, state, expected payments and groups

GET …/assets/{id}?include=state&include=payment_plan

The groups of one kind

GET …/asset-groups?asset_group_kind=employer

A group's assets

GET …/asset-groups/{id}/assets