What happens if an API fails?
When an API fails, it means that the intended operation or task could not be completed as expected. API failures can occur for various reasons, including client-side errors, server-side issues, network problems, or incorrect API usage. Here's what typically happens when an API fails:
HTTP Status Codes
: APIs often use HTTP status codes to indicate the outcome of a request. These codes provide information about whether the request was successful or encountered an error. Common HTTP status codes include:
200
OK
201
Created
400
Bad request
401
Unauthorized (Invalid AuthToken)
404
URL Not Found
405
Method Not Allowed (Method you have called is not supported for the invoked API)
429
Rate Limit Exceeded (API usage limit exceeded)
500
Internal Error
Error Messages:
APIs often include error messages or error codes in the response payload to provide more specific details about what went wrong. These messages help developers diagnose the issue and take appropriate action.
For more detailed information, please reach out at
help@protecto.ai
.
:
1. if payload length is empty
sample input:{"mask": [ ]}
error response:{"data": null,"success": false,"error": {"message": "Payload is empty"}}
2. if 'mask' key not in payload
sample input:[{ "value": “George Williams","token_name": "Numeric Token"}]}
error response:{"data": null,"success": false,"error": {"message": "mask data missing"}}
3. if value is not there in input:
sample input:{"mask": [{ "value": "","token_name": "Numeric Token"}]}
error response:{"data": null,"success": false,"error": { "message": "Missing value"}}
4. if "token_name" is not there in input:
sample input:{"mask": [{ "value": "George Williams","token_name": ""}]}
error response:{"data": null,"success": false,"error": { "message": "Missing token_name"}}
5.if given token_name is not created or invalid token_name:
sample input:{"mask": [{ "value": "George Williams","token_name": "dfdfd"}]}
error response:{"data": null,"success": false,"error": {"message": "token_name not defined: {<INVALID_TOKEN_NAME>}"}}
6. if the format is empty
sample input:{"mask": [{ "value": "George Williams","token_name": "Numeric Token","format":""}]}
error response:{"data": null,"success": false, "error": { "message": "Missing format"}}
7. if the given format is invalid or not created:
sample input:{"mask": [{ "value": "George Williams","token_name": "Numeric Token","format":"fdfdf"}]}
error response:{"data": null,"success": false,"error": { "message": "format name not defined: {<INVALID_FORMAT_NAME>}}}
8. if metadata for masking is missing
sample input:{"mask": [{ "value": "George Williams","token_name": "dd","format":"fdfdf"}]}
error response:{"data": null, "success": false, "error": {"message": "Token and Format Metadata not available"}}
9. if subscription exhausted for user:
sample input:{"mask": [{ "value": "George Williams","token_name": "Numeric Token","format":"Person Name "}]}
error response: {"data": null, "success": false, "error": { "message": "You have exceeded the maximum number of token creation limit for your trial subscription. To upgrade your subscription, please contact help@protecto.ai."}}
10. if masked data is too long
sample input:{ "data": null,"success": false,"error": {"message": "Masked data exceeds the approved limit of 600 characters. please split the input value and try again." }}
11. if mask operation fails after 3 retries
sample input:{ "data": null,"success": false, "error": {"message": "Masking failed after 3 retries"}}
unmask api error messages: error_code: 500
1. if payload length is empty
sample input:{“unmask":[{}]}
{ "data": null, "success": false, "error": { "message": "Payload is empty" }}
2. if 'unmask' key not in payload
sample input:[{“token_value”:"2333"}]}
error response: { "data": null, "success": false,"error": { "message": "unmask data missing"}}
3. if 'token_value' not in unmask payload
sample input:{“unmask”:[{“token_value”:" "}]}
error response:{"data": null, "success": false, "error": {"message": "Missing token value field "}}
4. if 'token_value' field is empty
sample input:{“unmask”:[{"2333"}]}
error response:{"data": null, "success": false, "error": {"message": "Missing token value"}}
5. if unmasking failed
error response:{"data": null, "success": false, "error": { "message": "Unmasking of given token values failed." }}
Authentication error messages : error_code: 401
Note: To send a request with the authentication token, include the following in headers:
Headers: {"Authorization": "Bearer <AUTH_TOKEN>"}
1. If the auth token is not there in the authorization headers
{ "detail": "To access Protecto, a valid license is required. Please create an account to execute the code"}
(or)
{"detail": "Your license is currently being generated. Please wait for a moment before running the code."}
2. if the auth token is expired
{ "detail": "Protecto's license has expired. To execute the code, please contact help@protecto.ai."}
3. if no Authorization header
{ "detail": "Access token has expired or is not yet valid."}
(or)
{ "detail": "Not authenticated"}
Last updated