Learn about the different error responses returned from Wristband's APIs.
HTTP Status Codes
If a call to a Wristband API fails, the response will include a 4xx or 5xx HTTP status code.
- 4xx indicates an issue with the request.
- 5xx indicates an error on Wristband’s servers.
In both cases, the response body includes a JSON object with details about the error. The JSON object will be one of two types:
- Base Error
- Constraint Violations Error
In the following sections, we'll go over the differences between the two types of error objects.
Base Error Object
This is the default error object, and it can be returned for both 4xx and 5xx HTTP status codes.
Base Error Object Fields
Name | Type | Description |
---|---|---|
type | String | The type of the error object. This value will always be base_error . |
code | String | A distinct code representing the error that occurred. |
message | String | A human-readable message describing the error. |
ticket | String | String used internally by Wristband to correlate error responses to server-side requests. |
Example Base Error Response
The following is an example of a Base Error returned when calling the Get User API with an identifier that does not match an existing user.
HTTP/2 404 Not Found
Content-Type: application/json;charset=UTF-8
{
"type": "base_error",
"code": "user_not_found",
"message": "User [abc123] could not be found",
"ticket": "v1c7nblicpvqia7fia8r5d2qeu"
}
Constraint Violations Error Object
Constraint Violations Error objects are returned when issues are linked to specific parts of the HTTP request, such as a request body field, query parameter, path parameter, or header. A Constraint Violations Error object has the same structure as a Base Error object, except it has an additional violations
field.
Constraint Violations Error Object Fields
Name | Type | Description |
---|---|---|
type | String | The type of the error object. This value will always be constraint_violations_error . |
code | String | A distinct code representing the error that occurred. The code will be one of the following: - message_body_constraint_violations : Returned if the violations correspond to the request message body fields.- request_constraint_violations : Returned when the violations relate to parts of the HTTP request other than the body, such as query parameters, path parameters, or headers. |
message | String | A human-readable message describing the error. |
ticket | String | String used internally by Wristband support to correlate error responses to server-side requests. |
violations | Map<String, List<ConstraintViolationDetails>> | A map where each key is the path to the part of the request that violated the constraint, and each value is a ConstraintViolationDetails object describing the violation. |
Constraint Violation Details Object Fields
Name | Type | Description |
---|---|---|
code | String | Error code indicating the issue with the request value. |
constraintAttributes | Map<String, String> | A map containing metadata about the violated constraint. Each key is a constraint attribute name, and each value is the attribute's assigned value, represented as a string. Note, for some violations, the constraintAttribute field may be undefined if there's no additional metadata associated with the code. |
Example Constraint Violations Error Response
To help better understand the structure of a Constraint Violation Error, consider a request to the Create User API with an email value exceeding the 200-character limit. The resulting error response would appear as follows:
HTTP/2 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
"type": "constraint_violations_error",
"code": "message_body_constraint_violations",
"message": "Field violations detected while trying to create a user",
"ticket": "jgqgau2nj4eobeaje6m4jhoop8",
"violations": {
"email": [{
"code": "too_long",
"constraintAttributes": {
"maxLength": "200"
}
}]
}
}
If we look at the violations
, we can see it contains one entry for the user email
field. The code of too_long
indicates that the email value we provided exceeded the max allowed length. Furthermore, the constraintAttributes
field includes a maxLength
attribute set to 200, showing that the email field cannot exceed 200 characters.
Nested Fields
If a violation occurs on a nested field, the key will show the full path to the field, using periods (
.
) as field delimiters. For example, if the Create Identity Provider API was called with an invalid protocol type, the violation key would beprotocol.type
.
Constraint Violation Codes
Below is a table containing descriptions of all constraint violation codes.
Code | Description |
---|---|
blank | Indicates that a string was left blank when a value was required. |
contained_disallowed_element | Indicates that a collection contained an element that is not allowed. |
contained_invalid_field_name | Indicates that the specified object field name is not valid. |
contained_nested_arrays | Indicates that an object contained nested arrays, which are not allowed. |
digit_not_present | Indicates that a password did not contain a digit, when digits are required. |
disabled | Indicates that the referenced entity is disabled when it is required to be enabled. |
disallowed_enum | Indicates that the specified enum value is not allowed. |
duplicate_elements | Indicates that a collection contained duplicate elements, when they are required to be unique. |
duration_greater_than | Indicates that a duration was greater than the maximum allowed value. |
duration_less_than | Indicates that a duration was less than the minimum allowed value. |
email_value_not_allowed | Indicates that a value was an email when non-email values are required. |
empty | Indicates that a collection was empty when it is required to contain at least one element. |
expired | Indicates that an ephemeral token or code has expired. |
failed_regex_match | Indicates that a string value did not match a required regex pattern. |
greater_than | Indicates that a number was greater than the maximum allowed value. |
illegal_domain_suffix | Indicates that a domain name contained an illegal suffix. |
immutable | Indicates an attempt to modify a field that is immutable. |
inactive | Indicates that the referenced entity is inactive when an active one is required. |
invalid_code_point | Indicates that a Unicode string contained an invalid code point. |
invalid_date | Indicates that a string was not a valid ISO 8601 representation of a date. |
invalid_date_time | Indicates that a string was not a valid ISO 8601 representation of a datetime. |
invalid_directionality | Indicates that a Unicode string violated a directionality rule. |
invalid_domain_name | Indicates that a string was not a valid domain name. |
invalid_domain_name_label | Indicates that a string was not a valid domain name label. |
invalid_duration | Indicates that a string was not a valid ISO 8601 duration. |
invalid_e164_phone_number | Indicates that a string was not a valid E.164 phone number |
invalid_email | Indicates that a string was not a valid email address. |
invalid_epoch_timestamp | Indicates that a number could not be converted to a valid epoch timestamp. |
invalid_ip_address | Indicates that a string was not a valid IP address. |
invalid_locale | Indicates that a string was not a valid BCP 47 language tag. |
invalid_path_expression | Indicates that a string was not a valid path expression composed of field names delimited by periods (. ). |
invalid_phone_number | Indicates that a string was not a valid phone number. |
invalid_semantic_version | Indicates that a string was not a valid semantic version. |
invalid_time_zone | Indicates that a string was not a valid IANA time zone. |
invalid_url | Indicates that a string was not a valid URL. |
invalid_url_authority | Indicates that a string contained an invalid URL authority. |
invalid_url_path | Indicates that a string contained an invalid URL path. |
invalid_url_query | Indicates that a string contained an invalid URL query string. |
invalid_url_scheme | Indicates that a string contained an invalid URL scheme. |
less_than | Indicates that a number was less than the minimum allowed value. |
lowercase_char_not_present | Indicates that a password did not contain a lowercase character when one is required. |
max_byte_length_exceeded | Indicates that a field's max byte length was exceeded. |
max_field_count_exceeded | Indicates that an object contains more fields than the allowed maximum. |
max_nesting_depth_exceeded | Indicates that an object contains nested objects that exceed the maximum allowed nesting depth. |
missing_required_element | Indicates that a collection is missing an element that is required to be present in the collection. |
not_active | Indicates that a referenced entity is not active when it is required to be active. |
not_alphanumeric | Indicates that a string contained non-alphanumeric characters when only alphanumeric characters are allowed. |
not_false | Indicates that a boolean value was true when it was required to be false . |
not_empty | Indicates that a collection was not empty when it was required to be empty. |
not_found | Indicates that a referenced entity does not exist. |
not_json_object | Indicates that a string was not a valid JSON object. |
not_null | Indicates that a value was not null when it should have been null. |
not_subdomain_of_public_suffix | Indicates that the specified domain name was not a subdomain of a public suffix. |
not_true | Indicates that a boolean value was false when it was required to be true . |
not_undefined | Indicates that a value was not undefined when it should have been undefined. |
not_unique | Indicates that the specified value violates a unique constraint. For example, this error can occur when you attempt to create a tenant with a name that's already in use by another tenant within the same application. |
null | Indicates that a value was null when a non-null value was required. |
future | Indicates that a time or date value references the future when it should reference the past. |
password_breached | Indicates that a specified password has been detected in a breached data set. |
past_or_present | Indicates that a time or date value references the past or present when it should reference the future. |
size_greater_than | Indicates the size of a collection is greater than the maximum allowed size. |
special_char_not_present | Indicates that a password did not contain a special character when special characters are required. |
phone_number_value_not_allowed | Indicates that a value was a phone number when non-phone number values are required. |
too_far_into_past | Indicates that a date or time value is too far into the past. |
too_far_into_future | Indicates that a date or time value is too far into the future. |
too_long | Indicates that a string value is too long. |
too_short | Indicates that a string value is too short. |
undefined | Indicates that a value was undefined when a value is required. |
unknown | Indicates that an unknown enum value was provided. |
uppercase_char_not_present | Indicates that a password did not contain an uppercase character when one is required. |
url_contained_fragment | Indicates that a URL contained a fragment when fragments are not allowed. |
url_contained_http_scheme | Indicates that a URL contained an HTTP scheme instead of an HTTPS scheme. |
url_contained_ip_address | Indicates that a URL contained an IP address instead of a domain name as the host. |
url_contained_loopback_address | Indicates that a URL contained a loopback address when loopback addresses are not allowed. |
url_contained_query_parameters | Indicates that a URL contained query parameters when query parameters are not allowed. |
url_contained_user_info | Indicates that a URL contained user info when user info is not allowed. |
url_domain_name_too_long | Indicates that the URL's domain name is too long. |