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
codesand have noGETof 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 (
currencyon each code).
| Endpoint | Permission |
|---|---|
POST /api/v1/users | users:create (+ codes:create if it carries codes) |
GET /api/v1/users | users:read |
GET /api/v1/users/:id | users:read |
PATCH /api/v1/users/:id | users:update |
POST /api/v1/users/:id/activate · /deactivate | users:update |
DELETE /api/v1/users/:id | users:delete |
POST /api/v1/users/:id/codes | codes:create |
PATCH /api/v1/users/:id/codes/:codeId | codes:update |
POST /api/v1/users/:id/codes/:codeId/activate · /deactivate | codes:update |
DELETE /api/v1/users/:id/codes/:codeId | codes: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"
}
| Field | Type | Description |
|---|---|---|
id | string | User id or identification. |
name | string | Name. |
identification | string | Identification (national id or other document). Unique in the account. |
isActive | boolean | An inactive user cannot buy or receive deliveries. |
tags | { key, value }[] | Tags (max 4). Keys are the account's userTagKeys. |
codes | code[] | The user's codes, newest first. [] if none. |
createdAt / updatedAt | ISO 8601 UTC |
The code (inside codes)
| Field | Type | Description |
|---|---|---|
codeId | string | Code value (what the device reads). Unique in the account. |
codeType | enum | QR, NFC, CODE128, CODE39, PDF417, EAN13, UPCA, MRZ, GENERIC. Codes registered in the app may carry other types that the API cannot create. |
isActive | boolean | An inactive code does not authorize purchases or deliveries. |
profile | object | null | Profile of the code: { id, name }. null only on old codes without a profile. |
balance | integer ≥ 0 | Subsidy balance, in minor units. Always 0 in EAS accounts. |
recharge | integer ≥ 0 | Balance the user tops up at the machine, in minor units. Read only. Always 0 in EAS. |
currency | string ISO 4217 | Currency of the account. |
minorUnitDecimals | integer | Decimals of the currency (COP = 2). Value of balance and recharge = amount / 10^minorUnitDecimals. |
lastAccreditation | ISO 8601 | null | Last accreditation (start of a purchase or delivery) with this code. |
lastReload | ISO 8601 | null | Last automatic subsidy reload from the profile. |
createdAt | ISO 8601 | When 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).
| Field | Type | Required | Limits | Editable later |
|---|---|---|---|---|
name | string | yes | 1–120 | yes, with PATCH /users/:id |
identification | string | yes | 3–30 after trimming spaces (stored trimmed); unique in the account | yes, with PATCH /users/:id |
tags | { key, value }[] | no | Max 4; key 1–32, value 0–64; keys not repeated and present in the account's userTagKeys | yes, with PATCH /users/:id (replaces the list) |
codes | new code[] | no | Max 20; codeId not repeated within the array | through the code endpoints |
Each new code (codes[]) carries the same as the body of add a code:
| Field | Type | Required | Limits | Editable later |
|---|---|---|---|---|
codeId | string | yes | 1–100; unique in the account (across codes and tickets) | yes (change the value) |
codeType | enum | yes | QR, NFC, CODE128, CODE39, PDF417, EAN13, UPCA, MRZ, GENERIC (case-insensitive: qr → QR) | yes |
profileId | string | yes | A profile of the account: its id or its name | yes (change, never remove) |
balance | integer | yes | 0 – 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
| HTTP | code | When |
|---|---|---|
| 400 | users.invalid_identification | Identification empty, shorter than 3 or longer than 30 characters after trimming. |
| 400 | users.unknown_tag_key | A tag key is not in the account's userTagKeys. |
| 400 | users.duplicate_tag_key | Repeated tag key. |
| 400 | users.invalid_tag | A tag key that is empty or only spaces. |
| 400 | users.invalid_code | balance greater than 0 in an EAS account. |
| 403 | http.forbidden | codes was sent and the key lacks codes:create. |
| 404 | profiles.not_found | A profileId is not a profile of the account (neither by id nor by name). |
| 409 | users.identification_exists | A user with that identification already exists in the account. |
| 409 | users.code_exists | A code value is already used by another code or a ticket of the account. |
| 422 | validation.failed | Invalid 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
| Query | Type | Required | Default | Limits / values | What it does |
|---|---|---|---|---|---|
page | integer | no | 1 | ≥ 1 | Page. |
pageSize | integer | no | 50 | 1–200 | Users per page. |
sortBy | enum | no | createdAt | createdAt, updatedAt, name, identification | Sort field. Anything else → 422. |
sortOrder | enum | no | desc | asc, desc | Direction. |
search | string | no | — | Max 100 | Case-insensitive "contains" on the name, the identification or the value of any of their codes. |
isActive | boolean | no | — (all) | true, false (also 1, 0) | User state. |
profileId | string | no | — | id or name | Users with at least one code with that profile. If it does not exist in the account → empty page. |
tagKey | string | no (yes if tagValue is sent) | — | 1–32 | Users that have a tag with that key (exact). |
tagValue | string | no | — | Max 64 | Exact value of the tagKey tag. Without tagKey → 422. |
from | ISO 8601 | no | — | valid date | createdAt ≥ from (inclusive). |
to | ISO 8601 | no | — | valid date | createdAt 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 param | Type | Description |
|---|---|---|
id | string | User 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
| HTTP | code | When |
|---|---|---|
| 404 | users.not_found | (:id) No user with that id or identification in the account (does not exist, was deleted or belongs to another account). |
| 422 | validation.failed | Invalid 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… | Endpoint | Permission |
|---|---|---|
| Name, identification or tags | PATCH /users/:id | users:update |
| Whether the user is active | POST /users/:id/activate · /deactivate | users:update |
| Add a code | POST /users/:id/codes | codes:create |
| A code's value, type, profile or balance | PATCH /users/:id/codes/:codeId | codes:update |
| Whether a code is active | POST /users/:id/codes/:codeId/activate · /deactivate | codes:update |
| Remove a code | DELETE /users/:id/codes/:codeId | codes: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 param | Type | Description |
|---|---|---|
id | string | User id or identification. |
| Field | Type | Required | Limits |
|---|---|---|---|
name | string | no | 1–120 |
identification | string | no | 3–30; unique in the account |
tags | { key, value }[] | no | Same 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.
| HTTP | code | When |
|---|---|---|
| 400 | users.invalid_identification, users.unknown_tag_key, users.duplicate_tag_key, users.invalid_tag | As on create. |
| 404 | users.not_found | The user does not exist, was deleted or belongs to another account. |
| 409 | users.identification_exists | Another user of the account already has that identification. |
| 422 | validation.failed | Invalid 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 param | Type | Description |
|---|---|---|
id | string | User id or identification. |
| Field | Type | Required | Limits |
|---|---|---|---|
codeId | string | yes | 1–100; unique in the account (across codes and tickets) |
codeType | enum | yes | QR, NFC, CODE128, CODE39, PDF417, EAN13, UPCA, MRZ, GENERIC |
profileId | string | yes | A profile of the account: its id or its name |
balance | integer | yes | 0 – 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.
| HTTP | code | When |
|---|---|---|
| 400 | users.invalid_code | balance greater than 0 in an EAS account. |
| 404 | users.not_found | The user does not exist or belongs to another account. |
| 404 | profiles.not_found | No profile with that id or name in the account. |
| 409 | users.code_exists | The value already exists in the account (on this or another user, or as a ticket). |
| 422 | users.too_many_active_codes | The user already has 20 active codes. |
| 422 | validation.failed | Invalid body. |
Edit a code
PATCH /api/v1/users/:id/codes/:codeId
Permission: codes:update. Partial edit.
| Path param | Type | Description |
|---|---|---|
id | string | User id or identification. |
codeId | string | The code's current value, URL-encoded. |
| Field | Type | Required | Limits | Effect |
|---|---|---|---|---|
codeId | string | no | 1–100; unique in the account | Changes the value. Keeps balances, profile and delivery history. |
codeType | enum | no | Same as on create | Changes the type. |
profileId | string | no | A profile of the account: its id or its name | Changes the profile (it cannot be removed). In VENDING keeps balance and recharge; in EAS adjusts the delivery entitlement to the new profile. |
balance | integer | no | 0 – 9007199254740991; only 0 in EAS | Sets 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).
| HTTP | code | When |
|---|---|---|
| 400 | users.invalid_code | balance greater than 0 in an EAS account. |
| 404 | users.not_found | The user does not exist or belongs to another account. |
| 404 | users.code_not_found | The user has no code with that value. |
| 404 | profiles.not_found | No profile with that id or name in the account. |
| 400 | users.code_profile_required | profileId: null: the profile is changed, never removed. |
| 409 | users.code_exists | The new value already exists in the account. |
| 422 | validation.failed | Invalid 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.
| HTTP | code | When |
|---|---|---|
| 404 | users.not_found | The user does not exist or belongs to another account. |
| 404 | users.code_not_found | The user does not have that code. |
| 422 | users.too_many_active_codes | Activating 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.
| HTTP | code | When |
|---|---|---|
| 404 | users.not_found | The user does not exist or belongs to another account. |
| 404 | users.code_not_found | The user does not have that code. |
Business rules
| Rule | Detail |
|---|---|
| Unique identification | Per account, among non-deleted users. |
| Unique code | The 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. |
| Profile | Every 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 codes | Max 20 active per user. |
| Tags | Max 4; keys from the account's userTagKeys; key max 32 characters and value max 64. |
| Code type | Stored in UPPERCASE. |
| Not editable | id, createdAt and the user's account. |
Errors common to every endpoint: 401 http.unauthorized, 403 http.forbidden (missing
permission), 429 http.too_many_requests.