Skip to main content

API: users and codes

General conventions in How the API works.

The users of the key's account and their codes. A user, profile or code from another account does not exist for the key: it returns 404.

  • Codes are part of the user: they come inside codes and have no GET of their own. Code writes (/users/:id/codes/…) return the full user, updated.
  • A user is referenced by its id or its identification: GET /api/v1/users/1016075813. A code, by its value (codeId, e.g. RFID-A1B2). Profiles (profileId) go by id or name. In the path, URL-encode the values (encodeURIComponent). See References.
  • Money in minor units of the account's currency (currency on each code).
EndpointPermission
POST /api/v1/usersusers:create (+ codes:create if it carries codes)
GET /api/v1/usersusers:read
GET /api/v1/users/:idusers:read
PATCH /api/v1/users/:idusers:update
POST /api/v1/users/:id/activate · /deactivateusers:update
DELETE /api/v1/users/:idusers:delete
POST /api/v1/users/:id/codescodes:create
PATCH /api/v1/users/:id/codes/:codeIdcodes:update
POST /api/v1/users/:id/codes/:codeId/activate · /deactivatecodes:update
DELETE /api/v1/users/:id/codes/:codeIdcodes:delete

The user​

{
"id": "01a1213b-17ec-70be-9897-a55b5ea19962",
"name": "Juan Pérez",
"identification": "1023456789",
"isActive": true,
"tags": [{ "key": "departamento", "value": "Marketing" }],
"codes": [
{
"codeId": "RFID-A1B2",
"codeType": "QR",
"isActive": true,
"profile": { "id": "00000000-0000-7000-8000-e20000000002", "name": "Subsidio planta" },
"balance": 500000,
"recharge": 0,
"currency": "COP",
"minorUnitDecimals": 2,
"lastAccreditation": null,
"lastReload": null,
"createdAt": "2026-10-09T15:14:43.309Z"
}
],
"createdAt": "2026-10-09T15:14:43.309Z",
"updatedAt": "2026-10-09T15:14:43.451Z"
}
FieldTypeDescription
idstringUser id or identification.
namestringName.
identificationstringIdentification (national id or other document). Unique in the account.
isActivebooleanAn inactive user cannot buy or receive deliveries.
tags{ key, value }[]Tags (max 4). Keys are the account's userTagKeys.
codescode[]The user's codes, newest first. [] if none.
createdAt / updatedAtISO 8601 UTC

The code (inside codes)​

FieldTypeDescription
codeIdstringCode value (what the device reads). Unique in the account.
codeTypeenumQR, NFC, CODE128, CODE39, PDF417, EAN13, UPCA, MRZ, GENERIC. Codes registered in the app may carry other types that the API cannot create.
isActivebooleanAn inactive code does not authorize purchases or deliveries.
profileobject | nullProfile of the code: { id, name }. null only on old codes without a profile.
balanceinteger ≥ 0Subsidy balance, in minor units. Always 0 in EAS accounts.
rechargeinteger ≥ 0Balance the user tops up at the machine, in minor units. Read only. Always 0 in EAS.
currencystring ISO 4217Currency of the account.
minorUnitDecimalsintegerDecimals of the currency (COP = 2). Value of balance and recharge = amount / 10^minorUnitDecimals.
lastAccreditationISO 8601 | nullLast accreditation (start of a purchase or delivery) with this code.
lastReloadISO 8601 | nullLast automatic subsidy reload from the profile.
createdAtISO 8601When the code was added. A code has no updatedAt of its own: its changes update the user's updatedAt.

Create a user​

POST /api/v1/users

Permission: users:create. If codes has at least one item, the key also needs codes:create (otherwise 403 and nothing is created).

FieldTypeRequiredLimitsEditable later
namestringyes1–120yes, with PATCH /users/:id
identificationstringyes3–30 after trimming spaces (stored trimmed); unique in the accountyes, with PATCH /users/:id
tags{ key, value }[]noMax 4; key 1–32, value 0–64; keys not repeated and present in the account's userTagKeysyes, with PATCH /users/:id (replaces the list)
codesnew code[]noMax 20; codeId not repeated within the arraythrough the code endpoints

Each new code (codes[]) carries the same as the body of add a code:

