# Debugging

> Error codes, rate limits and the checks to run when a Segmentify API request fails.

Start by sending the failing request from the API reference with the same values. The reference shows the raw response, which usually names the problem.

## Events API

The Events API reports errors in the response body. If the body contains a `statusCode` field, the request failed.

| `statusCode` | Meaning | What to check |
| --- | --- | --- |
| `NO_API_KEY` | The `apiKey` parameter is missing. | Send your API key as the `apiKey` query parameter. |
| `NO_ACCOUNT` | The API key belongs to no Segmentify account. | Compare the key with the one under Settings > Integrations. |
| `FAILED_ACCOUNT` | The account of the API key is inactive. | Contact the Segmentify support team to re-activate the account. |
| `NO_DOMAIN_APIKEY_MATCH` | The `Origin` header does not match the domain of the account. | Send the registered domain as `Origin`. In the reference on this site, use `X-Forward-Origin`. |
| `NO_EVENT` | The request body holds no events. | Send at least one event. |
| `INVALID_EVENT` | The event format is not acceptable. | Compare the event with the example of its category. |
| `NO_USERID` | An event has no `userId`. | Add `userId` to every event. See [Session Management](/events/session-management/). |
| `NO_SESSIONID` | An event has no `sessionId`. | Add `sessionId` to every event. |
| `BAD_INPUT` | The body is not valid JSON. | Validate the JSON: look for missing or trailing commas and comments. |

Other checks:

- **Data center**: the host must be the data center of your account. A key sent to another data center is not found.
- **Test mode**: an event with `testMode: "true"` does not affect live data, so it does not show up in live reports.
- **Campaign events** (email, SMS, push): the values come from the UTM parameters of the landing page URL. Check that the URL carries them before sending the event. See [Email](/events/email/), [SMS](/events/sms/) and [Push](/events/push/).
- **Push endpoints** are served from the push data center, not the events data center.

## Customer API

- **`401`**: the access token is missing, invalid or expired. Access tokens are short-lived; get a new pair from `POST /auth/token/refresh`, or log in again if the refresh token has expired too.
- **Missing version header**: every endpoint needs `X-Api-Version: 1.0`.
- **Wrong region**: use the base URL of your region, `api-eq` for Türkiye or `api-gcp` for Global.
- **Batch requests succeed partially**: a `200` response does not mean every record was created. Read `invalids` (records that failed validation and were not processed) and `fails` (valid records that could not be processed) in the response.

## Contacts API

- **`400` on import**: the response lists each rejected field in `errors`, with the `index` of the record in your array, the rejected `value` and a `message`. `successRecord` is the number of records that were saved. Dates (`birthDate`, `memberShipDate`) must be in `DD.MM.YYYY` format.
- **`400` on export**: the `page` parameter is greater than `totalPages`. Read `totalPages` and `currentPage` from the previous response.
- **`429` Too Many Requests**: one request can carry 1000 records, and 100 successful requests are allowed per hour. More than 100 failed requests in an hour block the account for one hour.
- **Expired token**: the access token is valid for 2 hours and the refresh token for 4 hours. Send the refresh token to `POST /oauth2/token` with `grantType: "REFRESH_TOKEN"`.

## Still stuck

Send the Segmentify support team the request (method, URL without the API key or token, body) and the full response, with the time of the request.
