Skip to main content

API: profiles

General conventions in How the API works.

Consumption profiles of the key's account. The shape of a profile depends on the account's business line:

  • VENDING account: the profile carries vending (subsidy and reload) and lines is null.
  • EAS account: the profile carries lines (one line per product) and vending is null.

Sending vending on an EAS account, or lines on a VENDING one, returns 400 profiles.policy_mismatch: it is not ignored.

EndpointPermission
POST /api/v1/profilesprofiles:create
GET /api/v1/profilesprofiles:read
GET /api/v1/profiles/:idprofiles:read
PATCH /api/v1/profiles/:idprofiles:update
POST /api/v1/profiles/:id/activate · /deactivateprofiles:update
DELETE /api/v1/profiles/:idprofiles:delete

:id is the profile's id or name. In bodies, allowedDeviceIds accepts ids or serials and lines[].productId ids or SKUs (see References). Anything that does not exist in the account returns 404.

The profile​

EAS account profile:

{
"id": "01a1213c-2d4e-72a8-8c1c-1ba74ea70c6a",
"name": "PPE Operators",
"isActive": true,
"currency": "COP",
"minorUnitDecimals": 2,
"timezone": "America/Bogota",
"period": { "type": "PRESET", "value": "MONTHLY", "dates": null },
"nextReloadAt": "2026-11-01T05:00:00.000Z",
"consumptionSchedule": { "weekdays": [1, 2, 3, 4, 5], "includeDates": [], "excludeDates": ["2026-12-25"] },
"allowedDevices": [{ "id": "00000000-0000-7000-8000-e30000000001", "serial": "LK20W000001", "name": "Locker Planta 1" }],
"vending": null,
"lines": [
{
"product": { "id": "00000000-0000-7000-8000-e10000000002", "sku": "EPP-CAS", "name": "Casco de seguridad" },
"quantity": null,
"minutesBetweenDeliveries": 60,
"isReturnable": true,
"restrictDelivery": true,
"isReusable": true
}
],
"createdAt": "2026-10-09T15:15:54.319Z",
"updatedAt": "2026-10-09T15:15:54.319Z"
}

VENDING account profile:

{
"id": "01a1213c-2d4e-72a8-8c1c-2cb85fb81d7b",
"name": "Plant subsidy",
"isActive": true,
"currency": "COP",
"minorUnitDecimals": 2,
"timezone": "America/Bogota",
"period": { "type": "PRESET", "value": "MONTHLY", "dates": null },
"nextReloadAt": "2026-11-01T05:00:00.000Z",
"consumptionSchedule": null,
"allowedDevices": [],
"vending": {
"defaultReloadValue": 500000,
"maxBalance": 1000000,
"isCumulative": true,
"balanceResetDates": ["2026-12-31"]
},
"lines": null,
"createdAt": "2026-10-09T15:15:54.319Z",
"updatedAt": "2026-10-09T15:15:54.319Z"
}
FieldTypeDescription
iduuid
namestringUnique in the account, ignoring case and repeated spaces.
isActivebooleanfalse = deactivated (reversible).
currencystring ISO 4217The account's currency; applies to the vending amounts. Never changes.
minorUnitDecimalsintegerDecimals of currency (COP = 2): real amount = amount / 10^minorUnitDecimals.
timezonestring IANADefines the reload midnight and the consumption day. Cannot be edited.
period.typeenumPRESET or CUSTOM.
period.valueenum | nullDAILY, WEEKLY, BIWEEKLY, MONTHLY, QUARTERLY, SEMIANNUAL, ANNUAL. Only with PRESET; null with CUSTOM.
period.datesstring[] | nullReload dates YYYY-MM-DD in the profile's time zone. Only with CUSTOM; null with PRESET.
nextReloadAtISO 8601 UTC | nullNext reload, computed on read. null if a CUSTOM has no future dates left.
consumptionScheduleobject | nullDays when consumption is allowed. null = no restriction. See rules.
allowedDevicesobject[]Devices where it works: { id, serial, name }. [] = all the account's devices.
vendingobject | nullVENDING accounts only.
vending.defaultReloadValueinteger | nullSubsidy loaded on each reload, in minor units. null = no automatic reload.
vending.maxBalanceinteger | nullSubsidy cap, in minor units. null = no cap.
vending.isCumulativebooleantrue = the reload adds to the previous balance; false = it replaces it.
vending.balanceResetDatesstring[]YYYY-MM-DD dates when the accumulated subsidy goes back to 0. Always [] if isCumulative is false.
linesobject[] | nullEAS accounts only. One per product.
lines[].productobjectProduct of the account: { id, sku, name } (sku is null if it has none).
lines[].quantityinteger | nullDeliveries per period (≥ 1). null = unlimited.
lines[].minutesBetweenDeliveriesinteger | nullMinimum minutes between deliveries (≥ 1). null = no frequency. Also applies with unlimited quantity.
lines[].isReturnablebooleanReturnable: the delivery stays pending return (frozen at delivery time).
lines[].restrictDeliverybooleanWith a pending return of this product, blocks the next delivery. Always false if isReturnable is false.
lines[].isReusablebooleanWhat is returned can be delivered again. Always false if isReturnable is false.
createdAt / updatedAtISO 8601 UTC

