Upload and validate a card import CSV
Upload a CSV file for a given supplier, validate every row, classify each row as create, update, invalid, duplicate, or unauthorized, and persist row-level results in fm_card_imports. A batch header record is created in gb_imports (interface=card_services, service=importCards).
Business rules enforced during validation:
-
supplier_idmust be supplied and must exist as a card-services supplier. -
Each row must contain either
contract_idorreg_no. -
If
reg_noresolves to more than one active contract the row is classified as invalid. -
Create vs update is determined by the combination of
supplier_id+card_number. If a card with that supplier/card-number already exists the row is classified as update; otherwise create. -
Duplicate rows within the same file (same
supplier_id+card_number) are classified as duplicate. -
status_flagmust beactiveorinactive;deletedis rejected. -
Missing Cards:Create permission does not invalidate update rows; missing Cards:Update permission does not invalidate create rows. Rows the caller lacks permission to process are classified as unauthorized and reported as skipped during processing.
This method only requires an authenticated identity. Authorisation is enforced per row using the caller's Cards:Create and Cards:Update permissions: create rows require Cards:Create and update rows require Cards:Update. Rows the caller is not authorised to process are classified as unauthorized rather than blocking the request.
For accessing the API a valid token must be passed in all the queries in the 'Authorization' header.
A valid token is generated by the API and returned by the /authenticate method by supplying a valid username and password.
The following syntax must be used in the 'Authorization' header :
Bearer aaaaaa/bbbbbb.ccccccc.ddddddBody
CSV file to import. The file must include a header row. Supported columns:
| Column | Required | Notes |
|---|---|---|
card_number | Yes | Up to 40 characters |
contract_id | Conditional | Required if reg_no is not supplied |
reg_no | Conditional | Required if contract_id is not supplied. Must resolve to exactly one active contract. |
account_number | No | Up to 40 characters |
status_flag | No | active or inactive. Blank on update leaves existing value unchanged. |
expiry_date | No | ISO 8601 date (yyyy-MM-dd). Blank on update leaves existing value unchanged. |
activated_date | No | ISO 8601 date (yyyy-MM-dd). Blank on update leaves existing value unchanged. |
inactivated_date | No | ISO 8601 date (yyyy-MM-dd). Blank on update leaves existing value unchanged. |
recharge_flag | No | yes or no. Blank on update leaves existing value unchanged. |
client_id_recharge | No | Blank on update leaves existing value unchanged. |
Response
Batch created and all rows validated. Inspect import_allowed to determine whether the batch may be processed.
true if there is at least one invalid, duplicate, or unauthorized row for which an error report can be downloaded via GET /fm/cards/imports/{import_batch_id}/errors.
truetrue if there is at least one create or update row that can be processed. false if every row is invalid, duplicate, or unauthorized — in which case calling the process endpoint would result in no operations being performed.
trueThe unique identifier for the newly created import batch record in gb_imports. Use this value in subsequent process, error, and result requests.
1042