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

# Bulk Loan Upload

> Submit multiple loan tapes in a single job with per-deal upload URLs and independent status tracking.

<Steps>
  <Step title="Initiate a Bulk Upload Job">
    Send an array of loan type entries. Each deal is created in `DRAFT` status with its own upload URL valid for **1 hour**.

    **Supported loan types:** `Auto`, `Personal`, `Mortgage`, `Student`, `Business`, `Credit Card`

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST https://api.9squid.com/v1/api/originator/loans/bulk \
        -H "Authorization: Bearer <your_token>" \
        -H "Content-Type: application/json" \
        -d '[
          { "type": "Auto" },
          { "type": "Mortgage" }
        ]'
      ```

      ```json Response theme={null}
      {
        "success": true,
        "data": {
          "bulk_job_id": "clxbulk987654",
          "files": [
            {
              "deal_id": "clx1a2b3c4d5e6f7g8h9",
              "upload_url": "https://api.9squid.com/v1/api/originator/loans/upload?u=<token>",
              "file_name": "loan-tape-abc123.upload",
              "expires_in": 3600
            },
            {
              "deal_id": "clx9z8y7x6w5v4u3t2s1",
              "upload_url": "https://api.9squid.com/v1/api/originator/loans/upload?u=<token>",
              "file_name": "loan-tape-def456.upload",
              "expires_in": 3600
            }
          ]
        }
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="Upload Each File">
    Upload each file to its corresponding `upload_url`. The URL routes through the platform gateway — include your `Authorization` header and `Content-Length` as with any other request.

    Upload all files before calling complete. Any deal without an uploaded file will fail validation.

    > Upload URLs expire in **1 hour**. Call `PATCH /originator/loans/bulk/:jobId` to regenerate fresh URLs for all DRAFT deals in the job.

    <CodeGroup>
      ```bash cURL theme={null}
      # Auto loan tape
      curl -X PUT "<upload_url_for_auto>" \
        -H "Authorization: Bearer <your_token>" \
        -H "Content-Length: <file_size_in_bytes>" \
        --data-binary @auto-loans-q2.csv

      # Mortgage loan tape
      curl -X PUT "<upload_url_for_mortgage>" \
        -H "Authorization: Bearer <your_token>" \
        -H "Content-Length: <file_size_in_bytes>" \
        --data-binary @mortgage-loans-q2.csv
      ```

      ```json Response theme={null}
      {
        "success": true,
        "file_path": "upload/documents/deals/clx1a2b3c4d5e6f7g8h9/loan-tape-abc123.upload"
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="Complete the Bulk Job">
    Pass each `deal_id` and `file_name` from Step 1. The gateway fetches file metadata, registers each file, and marks all deals as `IN_REVIEW`.

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST https://api.9squid.com/v1/api/originator/loans/bulk/complete \
        -H "Authorization: Bearer <your_token>" \
        -H "Content-Type: application/json" \
        -d '{
          "bulk_job_id": "clxbulk987654",
          "loans": [
            { "deal_id": "clx1a2b3c4d5e6f7g8h9", "file_name": "loan-tape-abc123.upload" },
            { "deal_id": "clx9z8y7x6w5v4u3t2s1", "file_name": "loan-tape-def456.upload" }
          ]
        }'
      ```

      ```json Response theme={null}
      {
        "success": true,
        "data": {
          "bulk_job_id": "clxbulk987654",
          "results": [
            { "deal_id": "clx1a2b3c4d5e6f7g8h9", "deal_status": "IN_REVIEW" },
            { "deal_id": "clx9z8y7x6w5v4u3t2s1", "deal_status": "IN_REVIEW" }
          ]
        }
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="Poll Bulk Job Status">
    | Bulk Status  | Meaning                                         |
    | ------------ | ----------------------------------------------- |
    | `PROCESSING` | Files submitted, deals being validated          |
    | `COMPLETED`  | All deals processed — check individual statuses |
    | `PARTIAL`    | Some deals failed validation                    |

    <CodeGroup>
      ```bash cURL theme={null}
      curl https://api.9squid.com/v1/api/originator/loans/bulk/clxbulk987654 \
        -H "Authorization: Bearer <your_token>"
      ```

      ```json Response theme={null}
      {
        "success": true,
        "data": {
          "bulk_job_id": "clxbulk987654",
          "deals": [
            { "deal_id": "clx1a2b3c4d5e6f7g8h9", "deal_status": "QC_COMPLETED" },
            { "deal_id": "clx9z8y7x6w5v4u3t2s1", "deal_status": "IN_REVIEW" }
          ]
        }
      }
      ```
    </CodeGroup>
  </Step>
</Steps>