Rules​

  • Period: marks when the EAS quota resets and when the VENDING reload runs, at midnight in timezone.
  • VENDING reload: on each reload the subsidy becomes defaultReloadValue (or balance + defaultReloadValue with isCumulative: true), capped by maxBalance. defaultReloadValue cannot exceed maxBalance when both have a value. With isCumulative: true, on each balanceResetDates date the subsidy goes back to 0; with isCumulative: false those dates are discarded.
  • Consumption schedule (consumptionSchedule): null = any day. With an object, a day is valid if its weekday is in weekdays (0 = Sunday … 6 = Saturday) or it is in includeDates, and it is not in excludeDates, all in the profile's time zone. An empty object ({}) blocks every day.
  • Devices (allowedDeviceIds): [] = works on every device of the account. With at least one, only on those: a new device is not added automatically.
  • EAS lines: at least one, productId not repeated, products of the account. restrictDelivery and isReusable without isReturnable are stored as false (not an error).
  • Not editable: timezone and currency.
  • Deleting requires that no user code has the profile assigned.

Create a profile​

POST /api/v1/profiles

Permission: profiles:create.

FieldTypeRequiredLimitsEditable later
namestringyes2–100; unique in the accountyes
timezonestring IANAyesA valid IANA zone (America/Bogota); no offsets or abbreviationsno
periodobjectyesyes
period.typeenumyesPRESET, CUSTOMyes
period.valueenumwith PRESETDAILY, WEEKLY, BIWEEKLY, MONTHLY, QUARTERLY, SEMIANNUAL, ANNUALyes
period.datesstring[]with CUSTOM1–366 dates YYYY-MM-DDyes
consumptionScheduleobject | nullno (default null)yes
consumptionSchedule.weekdaysinteger[]noMax 7, each 0–6yes
consumptionSchedule.includeDatesstring[]noMax 366, YYYY-MM-DDyes
consumptionSchedule.excludeDatesstring[]noMax 366, YYYY-MM-DDyes
allowedDeviceIdsstring[]no (default [])Max 5000, not repeated, devices of the account by id or serialyes (replaces the list)
vendingobjectyes on VENDING; forbidden on EASyes (replaces the object)
vending.defaultReloadValueinteger | nullyes (the key, always)0 – 9007199254740991, minor unitsyes
vending.maxBalanceinteger | nullyes (the key, always)0 – 9007199254740991, minor unitsyes
vending.isCumulativebooleanno (default false)yes
vending.balanceResetDatesstring[]no (default [])Max 366, YYYY-MM-DDyes
linesobject[]yes on EAS; forbidden on VENDING1–200, productId not repeatedyes (replaces the list)
lines[].productIdstringyesA product of the account: its id or its SKUyes
lines[].quantityinteger | nullyes (the key, always)1 – 2147483647; null = unlimitedyes
lines[].minutesBetweenDeliveriesinteger | nullno (default null)1 – 2147483647yes
lines[].isReturnablebooleanno (default false)yes
lines[].restrictDeliverybooleanno (default false)Only with isReturnableyes
lines[].isReusablebooleanno (default false)Only with isReturnableyes

EAS account example:

{
"name": "PPE Operators",
"timezone": "America/Bogota",
"period": { "type": "PRESET", "value": "MONTHLY" },
"consumptionSchedule": { "weekdays": [1, 2, 3, 4, 5] },
"allowedDeviceIds": [],
"lines": [
{ "productId": "00000000-0000-7000-8000-e10000000002", "quantity": 2, "minutesBetweenDeliveries": 60 },
{ "productId": "00000000-0000-7000-8000-e10000000001", "quantity": null, "isReturnable": true, "restrictDelivery": true }
]
}

VENDING account example:

{
"name": "Plant subsidy",
"timezone": "America/Bogota",
"period": { "type": "PRESET", "value": "MONTHLY" },
"vending": {
"defaultReloadValue": 500000,
"maxBalance": 1000000,
"isCumulative": true,
"balanceResetDates": ["2026-12-31"]
}
}