FieldTypeRequiredLimitsEditable later
codeIdstringyes1–100; unique in the account (across codes and tickets)yes (change the value)
codeTypeenumyesQR, NFC, CODE128, CODE39, PDF417, EAN13, UPCA, MRZ, GENERIC (case-insensitive: qr → QR)yes
profileIdstringyesA profile of the account: its id or its nameyes (change, never remove)
balanceintegeryes0 – 9007199254740991, minor units; 0 = no balance. In EAS accounts it must be 0.yes

Example​

curl -X POST https://back.inssacs.com/api/v1/users \
-H 'x-api-key: ics_a1b2c3d4_e5f6...' \
-H 'Content-Type: application/json' \
-d '{
"name": "Juan Pérez",
"identification": "1023456789",
"tags": [{ "key": "departamento", "value": "Marketing" }],
"codes": [
{ "codeId": "RFID-A1B2", "codeType": "QR", "profileId": "Plant Subsidy", "balance": 500000 }
]
}'

Response 201: the created user, with their codes (as in the example above).

Rules​

  • All or nothing: if a code fails, the newly created user is deleted with their codes and the error is returned. The identification and the values stay free to retry.
  • In EAS accounts each code gets the delivery entitlement set by its profile's rules.

Errors​

HTTPcodeWhen
400users.invalid_identificationIdentification empty, shorter than 3 or longer than 30 characters after trimming.
400users.unknown_tag_keyA tag key is not in the account's userTagKeys.
400users.duplicate_tag_keyRepeated tag key.
400users.invalid_tagA tag key that is empty or only spaces.
400users.invalid_codebalance greater than 0 in an EAS account.
403http.forbiddencodes was sent and the key lacks codes:create.
404profiles.not_foundA profileId is not a profile of the account (neither by id nor by name).
409users.identification_existsA user with that identification already exists in the account.
409users.code_existsA code value is already used by another code or a ticket of the account.
422validation.failedInvalid body; more than 4 tags; codeId repeated within codes (field: codes.<i>.codeId, rule: unique); unknown field.

How to query users​

GET /api/v1/users
GET /api/v1/users/:id

Permission: users:read. The list returns each user with their codes, same as the get by id.

Filters, search and sorting​

QueryTypeRequiredDefaultLimits / valuesWhat it does
pageintegerno1≥ 1Page.
pageSizeintegerno501–200Users per page.
sortByenumnocreatedAtcreatedAt, updatedAt, name, identificationSort field. Anything else → 422.
sortOrderenumnodescasc, descDirection.
searchstringno—Max 100Case-insensitive "contains" on the name, the identification or the value of any of their codes.
isActivebooleanno— (all)true, false (also 1, 0)User state.
profileIdstringno—id or nameUsers with at least one code with that profile. If it does not exist in the account → empty page.
tagKeystringno (yes if tagValue is sent)—1–32Users that have a tag with that key (exact).
tagValuestringno—Max 64Exact value of the tagKey tag. Without tagKey → 422.
fromISO 8601no—valid datecreatedAt ≥ from (inclusive).
toISO 8601no—valid datecreatedAt before to (exclusive).

Filters combine (all must match). Sort ties are broken by id, so paging is stable. Deleted users never appear.

Examples​

Find a person by document or by the value of their code:

curl 'https://back.inssacs.com/api/v1/users?search=1023456789' \
-H 'x-api-key: ics_a1b2c3d4_e5f6...'

Active users in the Marketing department, by name A to Z:

curl 'https://back.inssacs.com/api/v1/users?isActive=true&tagKey=departamento&tagValue=Marketing&sortBy=name&sortOrder=asc' \
-H 'x-api-key: ics_a1b2c3d4_e5f6...'

Users created in October 2026, 200 at a time:

curl 'https://back.inssacs.com/api/v1/users?from=2026-10-01T05:00:00Z&to=2026-11-01T05:00:00Z&pageSize=200&page=1' \
-H 'x-api-key: ics_a1b2c3d4_e5f6...'

To walk all users, request page=1, 2, 3… until data comes back empty or up to ceil(pagination.total / pageSize).

List response 200​

