Quickstart API Error Handling
Your Zuora integration may have to deal with errors when making requests to the Zuora API.
Zuora uses conventional HTTP response codes to indicate the success or failure of an API request. In general:
- Codes in the 2xx range indicate success.
- Codes in the 4xx range indicate errors that occurred on the user's end, for example, a required parameter was missing, or a resource has been removed.
- Codes in the 5xx range indicate errors with Zuora's servers.
Some 4xx errors that could be handled programmatically include an error code that briefly explains the error reported.
An error response contains the following attributes:
Attribute | Type | Description |
---|---|---|
type | enum | Type of the error. See the Error types section below for details. |
code | string | An error code indicating the reported error. See the Error codes section below for details. |
message | string | A human-readable message providing more details about the error. |
parameter | string | If the error is parameter-specific, it shows the parameter related to the error. For example, you can use this attribute to display a message near the correct form field. |
HTTP status codes
The following table lists the HTTP status codes you might receiving when working with the Quickstart API:
HTTP status code | Description |
---|---|
200 - OK | Everything worked as expected. |
201 - Created | Everything worked as expected and a resource was created. |
202 - Accepted | Your request has been accepted, but processing has not been completed and may not have been started. |
400 - Bad Request | The request contains invalid parameters. |
401 - Unauthorized | The request requires user authentication. Resend the request with valid authentication credentials for the resource. |
403 - Forbidden | Access is forbidden to users with your authentication credentials. |
404 - Not Found | The server cannot find the requested resource. |
408 - Request Timeout | The server has decided to close this connection rather than continue waiting. |
409 - Conflict | The request conflicts with the current state of the target resource. |
429 - Too Many Requests | Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. |
500, 501, 502, 503, 504 - Server Errors | Something went wrong on Zuora’s end. |
Error types
The following table lists values of the type
field in the error response, and their corresponding description:
Error Type | Description |
---|---|
bad_request |
The request contains invalid parameters. |
unauthorized |
The request requires user authentication. Resend the request with valid authentication credentials for the resource. |
forbidden |
Access is forbidden to users with your authentication credentials. |
not_implemented |
The server does not recognize the request method and is incapable of supporting it. |
conflict |
The request conflicts with the current state of the target resource. |
not_found |
The server cannot find the requested resource. |
locked |
This request cannot be processed because the objects this request is trying to modify are being modified by another process. |
too_many_requests |
Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. |
internal_server_error |
Something went wrong on Zuora’s end. |
Error codes
Some errors include an error code - a short string with a brief explanation.
Below is a list of possible error codes, along with additional information about how to resolve them.
Error code | Description |
---|---|
invalid_parameter |
One or more of the parameters requires a value of a specific type, but the values provided were a different type. Make sure that only supported values are provided for each attribute. Refer to our Quickstart API Reference to look up the type of data each attribute supports. |
unknown_parameter |
The request contains one or more unexpected parameters. Remove these parameters and try again. |
missing_parameter |
One or more required values are missing. Check our Quickstart API Reference to see which values are required to create or modify the specified resource. |
parameters_exclusive |
Two or more mutually exclusive parameters were provided. Check our Quickstart API Reference or the returned error message to see which values are permitted when creating or modifying the specified resource. |
invalid_request |
The request could not be understood by the server due to malformed syntax. Check our Quickstart API Reference to see how to create or modify the specified resource and modify your request accordingly. |
not_found |
The requested resource does not exist. |
card_error |
An error occurred while processing the card. Try again later or with a different payment method. |
authorization_token_expired |
The authorization token provided has expired. Obtain a new authorization token and try again. |
lock_timeout |
This object cannot be accessed right now because another API request or Zuora process is currently accessing it. If you see this error intermittently, retry the request. If you see this error frequently when making multiple concurrent requests to a single object, submit your requests serially or at a lower rate. See our rate limit documentation for more details. |
resource_already_exists |
A resource with a user-specified identifier already exists. Use a different and unique value for the identifier such as account_number and try again.Note: This error code only applies to a resource referenced in a POST request. The error type for such an error is bad_request instead of not_found . |
resource_not_found |
The resource identifier provided is not found. Note: This error code applies to a resource referenced in a POST, PUT, or PATCH request. For example, when creating a payment method for an account by specifying either an account_number or account_id that does not exist. It will result in an error where the type is bad_request instead of not_found . |
Handling errors
If you use the Zuora SDK, use the following template to handle errors:
try {
// Use Zuora's client library to make requests
} catch (RateLimitException e) {
// Too many requests made to the API too quickly
} catch (InvalidRequestException e) {
// Invalid parameters were supplied to Zuora's API
} catch (AuthenticationException e) {
// Authentication with Zuora's API failed (maybe you changed API keys recently)
} catch (APIConnectionException e) {
// Network communication with Zuora failed
} catch (ZuoraException e) {
// Display a very generic error to the user, and maybe send yourself an email
} catch (Exception e) {
// Something else happened, completely unrelated to Zuora
}
(async () => {
try {
// Use Zuora's client library to make requests
}
catch (error) {
console.log(error);
}
})();