# Errors

ReferralHero 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 an error that failed given the information provided (e.g., a required parameter was omitted, an update failed, etc.), and codes in the `5xx` range indicate an error with ReferralHero's servers (these are rare).

When a request returns an error we always try to provide a clear explanation of what went wrong. Errors are returned as JSON files and follow the same structure:

```json
{
  status: "error",
  message: "Error explanation" // Eg: "Missing API token"
  code: "error_code" // Eg: no_token
}
```

### **Status**

Our API raises errors for many reasons and when this happens the "status" attribute will always be "error". We recommend writing code that gracefully handles all possible API exceptions.

### **Message**

A human-readable message providing more details about the error.

### **Code**

The type of error returned. See list of possible errors below:

| Error codes                    | Explanation                                                |
| ------------------------------ | ---------------------------------------------------------- |
| no\_token                      | "api\_token" parameter is missing or blank                 |
| invalid\_token                 | "api\_token" provided does not exist                       |
| inactive\_account              | Account associated with this API token is inactive         |
| too\_many\_calls               | Rate limit hit. Wait 60 minutes to reset the counter.      |
| no\_list\_uuid                 | "uuid" parameter is missing or blank                       |
| invalid\_list                  | "uuid" provided belongs is invalid                         |
| no\_subscriber\_id             | "subscriber\_id" parameter is missing or blank             |
| subscriber\_not\_found         | subscriber provided does not exist                         |
| no\_email\_address             | "email" parameter is missing or blank                      |
| invalid\_email\_address        | "email" provided is not a valid email.                     |
| no\_name                       | "name" parameter is missing or blank                       |
| no\_points                     | "points" parameter is missing or blankno\_hosting\_url     |
| no\_hosting\_url               | "hosting\_url" parameter is missing or blank               |
| error\_list\_creation          | Something went wrong when creating a new list.             |
| subscriber\_already\_promoted  | Subscriber's already been promoted                         |
| subscriber\_not\_promoted      | Subscriber is not promoted, hence it can't be "unpromoted" |
| bad\_request                   | Missing required params                                    |
| reward\_not\_found             | The provided reward does not exist                         |
| invalid\_status                | The provided 'status' does not exist                       |
| no\_coupons                    | The "coupons" parameter is missing or blank                |
| error\_coupon\_group\_creation | Errors occured while creating coupon                       |
| coupon\_group\_created         | Coupon created successfully                                |