{
"data": [
{
"id": "01a1213b-17ec-70be-9897-a55b5ea19962",
"name": "Juan Pérez",
"identification": "1023456789",
"isActive": true,
"tags": [{ "key": "departamento", "value": "Marketing" }],
"codes": [
{
"codeId": "RFID-A1B2",
"codeType": "QR",
"isActive": true,
"profile": { "id": "00000000-0000-7000-8000-e20000000002", "name": "Subsidio planta" },
"balance": 500000,
"recharge": 0,
"currency": "COP",
"minorUnitDecimals": 2,
"lastAccreditation": null,
"lastReload": null,
"createdAt": "2026-10-09T15:14:43.309Z"
}
],
"createdAt": "2026-10-09T15:14:43.309Z",
"updatedAt": "2026-10-09T15:14:43.451Z"
}
],
"pagination": { "page": 1, "pageSize": 50, "total": 1 }
}

Get a user​

Path paramTypeDescription
idstringUser id or identification.

Response 200: the user. If you only know the identification or a code value, use GET /api/v1/users?search=….

Query errors​

HTTPcodeWhen
404users.not_found(:id) No user with that id or identification in the account (does not exist, was deleted or belongs to another account).
422validation.failedInvalid query: sortBy outside the enum, pageSize above 200, tagValue without tagKey, malformed date, unknown parameter.

How to edit a user​

Each change has its own endpoint:

I want to change…EndpointPermission
Name, identification or tagsPATCH /users/:idusers:update
Whether the user is activePOST /users/:id/activate · /deactivateusers:update
Add a codePOST /users/:id/codescodes:create
A code's value, type, profile or balancePATCH /users/:id/codes/:codeIdcodes:update
Whether a code is activePOST /users/:id/codes/:codeId/activate · /deactivatecodes:update
Remove a codeDELETE /users/:id/codes/:codeIdcodes:delete

Codes are not edited through PATCH /users/:id: sending codes there returns 422.

Edit name, identification and tags​

PATCH /api/v1/users/:id

Permission: users:update. Partial edit: only the fields you send change.

Path paramTypeDescription
idstringUser id or identification.
FieldTypeRequiredLimits
namestringno1–120
identificationstringno3–30; unique in the account
tags{ key, value }[]noSame as on create. Replaces the whole list; [] clears it.

Only those three fields. Anything else (codes, isActive, id, createdAt…) returns 422 validation.failed. To change a single tag, send the whole list with the change.

{
"name": "Juan Pérez Gómez",
"tags": [
{ "key": "departamento", "value": "Ventas" },
{ "key": "cargo", "value": "Analista" }
]
}

Response 200: the updated user, with their codes.

HTTPcodeWhen
400users.invalid_identification, users.unknown_tag_key, users.duplicate_tag_key, users.invalid_tagAs on create.
404users.not_foundThe user does not exist, was deleted or belongs to another account.
409users.identification_existsAnother user of the account already has that identification.
422validation.failedInvalid body or non-editable field.

Activate and deactivate a user​

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

Permission: users:update. Path param id (id or identification). No body.

Response 200: the user with the new isActive. Idempotent: activating an active user changes nothing. Deactivating does not touch the codes or their balances; the user cannot buy or receive deliveries until reactivated.

Errors: 404 users.not_found.

Delete a user​

DELETE /api/v1/users/:id

Permission: users:delete. Path param id (id or identification). Response 204 with no body.

  • Permanent deletion: there is no restore. Nothing blocks it, not balances nor codes.
  • Cascade: the user's codes, tags and, in EAS, delivery entitlements are deleted with the user. The balances (balance, recharge) of their codes are lost.
  • History is kept: deliveries, returns and recharges.
  • The identification and their code values become free to be reused in the account.

Errors: 404 users.not_found (also if already deleted).

A user's codes​

Add a code​

POST /api/v1/users/:id/codes

Permission: codes:create.

Path paramTypeDescription
idstringUser id or identification.
FieldTypeRequiredLimits
codeIdstringyes1–100; unique in the account (across codes and tickets)
codeTypeenumyesQR, NFC, CODE128, CODE39, PDF417, EAN13, UPCA, MRZ, GENERIC
profileIdstringyesA profile of the account: its id or its name
balanceintegeryes0 – 9007199254740991, minor units; only 0 in EAS
{ "codeId": "NFC-0099", "codeType": "NFC", "profileId": "00000000-0000-7000-8000-e20000000002", "balance": 0 }

