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.
423 - Locked This request cannot be processed because the objects this request is trying to modify are being modified by another process.
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.
method_not_allowed 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.
idempotency_key_in_use The request conflicts with another request due to using the same idempotency key.
request_failed The request failed because the payment gateway declines the transaction or due to a payment gateway error.
request_timeout The client connection has timed out.
gateway_timeout The host connection has timed out.
payment_gateway_timeout The payment gateway connection has timed out.
payment_gateway_unavailable The payment gateway server is busy.
payment_gateway_error General transaction error.

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.
invalid_parameter_integer One or more of the parameters requires an integer, but the values provided were a different type. Make sure that only support values are provided for each attribute. Refer to our Quickstart API Reference to look up the type of data each attribute supports.
invalid_parameter_number One or more of the parameters requires a number, but the values provided were a different type. Make sure that only support values are provided for each attribute. Refer to our Quickstart API Reference to look up the type of data each attribute supports.
invalid_parameter_boolean One or more of the parameters requires a boolean, but the values provided were a different type. Make sure that only support values are provided for each attribute. Refer to our Quickstart API Reference to look up the type of data each attribute supports.
invalid_parameter_string One or more of the parameters requires a string, but the values provided were a different type. Make sure that only support 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.
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.
in_use The resource cannot be deleted because it is being used.
invalid_value The values of one or more parameters you specified are invalid. Check the parameter values you specified, update them to valid values, then try again.
delete_not_allowed The specified order cannot be deleted. This error is specific to the "Delete an order" operation.

Handling errors

If you use the Zuora SDK, use the following template to handle errors:

JavaNode
Copy
Copied
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
}
Copy
Copied
(async () => {
  try {

   // Use Zuora's client library to make requests
    
  }
  catch (error) {
     console.log(error);
  }
})();