Code upload from template
Overview
This method utilizes an ingestion template provided by Scantrust engineers during the onboarding process to upload codes. It's the preferred method for uploading codes to the Scantrust system.
Supported code types:
- Serialized Identifiers (SID) codes (pre-print)
- Secure Codes (SSC) (pre-print)
Restrictions:
- One upload generates 1 workorder
- Specific settings will be inherited from the template and can not be set directly
For more information about different upload methods, Pre Print / Post Print, please refer to the overview.
API Design
Create Ingestion Record from template
POST /api/v2/ingestion/codes/create-from-template/
Overview
Calling this endpoint will start the code upload (ingestion) process. The ingestion process is an async process which must be validated upon completion using the record key from the response.
Please refer to the Ingestion Record documentation to see how to retrieve ingestions and check status.
Field Description
Field | Type | Description |
---|---|---|
mode | string [api, file] (Optional) | Default = api, Defines the upload mode. |
filetype | string [csv, json] (Optional) | Default = CSV, only applicable when mode = file |
default_scm_data | json (Optional) | SCM data field including product/activation_status/blacklist_reason/… WOrks the same as the SCM upload endpoints. Data here will be used as the default for each code (overridden by what is in the code record) |
codes | list - json (Optional*) | List of code records, may include SCM data / product etc and must include id |
template | string (Template Key) | Ingestion Template Key, provided by Scantrust |
printing_partner | int (Optional) | Overrides/sets printing partner. Required for SSC WO’s. |
optional*: Only required when mode=API
Validations
Some fields are validated directly upon the API call and others are validated during processing in the background.
Validated upon API call (400 BAD REQUEST - response, ingestion aborted)
- API mode
-
- Code ID (must exist for every row), codes can not be empty
-
- SCM data for codes must be valid
-
- Duplicate checks in the codes field
- File Mode
-
- Codes can not be passed directly
- All fields are separately checked for valid input
Validated during processing (200 OK, check status using record API):
- All code ID formats
- Duplicate checks within the system + file
- All SCM data / products / related objects / ...
Example payload
{
"codes": [
{
"id": "abc1234567810",
"pallet_nr": "PA01"
}
],
"default_scm_data": {
"activation_status": 1
},
"mode": "api",
"template": "template-1" // Template Key
}
Example Response (mode API) 200 OK
{
"record_key": "3k59jyrwznhp"
}
Example Response (mode S3) 200 OK
{
"post_data": {
"url": "https://st-media-dev.s3.amazonaws.com/",
"fields": {
"Content-Type": "text/csv",
"key": "private/c/1/ingestion/code/p37bk370jurt.csv",
"AWSAccessKeyId": "AKI...",
"policy": "eyJ...",
"signature": "yc..."
}
},
"record_key": "p37bk370jurt"
}
Example Response invalid template 400 BAD REQUEST
{
"template": [
"Invalid pk \"100\" - object does not exist."
]
}
Note: When using mode: file, the file must now be uploaded to the URL provided directly before calling /process-from-file/. Please refer to the file upload documentation for more information.
Next steps
- When using mode = file, continue uploading the file using the data returned from the API and call /process-from-file/ as described in the file upload documentation
- Check the ingestion status using the Ingestion Record API
- Use your uploaded codes