# Query Services Status Codes

The Query Services APIs return standard HTTP status codes to indicate the success or failure of a request. This document provides details about the status codes and their meanings.

## Status Codes

| Status Code              | Description          | Details                                                                                                 |
| ------------------------ | -------------------- | ------------------------------------------------------------------------------------------------------- |
| 200 OK                   | Request successful   | The request was processed successfully and the response contains the requested data.                    |
| 400 Bad Request          | Invalid request      | The request was malformed or contained invalid parameters. Check the request syntax and parameters.     |
| 403 Forbidden            | Authorization failed | The request failed to pass authorization. Verify your authentication credentials and permissions.       |
| 404 Not Found            | Resource not found   | The requested resource (callback ID, verification key, or both) was not found.                          |
| 422 Unprocessable Entity | Invalid attribute    | The attribute name used in fields/filter parameter doesn't exist. Verify the field names in your query. |
| 429 Too Many Requests    | Rate limit exceeded  | Too many requests were made in a given time period.                                                     |
| 500 Server Error         | Internal error       | An unexpected error occurred on the server. Contact support if the issue persists.                      |

## Error Response Structure

When an error occurs, the response includes:

- `error`: Error message describing the issue
- `errorCode`: Unique identifier for the error type
- `details`: Additional information about the error (if available)

## Examples

The following are examples of error code request and responses.

### 400 Bad Request

```json
{
  "error": "Invalid SQL query syntax",
  "errorCode": "INVALID_SQL",
  "details": "Syntax error at line 1: unexpected token 'FROM'"
}
```

### 403 Forbidden

```json
{
  "error": "Insufficient permissions",
  "errorCode": "FORBIDDEN",
  "details": "User does not have permission to access this resource"
}
```

### 429 Too Many Requests

```json
{
  "error": "Rate limit exceeded",
  "errorCode": "RATE_LIMIT",
  "details": "Rate limit exceeded for this organization"
}
```

## Notes

- All error responses are in JSON format
- Error messages are designed to be human-readable
- The `errorCode` field can be used for programmatic error handling
- Rate limits are enforced per organization

## Related Resources

- [Query API Documentation](/docs/data/data-cloud-query-guide/references/data-cloud-query-api-reference/c360a-api-queryservices-overview.md)
- [Data Cloud Query Guide](https://developer.salesforce.com/docs/data/data-cloud-query-guide/guide/query-guide-get-started.md)
