Signature Detection API
The following document highlights the details of the Signature Detection API.
API Description
Objective
The Signature Detection API checks for a signature in an image and helps extract it by providing its bounding box* coordinates.
| Input | Output |
|---|---|
| The image containing the user's signature | The signature's bounding box coordinates |
A bounding box is a rectangular border that completely encloses a detected signature on an image. It is defined by its width, height, and the coordinates of its top-left corner (left, top). This allows precise localization of the signature within the image. Check the Success Response section for a set of sample bounding box values.
API URL
https://ind-engine.thomas.hyperverge.co/v1/signatureDetection
API Endpoint
signatureDetection
Overview
The Signature Detection API is RESTful and uses standard HTTP verbs and status codes. The responses are in JSON format, and you should upload all images and files as form-data through a POST request.
Method - POST
Authentication
You need a unique pair of application ID ( appId ) and application key ( appKey ) from HyperVerge to verify your identity for accessing the Signature Detection API.
Headers
| Header | Mandatory / Optional | Description | Input Format |
|---|---|---|---|
| content-type | Mandatory | This parameter defines the media type for the request payload | multipart/form-data |
| appId | Mandatory | The application identifier shared by HyperVerge. You can find the details in the dashboard's credentials tab | This should be a unique value |
| appKey | Mandatory | The application key shared by HyperVerge. You can find the details in the dashboard's credentials tab | This should be a unique value |
| transactionId | Mandatory | A unique identifier for tracking a user journey | This should be both unique and easily associated with the user's journey in your application(s) |
Inputs
Please upload uncompressed or raw images for more accurate detection and extraction. Compressed images may lead to inaccuracies.
The following table provides the details of the parameters required for the Signature Detection API's request body:
| Parameter | Mandatory / Optional | Type | Description | Input Format | Default Value |
|---|---|---|---|---|---|
image | Mandatory | file | The image or document for signature detection. The image file can be of JPEG or PNG format. It should contain only one signature for the detection process. The image should be clear and properly aligned to ensure accurate signature localization and extraction. The uploaded signature should ideally have a clear white background for the best performance. | Image file (JPEG or PNG) | Not Applicable |
returnInputSignatureUrl | Optional | string | If set to "yes", the response returns the s3Url field with the link to access the input image. If set to "no", the response does not return the s3Url field. | yes/no | no |
returnCroppedSignatureUrl | Optional | string | If set to "yes", the response returns the croppedS3Url field with the link to access a cropped image of the detected signature, excluding other elements of the original document. If set to "no", the response does not return the croppedS3Url field. | yes/no | no |
returnDetectionDetails | Optional | string | If set to "yes", the response returns the following additional fields for all the non-500 status responses: signatureDetected, score, and toBeReviewed. | yes/no | no |
checkCropped | Optional | string | If set to "yes", the Signature Detection API performs additional validation on the cropped signature image to ensure quality and accuracy. Signatures that touch the edges of the cropped image are rejected. If set to "no", only basic signature detection is performed. | yes/no | no |
Request
The following code snippet demonstrates a standard curl request for the Signature Detection API:
curl --location --request POST 'https://ind-engine.thomas.hyperverge.co/v1/signatureDetection' \
--header 'Content-Type: multipart/form-data' \
--header 'appId: <Enter_the_HyperVerge_appId>' \
--header 'appKey: <Enter_the_HyperVerge_appKey>' \
--header 'transactionId: <Enter_the_HyperVerge_transactionID>' \
--form 'image=@"<Enter_the_Path_to_the_Image_or_Document>"' \
--form 'returnInputSignatureUrl="<yes_or_no>"' \
--form 'returnCroppedSignatureUrl="<yes_or_no>"' \
--form 'useCompression="<yes_or_no>"' \
--form 'returnDetectionDetails="<yes_or_no>"' \
--form 'checkCropped="<yes_or_no>"'
Success Response
The following code snippet demonstrates a success response from the Signature Detection API:
- Success Response
- Success Response with Signature URLs Enabled
- Success Response with returnDetectionDetails Enabled
{
"status": "success",
"statusCode": 200,
"metaData": {
"requestId": "<Request_Identifier>",
"transactionId": "<Transaction_Identifier>"
},
"result": {
"message": "One signature detected",
"boundingBox": {
"width": 0.7068939208984375,
"height": 0.6442266702651978,
"left": 0.0950758308172226,
"top": 0.11097365617752075
}
}
}
The following is a success scenario with the returnInputSignatureUrl and returnCroppedSignatureUrl set to "yes" in the request.
{
"status": "success",
"statusCode": 200,
"metaData": {
"requestId": "<Request_Identifier>",
"transactionId": "<Transaction_Identifier>"
},
"result": {
"message": "One signature detected",
"boundingBox": {
"width": 0.7068939208984375,
"height": 0.6442266702651978,
"left": 0.0950758308172226,
"top": 0.11097365617752075
},
"s3Url": "<Signature_Image_URL>",
"croppedS3Url": "<Cropped_Signature_URL>"
}
}
The following is a success scenario with the returnDetectionDetails set to "yes" in the request.
{
"status": "success",
"statusCode": 200,
"metaData": {
"requestId": "<Request_Identifier>",
"transactionId": "<Transaction_Identifier>"
},
"result": {
"message": "One signature detected",
"boundingBox": {
"width": 0.7494100332260132,
"height": 0.17407670617103577,
"left": 0.16272765398025513,
"top": 0.4088674336671829
},
"s3Url": "<Signature_Image_URL>",
"signatureDetected": "yes",
"score": 0.58,
"toBeReviewed": "yes",
"croppedS3Url": "<Cropped_Signature_URL>"
}
}
Success Response Details
The following table outlines the details of the success response from the Signature Detection API:
| Parameter | Type | Description |
|---|---|---|
status | string | The status of the request |
statusCode | integer | The HTTP status code for the response |
result | object | The JSON object containing the signature detection details |
result.message | string | The summary of the signature detection outcome |
result.boundingBox | object | The coordinates of the detected signature |
result.s3Url | string | The URL of the input image |
result.croppedS3Url | string | The URL of the cropped image of the signature after detection |
result.signatureDetected | string | Indicates whether a signature was detected (returned when returnDetectionDetails is "yes") |
result.score | float | The detection score (returned when returnDetectionDetails is "yes") |
result.toBeReviewed | string | Indicates whether manual review is required (returned when returnDetectionDetails is "yes") |
Failure Response
The following code snippet demonstrates a failure response from the Signature Detection API:
- Failed to Detect a Signature
- Failed to Detect a Signature with returnDetectionDetails Enabled
{
"status": "failure",
"statusCode": 400,
"metaData": {
"requestId": "<Request_Identifier>"
},
"error": {
"message": "No signature detected"
}
}
The following is a failure scenario with the returnDetectionDetails set to "yes" in the request.
{
"status": "failure",
"statusCode": 400,
"metaData": {
"requestId": "<Request_Identifier>"
},
"error": {
"message": "No signature detected"
},
"result": {
"s3Url": "<Signature_Image_URL>",
"signatureDetected": "no",
"score": 0.8,
"toBeReviewed": "no"
}
}
Error Responses
The following are some error responses from the Signature Detection API:
- Multiple Signatures Detected
- Unsupported Document Format
- Edge-Drawn Signature
- Missing/Invalid Credentials
- Signature on Non-White Background
- Invalid Ink Color
- Rate Limit Exceeded
- Internal Server Error
{
"status": "failure",
"statusCode": 400,
"metaData": {
"requestId": "<Request_Identifier>"
},
"error": {
"message": "Multiple signatures detected"
}
}
{
"status": "failure",
"statusCode": 400,
"metaData": {
"requestId": "<Request_Identifier>"
},
"error": {
"message": "Unsupported document format"
}
}
{
"status": "failure",
"statusCode": 400,
"metadata": {
"requestId": "<Request_ID>"
},
"error": {
"message": "Invalid signature: Signature is cropped or touches the border"
},
"result": {}
}
{
"message": "Missing/Invalid credentials",
"statusCode": 401,
"status": "failure"
}
{
"status": "failure",
"statusCode": 422,
"metaData": {
"requestId": "<Request_Identifier>",
"transactionId": "<Transaction_Identifier>"
},
"error": {
"message": "Invalid Signature. Please upload the signature on a white paper"
},
"result": {}
}
{
"status": "failure",
"statusCode": 422,
"metaData": {
"requestId": "<Request_Identifier>",
"transactionId": "<Transaction_Identifier>"
},
"error": {
"message": "Invalid Signature. Ink color is not valid."
},
"result": {
"s3Url": "https://s3.amazon.com/a/b/c/d.jpg"
}
}
{
"status": "failure",
"statusCode": 429,
"error": "Rate limit exceeded"
}
{
"status": "failure",
"statusCode": 500,
"message": "internal server error"
}
Error Response Details
A failure or error response contains a failure status with a relevant status code and error message.
The following table lists all error responses:
| Status Code | Error Message | Error Description | Error Resolution |
|---|---|---|---|
| 400 | No signature detected | No signature was detected in the uploaded image | Please retake the image and try again. Ensure the uploaded image contains a clear signature |
| 400 | Multiple signatures detected | Multiple signatures were detected in the uploaded image | Please retake the image and try again. Ensure the uploaded image contains only one signature |
| 400 | Unsupported Document Format | The document format is not supported | Please upload a JPEG or PNG image |
| 400 | Invalid signature: Signature is cropped or touches the border | This error occurs when the detected signature touches the edges of the image or is partially cropped, which can affect signature quality and validation accuracy | Ensure the signature is fully contained within the image boundaries and does not touch the edges |
| 401 | Missing/Invalid credentials | The request is either missing the mandatory appId and appKey combination or has invalid values | Verify and provide valid appId and appKey credentials |
| 422 | Invalid Signature. Please upload the signature on a white paper | The signature is not on a white paper. It is mandatory to use a white background for signature detection | Upload the signature on a white background |
| 422 | Invalid Signature. Ink color is not valid | The wet signature has invalid ink color (red or green) | Use black or blue ink for the signature |
| 429 | Rate limit exceeded | You have exceeded the configured limit on the number of transactions permitted in a minute | Retry the request after some time or contact the HyperVerge team if the issue persists |
| 500 | Internal Server Error | An internal server error occurred while processing the request | Check the request headers or contact the HyperVerge team for resolution |