Error Handling

Understanding response codes

Ninjapay uses conventional HTTP response codes to indicate the success or failure of an API request. Codes in the 2xxrange indicate success, in the 4xxrange indicate an error that failed given the information provided (usually a required parameter was omitted or incorrectly sent), in the 5xxrange indicate an error with Ninjapay's servers.

Status Code
Meaning
HTTP Response

200 - OK

Everything worked as expected

{ data: { ... } }

201 - OK

Entity created with success

{ data: object }

400 - Bad Request

The request was unacceptable, often due to incorrect or missing required parameter.

{ success: false, message: 'Error details' }

404 - Not Found

The requested resource doesn't exist

{ success: false, message: 'Error details' }

500 - Server Errors

Something went wrong with Ninjapay's servers

{ success: false, message: 'Error details' }

Our official API libraries raise exceptions when errors are thrown. We recommend writing code that gracefully handles all the possible API exceptions.

Last updated