> ## 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.

# Get Transaction Input

> Stedi Core-compatible **Retrieve Transaction Input** — the raw artifact Cair originally received (typically the X12 EDI).

An authenticated call returns a `302 Found` whose `Location` header and `documentDownloadUrl` body point at a short-lived, presigned download URL. Follow that URL (with or without the `Authorization` header) to stream the artifact bytes; the presigned URL is valid for 60 minutes and is bound to your organization, the transaction, and the `input` usage. This two-step flow matches Stedi's document-download endpoints so existing Stedi SDKs work unchanged.

## Overview

Downloads the transaction's **input document** — the raw artifact Cair originally received, which is the X12 EDI file for `stedi`, `upload`, and `eob-conversion` transactions. This is a 1:1 drop-in for Stedi's [Retrieve Transaction Input](https://www.stedi.com/docs/healthcare/api-reference/get-transactions-input) operation and the Stedi SDK's `getTransactionInput`.

## Authentication

The **initial** request is authenticated with your JWT Bearer token from [`POST /api/token`](/api-reference/endpoint/token), with the `api-access` feature.

The **download** request that follows the redirect is authenticated by the presigned token in the URL and does **not** require the `Authorization` header.

## Path parameters

<ParamField path="transactionId" type="string" required>
  The `transactionId` whose input artifact you want to download.
</ParamField>

## Two-step download flow

Media downloads on Stedi are a redirect to a short-lived, presigned URL, and Cair reproduces that exactly:

1. **Authenticated request.** Call the endpoint with your Bearer token. Cair responds `302 Found` with:
   * `Location` header pointing at a presigned URL.
   * Body `{ "documentDownloadUrl": "<presigned URL>" }`.
2. **Follow the redirect.** Fetch the presigned URL — with or without the `Authorization` header — and Cair streams the raw artifact bytes with a `Content-Type` matching the artifact (for input documents this is usually `application/edi-x12`).

Most HTTP clients follow the `302` automatically, so a Stedi SDK or a `fetch` with the default `redirect: 'follow'` gets the bytes in one call. The presigned URL is valid for **60 minutes** and is bound to your organization, the transaction, and the `input` usage, so it cannot be replayed for another transaction or artifact kind.

<Note>
  The presigned URL is `https://forecaster.cairhealth.com/api/stedi/2023-08-01/transactions/{transactionId}/input?token=...`. Requests to it do not need (and ignore) the `Authorization` header; the `token` query parameter is what authorizes the download.
</Note>

## Example

Follow the redirect automatically with `curl -L`:

```bash theme={null}
curl -L "https://forecaster.cairhealth.com/api/stedi/2023-08-01/transactions/c1f2e3d4a5b6c7d8e9f0a1b2c3d4e5f6/input" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -o transaction.x12
```

Handle the two steps explicitly:

```ts theme={null}
const initial = await fetch(
  `https://forecaster.cairhealth.com/api/stedi/2023-08-01/transactions/${transactionId}/input`,
  {
    headers: { Authorization: `Bearer ${process.env.CAIR_ACCESS_TOKEN}` },
    redirect: 'manual',
  },
);

// 302 Found — read the presigned URL from the body (or the Location header)
const { documentDownloadUrl } = await initial.json();

// No Authorization header needed here
const artifact = await fetch(documentDownloadUrl);
const x12 = await artifact.text();
```

With the Stedi SDK, `getTransactionInput` follows the redirect for you and returns the bytes:

```ts theme={null}
const x12 = await stedi.core.getTransactionInput('c1f2e3d4a5b6c7d8e9f0a1b2c3d4e5f6');
```

## Response

`302 Found` — body:

```json theme={null}
{
  "documentDownloadUrl": "https://forecaster.cairhealth.com/api/stedi/2023-08-01/transactions/c1f2e3d4a5b6c7d8e9f0a1b2c3d4e5f6/input?token=6f1e2d3c4b5a69788796a5b4c3d2e1f0"
}
```

`200 OK` (after following the redirect) — the raw artifact, e.g.:

```text theme={null}
ISA*00*          *00*          *ZZ*SUBMITTER      *ZZ*RECEIVER       *261005*1412*^*00501*000000042*0*P*:~
GS*HP*SUBMITTER*RECEIVER*20261005*1412*1*X*005010X221A1~
...
```

## Errors

| Status | Meaning |
| :- | :- |
| `401` | Missing/invalid Bearer token on the initial call, or an invalid/expired presigned token. |
| `404` | Transaction or input artifact not found, or not owned by your organization. |


## OpenAPI

````yaml GET /api/stedi/2023-08-01/transactions/{transactionId}/input
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/stedi/2023-08-01/transactions/{transactionId}/input:
    get:
      summary: Get a transaction's input document
      description: >-
        Stedi Core-compatible **Retrieve Transaction Input** — the raw artifact
        Cair originally received (typically the X12 EDI).


        An authenticated call returns a `302 Found` whose `Location` header and
        `documentDownloadUrl` body point at a short-lived, presigned download
        URL. Follow that URL (with or without the `Authorization` header) to
        stream the artifact bytes; the presigned URL is valid for 60 minutes and
        is bound to your organization, the transaction, and the `input` usage.
        This two-step flow matches Stedi's document-download endpoints so
        existing Stedi SDKs work unchanged.
      operationId: stediGetTransactionInput
      parameters:
        - name: transactionId
          in: path
          required: true
          description: >-
            Unique identifier of the processed transaction (the `transactionId`
            returned by the list/poll endpoints).
          schema:
            type: string
      responses:
        '200':
          description: >-
            Raw input artifact bytes, returned when the presigned URL is
            followed. `Content-Type` matches the artifact (e.g.
            `application/edi-x12`).
          content:
            application/edi-x12:
              schema:
                type: string
                format: binary
            application/json:
              schema:
                type: object
            application/octet-stream:
              schema:
                type: string
                format: binary
        '302':
          description: >-
            Redirect to the presigned artifact URL. Clients should follow
            `Location` (SDKs follow redirects automatically).
          headers:
            Location:
              description: Presigned download URL containing the artifact token.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StediArtifactRedirect'
              example:
                documentDownloadUrl: >-
                  https://forecaster.cairhealth.com/api/stedi/2023-08-01/transactions/c1f2e3d4a5b6c7d8e9f0a1b2c3d4e5f6/input?token=6f1e2d3c4b5a69788796a5b4c3d2e1f0
        '401':
          description: Missing/invalid token, or expired token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StediError'
        '404':
          description: >-
            Transaction or artifact not found, or not owned by your
            organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StediError'
        '500':
          description: Unexpected server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StediError'
      security:
        - bearerAuth: []
components:
  schemas:
    StediArtifactRedirect:
      type: object
      description: Body of the `302` redirect returned by the artifact endpoints.
      required:
        - documentDownloadUrl
      properties:
        documentDownloadUrl:
          type: string
          description: >-
            Short-lived (60 minute) presigned URL. Follow it to download the
            artifact bytes.
    StediError:
      type: object
      description: Stedi-compatible error envelope.
      required:
        - message
      properties:
        message:
          type: string
          description: Human-readable error message.
        code:
          type: string
          description: Stedi error code.
          enum:
            - BadRequestException
            - UnauthorizedException
            - AccessDeniedException
            - ResourceNotFoundException
            - UnprocessableEntityException
            - ServiceException
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.