Metadata · eKYC Core

Update metadata

PATCH/v1/images/{image_id}

Adds metadata, and optionally a label, to an uploaded image, and returns the image's latest label and metadata.

Request

MethodPATCH
Path/v1/images/{image_id}
Content-Typeapplication/json
Auth requiredYes — HMAC signing

{image_id} in the path is the id of the image the metadata is attached to.

NameTypeRequiredDescription
metadatadictionaryRequiredkey-value, key should be string, value should be string, int, float, bool
labelstringOptionallabel of the image as described at Label table
overrideboolOptionalflag to allow override old metadata or not
JSON
{
    "metadata": dictionary,
    "label": string,
    "override": bool,
}

Sample request

curl -X PATCH \
https://tv-staging.trustingsocial.com/api/v1/images/a4facba3-334b-41fb-97e3-4766cb70ae29 \
-H 'Authorization: TV <YOUR ACCESS KEY>:<CREATED SIGNATURE>' \
-H 'X-TV-Timestamp: 2019-04-21T18:00:15+07:00' \
-H 'Content-Type: application/json' \
-d \
'
{
    "metadata":  {
        "national_id": "123456789"
    }
}
'

Response

The response is a JSON body in the shape below; the errors array follows the shared response envelope.

JSON
{
    "data": {
        "image_id": string, // ID of the uploaded image in DB
        "label": string, // Label of the uploaded image
        "metadata": dictionary, // Metadata of the uploaded image
    },
    "errors": [
        {
            "code": string,
            "message": string,
            "detail": {
                "field": string, // optional, which parameter is invalid.
                ... // any other information that can be useful for client
            },
        },
        ... // other errors
    ]
}

In case of success, the HTTP status code will be 200, and the data will be an object containing following fields:

fieldtypedescription
image_idstringID of the uploaded image (UUID)
labelstringlatest label of the image
metadatadictionarylatest metadata of the image

An image that now carries a portrait label and two metadata keys:

JSON
{
    "data": {
        "image_id": "b35acc59-eefb-44fb-a6eb-ea02cec42cfc",
        "label": "portrait",
        "metadata": {
            "app_id": "5555",
            "national_id": "6666"
        }
    }
}

Failure codes

In case of error, the data will be empty, and server sends following HTTP status code and error information:

HTTP codeError codeDescription
401access_denied_exceptionYou are not authorized to perform the action.
400invalid_parameter_exceptionInput parameter violates a constraint.
404image_not_found_exceptionThe image ID is not found in DB.
408request_timeout_exceptionRequest takes too long to process
429rate_limit_exceptionThe number of requests exceeded your throughput limit.
500internal_server_errorSome unexpected error occurs while processing the request

The codes above are the ones documented for this endpoint. Response errors lists the codes for the eKYC Core surface as a whole — the two lists do not match on every endpoint.