Response 201: the user with the new code.

HTTPcodeWhen
400users.invalid_codebalance greater than 0 in an EAS account.
404users.not_foundThe user does not exist or belongs to another account.
404profiles.not_foundNo profile with that id or name in the account.
409users.code_existsThe value already exists in the account (on this or another user, or as a ticket).
422users.too_many_active_codesThe user already has 20 active codes.
422validation.failedInvalid body.

Edit a code​

PATCH /api/v1/users/:id/codes/:codeId

Permission: codes:update. Partial edit.

Path paramTypeDescription
idstringUser id or identification.
codeIdstringThe code's current value, URL-encoded.
FieldTypeRequiredLimitsEffect
codeIdstringno1–100; unique in the accountChanges the value. Keeps balances, profile and delivery history.
codeTypeenumnoSame as on createChanges the type.
profileIdstringnoA profile of the account: its id or its nameChanges the profile (it cannot be removed). In VENDING keeps balance and recharge; in EAS adjusts the delivery entitlement to the new profile.
balanceintegerno0 – 9007199254740991; only 0 in EASSets the subsidy balance (does not add).

Only those four fields. recharge cannot be edited (it is money the user loads at the machine) and isActive goes through activate or deactivate; sending them, or any other field, returns 422 validation.failed.

curl -X PATCH 'https://back.inssacs.com/api/v1/users/01a1213b-17ec-70be-9897-a55b5ea19962/codes/RFID-A1B2' \
-H 'x-api-key: ics_a1b2c3d4_e5f6...' \
-H 'Content-Type: application/json' \
-d '{ "codeId": "RFID-C3D4", "balance": 1000000 }'

Response 200: the user with the updated code (with the new value, if it changed).

HTTPcodeWhen
400users.invalid_codebalance greater than 0 in an EAS account.
404users.not_foundThe user does not exist or belongs to another account.
404users.code_not_foundThe user has no code with that value.
404profiles.not_foundNo profile with that id or name in the account.
400users.code_profile_requiredprofileId: null: the profile is changed, never removed.
409users.code_existsThe new value already exists in the account.
422validation.failedInvalid body or non-editable field.

Activate and deactivate a code​

POST /api/v1/users/:id/codes/:codeId/activate
POST /api/v1/users/:id/codes/:codeId/deactivate

Permission: codes:update. Path params id (id or identification) and codeId (value). No body.

Response 200: the user. Idempotent. Deactivating does not touch balances.

HTTPcodeWhen
404users.not_foundThe user does not exist or belongs to another account.
404users.code_not_foundThe user does not have that code.
422users.too_many_active_codesActivating would leave the user with more than 20 active codes.

Remove a code​

DELETE /api/v1/users/:id/codes/:codeId

Permission: codes:delete. Path params id (id or identification) and codeId (value). Response 204 with no body.

  • Permanent deletion of the code: its balance, its recharge and, in EAS, its delivery entitlement are lost. The value becomes free in the account.
  • The last code can be removed: a user can be left with no codes.
HTTPcodeWhen
404users.not_foundThe user does not exist or belongs to another account.
404users.code_not_foundThe user does not have that code.

Business rules​

RuleDetail
Unique identificationPer account, among non-deleted users.
Unique codeThe value is unique in the account, across all codes and tickets. A code works in every operation of the account; which devices it works on is decided by its profile's device list.
ProfileEvery new code carries a profile of the same account. It can be changed, never removed.
Balances (VENDING)The code uses balance (subsidy) + recharge. A purchase takes from balance first and the rest from recharge.
Balances (EAS)No balances (0): deliveries are governed by the profile's rules.
Active codesMax 20 active per user.
TagsMax 4; keys from the account's userTagKeys; key max 32 characters and value max 64.
Code typeStored in UPPERCASE.
Not editableid, createdAt and the user's account.

Errors common to every endpoint: 401 http.unauthorized, 403 http.forbidden (missing permission), 429 http.too_many_requests.