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

# Create a Deal

> Submit a loan tape as an originator — initiate the upload, push your file, and mark the deal for review.

<Steps>
  <Step title="Initiate the Deal">
    Call `POST /originator/loans` with your loan type. The platform creates a new deal in `DRAFT` status and returns an upload URL valid for **1 hour**.

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

    > If a `DRAFT` deal already exists for the same loan type, it will be reused and a fresh URL returned.

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

      ```json Response theme={null}
      {
        "success": true,
        "data": {
          "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
        }
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="Upload the File">
    Use the `upload_url` from Step 1 to push your CSV or XLSX file. The URL routes through the platform gateway — include your `Authorization` header as with any other request.

    > The upload URL expires in **1 hour**. If it expires, call `PATCH /originator/loans/:dealId` to get a fresh one.
    >
    > `Content-Length` is required — S3 needs it to accept the stream.

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

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

  <Step title="Complete the Upload">
    Notify the platform that the file is ready. The gateway verifies the file, registers it, and transitions the deal to `IN_REVIEW`.

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

      ```json Response theme={null}
      {
        "success": true,
        "data": {
          "deal_id": "clx1a2b3c4d5e6f7g8h9",
          "deal_status": "IN_REVIEW"
        }
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="Check Deal Status">
    Poll the deal to track its progress through the review pipeline.

    **Deal status lifecycle:**

    | Status         | Meaning                                   |
    | -------------- | ----------------------------------------- |
    | `DRAFT`        | Upload URL issued, file not yet submitted |
    | `IN_REVIEW`    | File submitted, under platform review     |
    | `QC_COMPLETED` | Quality check passed                      |
    | `APPROVED`     | Deal approved for securitization          |
    | `REJECTED`     | Deal rejected — check reason in response  |

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

      ```json Response theme={null}
      {
        "success": true,
        "data": {
          "deal_id": "clx1a2b3c4d5e6f7g8h9",
          "status": "QC_COMPLETED"
        }
      }
      ```
    </CodeGroup>
  </Step>
</Steps>
