# Fare Class Error Handling

- If the request has an error, the response includes the content of the request along with the error message.

- If a request comprises multiple domains—for example, Fare Class Control, Fare Class Detail, Work Unit, and Batch—all domains must pass the Level 0 and Level 1 edits and cross-edits published in the Edits and Cross Edits document. If any field fails validation, the entire request fails.

- If a fare class cannot be created—for example, because it already exists in the rule—the caller receives an error, and the response displays the original request parameters.

- If a runtime error exception occurs, the request is not redisplayed. The server returns a runtime error message with HTTP status 500.

## HTTP Status Codes

The API returns different HTTP status codes depending on where an error occurs during request processing:

- **422 Unprocessable Entity** — Returned when a request fails field-level or cross-field (Level 0/Level 1) validation, as described in [Field-Level Validation Messages](#field-level-validation-messages-selected-examples) and the Edits and Cross Edits document. This includes validation of Batch Domain fields, such as an invalid `batchId` format or a `batchId` that cannot be found.

- **403 Forbidden** — Returned only after a request has passed field-level and cross-field validation, when the PASS (Partner Security) check described in [Security](https://devportal.atpco.net/content-management/default/fare-class-security) determines that the requesting organization is not authorized to perform the operation on behalf of the specified owning carrier.

  Example:

  ```json
  {
    "ErrorCode": 403,
    "ErrorDescription": "You are not authorized to perform this operation."
  }
  ```

PASS checks are performed on requests that:

- Create a new fare class sequence
- Discontinue/cancel a distributed sequence (`actionCode: "X"`)
- Update a sequence’s Construction fields (`actionCode: "C"`)

They are not performed as part of field-level or batch validation. A request that fails validation at that stage returns a 422, regardless of whether the requester is ultimately authorized for the operation.

## Field-Level Validation Messages (Selected Examples)

| Field Name | Condition | Message Returned to Caller |
|---|---|---|
| `carrier` | Invalid carrier code (G01) or missing. | `[field name] - Request argument has invalid value and/or format` / `Field is required in this request` |
| `ageMin` / `ageMax` | Value outside `00–99` (minimum) or `01–99` (maximum), or `ageMax` is less than `ageMin`. | `[field name] - Request argument has invalid value and/or format` |
| `tvlEff` / `tktEff` / `rsvEff` | Invalid date format, or, for non-EDOT dates, the date is not greater than the current date. | `[field name] - Date must be today or greater` |
| `tvlDisc` / `tktDisc` / `rsvDisc` | Discontinue date is earlier than the corresponding effective date. | `[field name] - must be equal to or greater than the corresponding effective date field` |
| `txt` (996 Note Text) | Contains characters other than hyphen, period, or slash, or exceeds 33 characters per line. | `[field name] The only valid special characters allowed are dash (-), period (.) or slash (/)` |

*See the current Edits and Cross Edits workbook for the complete, authoritative set of field-level and cross-field edits. It is updated more frequently than this guide.*
