Image/File · Standard API · eKYC Core
Upload image
Uploads an image, as a file or as base64, and returns the image_id that every other eKYC Core API takes as its image reference.
Request
Send the image either as a file in a multipart/form-data body or as base64-encoded text in an application/json body. Which of file and base64 is required follows from that choice.
| Name | Type | Required | Description |
|---|---|---|---|
file | file | Required if content-type is multipart/form-data | the image file to be uploaded |
base64 | string | Required if content-type is application/json | the base64 of image file to be uploaded |
label | string | Required | label of the image as described at Label table |
metadata | string_json | Optional | key-value, key should be string, value should be string, int, float, bool. Example {\"id\":\"123456789\", \"type\": 1} |
tag | string | Optional | tag of the image. India only |
metadata is a JSON string holding key/value pairs as a dictionary. For a QR code image it can carry the raw decoded string:
{\"raw\": \"value\"} // raw decoded string of the QR code.
Sample request
curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/images \
-H 'Authorization: TV <YOUR ACCESS KEY>:<CREATED SIGNATURE>' \
-H 'X-TV-Timestamp: 2019-04-21T18:00:15+07:00' \
-F 'file=@"images/portrait.jpg"' \
-F 'label="portrait"'
Response
data.image_id is the id of the stored image, and it is what the rest of the eKYC Core APIs take as their image reference.
{
"data": {
"image_id": string, // ID of the uploaded image in StoreDB
},
"errors": [
{
"code": string,
"message": string,
"detail": {
"field": string, // optional, which parameter is invalid.
... // any other information that can be useful for client
},
},
... // other errors
]
}
On success the HTTP status code is 200 and data holds:
| Name | Type | Description |
|---|---|---|
image_id | string | ID of the uploaded image (UUID) |
A successful upload comes back like this:
{
"data": {
"image_id": "20b457d2-cf11-4c2b-a491-8137ae6b0bc8"
}
}
Failure codes
In case of error, the data will be empty, and server sends following HTTP status code and error information:
| HTTP code | Error code | Description |
|---|---|---|
400 | invalid_parameter_exception | Input parameter violates a constraint. |
400 | request_time_too_skewed | The X-TV-Timestamp header is expired, need a newer one. |
401 | access_denied_exception | You are not authorized to perform the action. |
404 | image_not_found_exception | The image ID is not found in DB. |
413 | image_too_large_exception | The input image size exceeds the allowed limit (15MB). |
415 | invalid_image_format_exception | The provided image format is not supported (JPG/PNG) |
408 | request_timeout_exception | Request takes too long to process |
429 | rate_limit_exception | The number of requests exceeded your throughput limit. |
500 | internal_server_error | Some unexpected error occurs while processing the request |
The codes above are the ones documented for this endpoint. Response errors on the Overview lists the codes for the eKYC Core surface as a whole — the two lists do not match on every endpoint.