> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cairhealth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Optimize X12 Claim Denials

> Processes X12 denials and returns associated claim IDs.

## Delivery

To receive results from this endpoint, you have two options: [Webhooks](../claims/webhook-delivery) or the [Poll Optimizer Runs](../claims/poll-claim-optimization) API.


## OpenAPI

````yaml POST /api/optimizer-x12-denials
openapi: 3.1.0
info:
  title: Cair Health APIs
  description: APIs for the Cair Health platform
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://forecaster.cairhealth.com
security:
  - bearerAuth: []
paths:
  /api/optimizer-x12-denials:
    post:
      description: Processes X12 denials and returns associated claim IDs.
      requestBody:
        description: >-
          EDI data and patient control numbers for processing. Should contain
          all 837s and 835s, and patient control numbers for the claims to
          optimize.
        content:
          application/json:
            schema:
              type: object
              properties:
                edi:
                  type: array
                  items:
                    type: string
                  description: >-
                    Array of EDI strings to be processed. Each string should be
                    either a valid 837 or 835 EDI transaction, with the ISA
                    headers included. The order of the edi strings does not
                    matter, but the Cair Optimizer will only process 837s for
                    which there exists a matching 835 somewhere else in the
                    request.
                patientControlNumbers:
                  type: array
                  items:
                    type: string
                  description: >-
                    Array of patient control numbers. Optional, only use if you
                    want to kick off the optimizer for only the claims with
                    these PCNs
              required:
                - edi
            example:
              edi:
                - EDI_STRING_1
                - EDI_STRING_2
              patientControlNumbers:
                - PCN12345
                - PCN67890
        required: true
      responses:
        '200':
          description: Array of objects containing data of processed claims.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                      description: >-
                        Unique identifier for the claim. The ID returned can be
                        used to poll for results using the [Poll Optimizer
                        Results](../claims/poll-claim-optimization) API. Output
                        can also be configured to be sent through webhooks using
                        [Webhook Delivery](../claims/webhook-delivery).
                    patientControlNumber:
                      type: string
                      description: >-
                        Control number assigned to the patient. This is
                        extracted from your EDI and is a unique identifier for
                        the claim.
                    apiStatus:
                      type: string
                      description: >-
                        Status of the API processing for the claim. Typically at
                        this point the response will be `PROCESSING_EDI`. Refer
                        to [API
                        Status](../claims/poll-claim-optimization#api-status-values)
                        for possible values
                    createdAt:
                      type: string
                      format: date-time
                      description: Timestamp when the claim was created
              example:
                - id: 1234abcd-56ef-78gh-90ij-klmnopqrstuv
                  patientControlNumber: '98765432'
                  apiStatus: PROCESSING_EDI
                  createdAt: '2025-04-07T19:00:00.000Z'
                - id: 5678wxyz-12ab-34cd-56ef-ghijklmnopqr
                  patientControlNumber: '12345678'
                  apiStatus: PROCESSING_EDI
                  createdAt: '2025-04-07T20:00:00.000Z'
        '401':
          description: Unauthorized access or invalid credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Invalid token or session expired
        '500':
          description: Server error or processing failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Failed to process EDI data. Please try again.
      security:
        - bearerAuth: []
components:
  schemas:
    Error:
      type: object
      properties:
        message:
          type: string
          description: Error message
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````