Response 201: the created profile.

Errors​

HTTPcodeWhen
400profiles.policy_mismatchvending on an EAS account or lines on a VENDING one.
400profiles.invalid_eas_policyEAS account without lines.
400profiles.invalid_vending_policyVENDING account without vending, defaultReloadValue greater than maxBalance, or a balanceResetDates date that does not exist (e.g. February 30).
400profiles.invalid_periodInvalid period (e.g. a date that does not exist).
400profiles.invalid_consumption_scheduleA schedule date that does not exist.
400profiles.device_not_foundAn allowedDeviceIds entry is not a device of the account (neither by id nor by serial).
404profiles.product_not_foundA lines[].productId is not a product of the account (neither by id nor by SKU).
409profiles.name_existsA profile with that name already exists in the account.
422validation.failedInvalid body, unknown field, productId repeated in lines, repeated allowedDeviceIds.

List profiles​

GET /api/v1/profiles

Permission: profiles:read.

QueryTypeRequiredDefaultLimits / values
pageintegerno1≥ 1
pageSizeintegerno501–200
sortByenumnocreatedAtcreatedAt, updatedAt, name
sortOrderenumnodescasc, desc
isActivebooleanno— (all)true/false (also 1/0)
searchstringno—Max 100. Case-insensitive "contains" on name.
curl 'https://back.inssacs.com/api/v1/profiles?isActive=true&sortBy=name&sortOrder=asc' \
-H 'x-api-key: ics_a1b2c3d4_e5f6...'

Response 200:

{
"data": [
{
"id": "01a1213c-2d4e-72a8-8c1c-2cb85fb81d7b",
"name": "Plant subsidy",
"isActive": true,
"currency": "COP",
"minorUnitDecimals": 2,
"timezone": "America/Bogota",
"period": { "type": "PRESET", "value": "MONTHLY", "dates": null },
"nextReloadAt": "2026-11-01T05:00:00.000Z",
"consumptionSchedule": null,
"allowedDevices": [],
"vending": {
"defaultReloadValue": 500000,
"maxBalance": 1000000,
"isCumulative": true,
"balanceResetDates": ["2026-12-31"]
},
"lines": null,
"createdAt": "2026-10-09T15:15:54.319Z",
"updatedAt": "2026-10-09T15:15:54.319Z"
}
],
"pagination": { "page": 1, "pageSize": 50, "total": 1 }
}

Get a profile​

GET /api/v1/profiles/:id

Permission: profiles:read.

Path paramTypeDescription
idstringProfile id or name.

Response 200: the profile. Error: 404 profiles.not_found (does not exist, was deleted or belongs to another account).

Edit a profile​

PATCH /api/v1/profiles/:id

Permission: profiles:update. Path param id (id or name). Partial edit.

Accepts the create fields except timezone: name, period, consumptionSchedule, allowedDeviceIds, vending (VENDING only) and lines (EAS only). Sending timezone, currency or any other field returns 422 validation.failed.

  • Only what you send changes.
  • consumptionSchedule: null removes the day restriction.
  • allowedDeviceIds, lines and vending replace the whole value. In vending, what you do not send goes back to its default (isCumulative: false, balanceResetDates: []) and both amount keys are required.
  • vending and lines do not accept null.
{
"name": "PPE Operators night shift",
"consumptionSchedule": null,
"lines": [
{ "productId": "00000000-0000-7000-8000-e10000000002", "quantity": 3, "minutesBetweenDeliveries": 120 }
]
}

Response 200: the updated profile.

Errors: those of create (except invalid_eas_policy and invalid_vending_policy for a missing policy) plus 404 profiles.not_found (does not exist, was deleted or belongs to another account).

Activate and deactivate a profile​

POST /api/v1/profiles/:id/activate
POST /api/v1/profiles/:id/deactivate

Permission: profiles:update. Path param id (id or name). No body. Idempotent and reversible: deactivating deletes nothing.

Response 200: the profile with the new isActive. Error: 404 profiles.not_found.

Delete a profile​

DELETE /api/v1/profiles/:id

Permission: profiles:delete. Path param id (id or name). Response 204 with no body.

Permanent: afterwards the profile returns 404. It cannot be deleted while any user code has it assigned: first change those codes' profile with PATCH /users/:id/codes/:codeId. To find them: GET /api/v1/users?profileId=….

HTTPcodeWhen
404profiles.not_foundDoes not exist, already deleted or belongs to another account.
409profiles.in_useUser codes have the profile assigned.

Errors common to every endpoint: 404 (no profile with that id or name in the account), 401 http.unauthorized, 403 http.forbidden (missing permission), 429 http.too_many_requests.