# 3.3.5.REST API Error Handling Practices

* API response ![](https://163116165-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4M0G7tIs4o9F9vSrao%2F-M4M0IVB0ax0vs2ocz_r%2F-M4M0XO9VEuHktPodSFE%2F201803176.jpg?generation=1586302965972299\&alt=media)
* HTTP status codes
  * over 70 status code
  * Decide the code that you will use for your API
    * Restrict the number of HTTP codes to a maximum of 8
    * Must use 200/ 400/ 500
* Error response
  * 1.Set the HTTP status codes to 4xx or 5xx
  * 2.Set the **Content-Type** of error response; common to use json
    * Content-Type: "application/json"
  * 3.Use numeric error codes for application specific errors
    * e.g., error = 7002
  * 4.Use a standard error **template for error response** body
  * Alternative approach to error response
    * Always send back HTTP status = 200 OOK
      * Response

        ```
        {
          status: {}
          payload: {}
        }
        ```
