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

# Create company with AI processing

> **The recommended way to create companies in Roulette.**

This intelligent endpoint accepts unstructured text (emails, notes, form data) and
file attachments, then uses AI to automatically:

1. **Extract URLs** from text using regex (handles long signed URLs from DocSend, Tally, etc.)
2. **Prioritize deck sources** by known platforms (DocSend, Papermark, Brieflink, Google Drive)
3. **Select the best pitch deck** from URLs or files
4. **Auto-detect company status** based on content context
5. **Auto-detect source** (email, referral, form, etc.) from content
6. **Upload remaining files** as attachments

## How It Works

### URL Priority (Highest → Lowest)
1. DocSend links
2. Papermark links
3. Brieflink links
4. Tally storage URLs
5. Google Drive links
6. Other URLs

### File Processing Logic
- **Single file**: Always treated as the pitch deck (regardless of type)
- **Multiple files**: AI analyzes PDF content to select the best deck candidate
- **Fallback**: First PDF file if AI can't determine

### Context Analysis
When text content is provided (>50 chars), the AI analyzes it to:
- Detect appropriate pipeline status based on conversation context
- Identify the source (email forward, referral mention, etc.)

## Use Cases

- **Email forwarding**: Paste the full email body + attachments
- **Form submissions**: Send form data as text + any uploaded files
- **Manual entry**: Provide company info + deck URL or file
- **Bulk import**: Process founder outreach emails automatically




## OpenAPI

````yaml openapi.json post /companies/upload/ai
openapi: 3.1.0
info:
  title: Roulette API
  version: 1.0.0
  description: >
    The Roulette API provides programmatic access to manage your VC deal flow,

    companies, contacts, and related data.


    ## Authentication


    All API requests require authentication using a Bearer token. Include your
    API key

    in the `Authorization` header:


    ```

    Authorization: Bearer YOUR_API_KEY

    ```


    You can generate API keys from your account settings in the Roulette
    dashboard.


    ## Rate Limiting


    API requests are rate limited to ensure fair usage. Current limits:

    - 1000 requests per minute per API key

    - 100 requests per second per API key


    Rate limit headers are included in all responses:

    - `X-RateLimit-Limit`: Maximum requests per window

    - `X-RateLimit-Remaining`: Requests remaining in current window

    - `X-RateLimit-Reset`: Unix timestamp when the window resets


    ## Pagination


    List endpoints support cursor-based pagination using the following query
    parameters:

    - `page`: Page number (default: 1)

    - `limit`: Items per page (default: 25, max: 100)


    Paginated responses include pagination metadata:

    ```json

    {
      "data": [...],
      "pagination": {
        "page": 1,
        "limit": 25,
        "has_next": true,
        "has_prev": false
      }
    }

    ```


    **Note**: For performance reasons, total counts (`total`, `total_pages`) are
    not included.

    Use `has_next` and `has_prev` to determine if more pages exist.


    ## Errors


    The API uses standard HTTP status codes and returns errors in a consistent
    format:


    ```json

    {
      "success": false,
      "error": "Human readable error message",
      "data": null
    }

    ```


    Common status codes:

    - `400` Bad Request - Invalid parameters or request body

    - `401` Unauthorized - Missing or invalid API key

    - `403` Forbidden - Valid API key but insufficient permissions

    - `404` Not Found - Resource not found

    - `429` Too Many Requests - Rate limit exceeded

    - `500` Internal Server Error - Server-side error
  termsOfService: https://www.useroulette.com/terms
  contact:
    name: Roulette API Support
    email: support@useroulette.com
    url: https://www.useroulette.com/support
  license:
    name: Proprietary
    url: https://www.useroulette.com/license
servers:
  - url: https://www.useroulette.com/api/v1
    description: Production server
  - url: http://localhost:3000/api/v1
    description: Local development server
security:
  - BearerAuth: []
tags:
  - name: Companies
    description: >
      Manage companies in your deal flow pipeline. Companies represent potential

      investment opportunities with associated pitch decks, contacts, and
      metadata.
  - name: Company Statuses
    description: |
      Manage deal flow stages/statuses for organizing companies through your
      investment pipeline (e.g., "Initial Review", "Due Diligence", "Closed").
  - name: Company Settings
    description: |
      Configure custom fields and settings for company tracking.
  - name: Contacts
    description: |
      Manage contacts associated with companies, including founders, executives,
      and other key personnel.
  - name: Form Submissions
    description: |
      Access form submissions from integrated platforms like Tally.
  - name: Emails
    description: |
      Manage emails linked to companies and contacts.
  - name: Meeting Minutes
    description: |
      Store and retrieve meeting notes and minutes related to companies.
  - name: Shared Links
    description: |
      Create and manage secure shareable links for company portfolios.
  - name: Integrations
    description: |
      Configure third-party integrations (Tally, Specter, etc.).
  - name: Investor Dashboard
    description: |
      Configure and manage investor-facing portfolio dashboards.
  - name: Dashboard
    description: |
      Access aggregated dashboard data and analytics.
  - name: Team Members
    description: |
      View team members and their roles within your account.
  - name: Short URLs
    description: |
      Create shortened URLs with optional password protection.
paths:
  /companies/upload/ai:
    post:
      tags:
        - Companies
      summary: Create company with AI processing
      description: >
        **The recommended way to create companies in Roulette.**


        This intelligent endpoint accepts unstructured text (emails, notes, form
        data) and

        file attachments, then uses AI to automatically:


        1. **Extract URLs** from text using regex (handles long signed URLs from
        DocSend, Tally, etc.)

        2. **Prioritize deck sources** by known platforms (DocSend, Papermark,
        Brieflink, Google Drive)

        3. **Select the best pitch deck** from URLs or files

        4. **Auto-detect company status** based on content context

        5. **Auto-detect source** (email, referral, form, etc.) from content

        6. **Upload remaining files** as attachments


        ## How It Works


        ### URL Priority (Highest → Lowest)

        1. DocSend links

        2. Papermark links

        3. Brieflink links

        4. Tally storage URLs

        5. Google Drive links

        6. Other URLs


        ### File Processing Logic

        - **Single file**: Always treated as the pitch deck (regardless of type)

        - **Multiple files**: AI analyzes PDF content to select the best deck
        candidate

        - **Fallback**: First PDF file if AI can't determine


        ### Context Analysis

        When text content is provided (>50 chars), the AI analyzes it to:

        - Detect appropriate pipeline status based on conversation context

        - Identify the source (email forward, referral mention, etc.)


        ## Use Cases


        - **Email forwarding**: Paste the full email body + attachments

        - **Form submissions**: Send form data as text + any uploaded files

        - **Manual entry**: Provide company info + deck URL or file

        - **Bulk import**: Process founder outreach emails automatically
      operationId: createCompanyWithAI
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/AiUploadRequest'
            examples:
              emailForward:
                summary: Forward a founder email
                value:
                  text: >
                    From: founder@startup.com

                    Subject: Intro - TechCo Series A


                    Hi, I'm the founder of TechCo. We're building AI tools for
                    developers.

                    Here's our deck: https://docsend.com/view/abc123


                    We're currently raising a $5M Series A.
                  account_id: 550e8400-e29b-41d4-a716-446655440000
              withFiles:
                summary: Upload with pitch deck file
                value:
                  text: Meeting notes from coffee chat with Jane from StartupXYZ
                  account_id: 550e8400-e29b-41d4-a716-446655440000
                  name: StartupXYZ
                  visibility: team
                  file_0: (binary)
              simpleCreate:
                summary: Simple company with deck URL
                value:
                  text: https://pitch.com/public/startup-deck-abc123
                  account_id: 550e8400-e29b-41d4-a716-446655440000
                  name: My Startup
      responses:
        '200':
          description: Company created successfully with AI analysis
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiUploadResponse'
              example:
                success: true
                data:
                  company:
                    id: 7c9e6679-7425-40de-944b-e07fc1f90ae7
                    account_id: 550e8400-e29b-41d4-a716-446655440000
                    name: TechCo
                    visibility: team
                    source: email
                    company_status_id: initial-review-uuid
                    notes: null
                    created_at: '2024-01-15T10:30:00Z'
                    updated_at: '2024-01-15T10:30:00Z'
                  pdfDownloadUrl: https://storage.useroulette.com/signed-url...
                  attachments:
                    - id: attach-uuid-1
                      title: Financial Model.xlsx
                      filePath: companies/7c9e6679/attachments/financial-model.xlsx
                      attachmentType: >-
                        application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
                  analysis:
                    detectedUrls:
                      - https://docsend.com/view/abc123
                    selectedDeckUrl: https://docsend.com/view/abc123
                    aiReasoning: >-
                      Selected DocSend URL as primary deck source (high priority
                      platform)
                    contextAnalysis:
                      statusDetected: true
                      statusReasoning: >-
                        Email mentions 'Series A raise' - assigned to
                        fundraising stage
                      sourceDetected: true
                      sourceReasoning: Content appears to be a forwarded email from founder
                    processedAt: '2024-01-15T10:30:00Z'
                authType: api_key
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    AiUploadRequest:
      type: object
      required:
        - text
        - account_id
      properties:
        text:
          type: string
          minLength: 1
          description: |
            Unstructured text content to process. Can include:
            - Full email body (with headers)
            - Form submission data
            - Meeting notes
            - URLs to pitch decks (DocSend, Google Drive, etc.)

            The AI will extract URLs and analyze context to determine
            company status and source automatically.
          example: |
            From: founder@startup.com
            Subject: TechCo - Series A Deck

            Hi, here's our pitch deck: https://docsend.com/view/abc123

            We're raising $5M at a $20M pre-money valuation.
        account_id:
          type: string
          format: uuid
          description: Account/team ID to create the company under
        name:
          type: string
          description: |
            Optional company name override. If not provided, the AI
            will attempt to extract it from the text or deck.
        visibility:
          type: string
          enum:
            - private
            - shared
            - team
          default: team
          description: Visibility level for the new company
        notes:
          type: string
          description: Optional internal notes
        company_status_id:
          type: string
          format: uuid
          description: |
            Optional status override. If not provided, the AI will
            attempt to detect an appropriate status from the content.
        source:
          type: string
          enum:
            - manual
            - email
            - form
            - referral
            - website
            - event
            - other
          description: |
            Optional source override. If not provided, the AI will
            attempt to detect the source from content context.
        metadata:
          type: object
          additionalProperties: true
          description: Optional custom metadata to merge with AI-extracted data
        file_0:
          type: string
          format: binary
          description: First file attachment (pitch deck or supporting document)
        file_1:
          type: string
          format: binary
          description: Second file attachment
        file_2:
          type: string
          format: binary
          description: Third file attachment
        file_3:
          type: string
          format: binary
          description: Fourth file attachment (up to 10 files supported via file_N pattern)
    AiUploadResponse:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          required:
            - company
            - attachments
            - analysis
          properties:
            company:
              $ref: '#/components/schemas/Company'
              description: The newly created company
            pdfDownloadUrl:
              type: string
              format: uri
              description: |
                Signed URL for downloading the pitch deck PDF.
                Only present if a deck was successfully processed and stored.
            attachments:
              type: array
              description: List of additional files uploaded as attachments
              items:
                $ref: '#/components/schemas/UploadedAttachment'
            analysis:
              $ref: '#/components/schemas/AiAnalysisResult'
        authType:
          type: string
          enum:
            - api_key
            - session
    Company:
      type: object
      required:
        - id
        - account_id
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the company
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        account_id:
          type: string
          format: uuid
          description: Account/team this company belongs to
          example: 11111111-2222-3333-4444-555555555555
        name:
          type: string
          description: Company name
          example: Acme Technologies
          maxLength: 255
        deck_link:
          type: string
          format: uri
          nullable: true
          description: URL to the pitch deck (external link or storage URL)
          example: https://docsend.com/view/example123
        deck_storage_path:
          type: string
          nullable: true
          description: Internal storage path for uploaded pitch deck
          example: companies/7c9e6679/deck.pdf
        visibility:
          type: string
          enum:
            - private
            - shared
            - team
          description: |
            Visibility level:
            - `private`: Only visible to the creator
            - `shared`: Visible to specific users via company_shared_access
            - `team`: Visible to all team members
          default: team
          example: team
        source:
          type: string
          enum:
            - manual
            - email
            - form
            - referral
            - website
            - event
            - other
          nullable: true
          description: How the company was added to the pipeline
          example: form
        source_content:
          type: string
          nullable: true
          description: |
            Raw source content when company was created from a form submission.
            Contains the original form field data in a serialized format.
          example: >-
            0:
            {"key":"question_wbB2ze","type":"INPUT_EMAIL","label":"Email","value":"founder@company.com"}
        notes:
          type: string
          nullable: true
          description: Internal notes about the company (not visible to the company)
          example: Met at TechCrunch Disrupt. Strong technical team.
        company_status_id:
          type: string
          format: uuid
          nullable: true
          description: Current deal flow status ID
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        company_status:
          nullable: true
          description: Embedded company status object (when joined)
          allOf:
            - $ref: '#/components/schemas/CompanyStatus'
        metadata:
          $ref: '#/components/schemas/CompanyMetadata'
        metadata_search_text:
          type: string
          nullable: true
          description: Flattened metadata for full-text search (auto-generated)
        assignees:
          type: array
          description: List of team members assigned to this company
          items:
            $ref: '#/components/schemas/Assignee'
          default: []
        created_by:
          type: string
          format: uuid
          nullable: true
          description: User ID who created this company record
          example: user-uuid-1234
        updated_by:
          type: string
          format: uuid
          nullable: true
          description: User ID who last updated this company record
          example: user-uuid-1234
        created_at:
          type: string
          format: date-time
          description: When the company was created
          example: '2024-01-15T10:30:00Z'
        updated_at:
          type: string
          format: date-time
          description: When the company was last updated
          example: '2024-01-15T12:45:00Z'
    UploadedAttachment:
      type: object
      description: An attachment uploaded during AI company creation
      properties:
        id:
          type: string
          format: uuid
          description: Attachment UUID
        title:
          type: string
          description: File name/title
          example: Financial Model.xlsx
        filePath:
          type: string
          description: Storage path for the file
          example: companies/7c9e6679/attachments/financial-model.xlsx
        attachmentType:
          type: string
          description: MIME type of the file
          example: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    AiAnalysisResult:
      type: object
      description: Details about the AI processing that occurred
      properties:
        detectedUrls:
          type: array
          items:
            type: string
            format: uri
          description: |
            All URLs extracted from the text content using regex.
            Includes signed URLs, short links, and deck platform URLs.
          example:
            - https://docsend.com/view/abc123
            - https://drive.google.com/file/d/xyz
        selectedDeckUrl:
          type: string
          format: uri
          description: |
            The URL that was selected as the primary pitch deck source.
            Only present if a URL was used (vs. uploaded file).
          example: https://docsend.com/view/abc123
        selectedDeckFile:
          type: string
          description: |
            Name of the file that was selected as the primary pitch deck.
            Only present if an uploaded file was used (vs. URL).
          example: Pitch Deck v2.pdf
        aiReasoning:
          type: string
          description: |
            Explanation of why the AI selected the particular deck source.
            Useful for debugging and understanding the selection logic.
          example: Selected DocSend URL as primary deck source (high priority platform)
        contextAnalysis:
          type: object
          description: Results of AI context analysis on the text content
          properties:
            statusDetected:
              type: boolean
              description: Whether a company status was auto-detected
            statusReasoning:
              type: string
              description: Explanation for the detected status
              example: Email mentions 'Series A raise' - assigned to fundraising stage
            sourceDetected:
              type: boolean
              description: Whether a source was auto-detected
            sourceReasoning:
              type: string
              description: Explanation for the detected source
              example: Content appears to be a forwarded email from founder
        processedAt:
          type: string
          format: date-time
          description: When the AI processing completed
          example: '2024-01-15T10:30:00Z'
    Error:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          description: Human-readable error message
          example: Invalid request body
        data:
          type: 'null'
          example: null
        authType:
          type: string
          enum:
            - api_key
            - session
          example: api_key
    CompanyStatus:
      type: object
      description: Deal flow pipeline status
      properties:
        id:
          type: string
          format: uuid
        status_text:
          type: string
          description: Display name of the status
          example: Initial Review
        color:
          type: string
          description: Hex color code
          example: '#3B82F6'
        rank:
          type: integer
          description: Order in pipeline (lower = earlier)
    CompanyMetadata:
      type: object
      description: >
        Custom metadata for the company. Contains AI-extracted data, founder
        info,

        and user-configurable custom fields.
      properties:
        founders:
          type: array
          description: >-
            Founder/team member information (typically AI-extracted from pitch
            deck)
          items:
            $ref: '#/components/schemas/Founder'
        ai_analysis:
          type: string
          nullable: true
          description: AI-generated company description/summary
          example: >-
            B2B SaaS platform providing enterprise workflow automation with
            AI-powered document processing.
        analyzed_at:
          type: string
          format: date-time
          nullable: true
          description: When the AI analysis was performed
          example: '2024-01-15T12:45:00Z'
        user_preferences:
          type: array
          description: Custom fields configured by the account for tracking company data
          items:
            $ref: '#/components/schemas/UserPreference'
      additionalProperties: true
    Assignee:
      type: object
      description: Team member assigned to a company
      properties:
        id:
          type: string
          format: uuid
          description: User ID of the assignee
        name:
          type: string
          nullable: true
          description: Display name
        email:
          type: string
          format: email
          nullable: true
          description: Email address
        picture_url:
          type: string
          format: uri
          nullable: true
          description: Profile picture URL
    Founder:
      type: object
      description: Information about a company founder or team member
      properties:
        name:
          type: string
          description: Full name
          example: Jane Smith
        email:
          type: string
          format: email
          nullable: true
          description: Email address
          example: jane@example.com
        phone:
          type: string
          nullable: true
          description: Phone number
          example: +1-555-123-4567
        title:
          type: string
          nullable: true
          description: Job title/role
          example: CEO/Co-Founder
        background:
          type: string
          nullable: true
          description: Professional background summary
          example: Former engineer at Google, 10 years in enterprise software
        linkedin_profile:
          type: string
          format: uri
          nullable: true
          description: LinkedIn profile URL
          example: https://www.linkedin.com/in/example/
    UserPreference:
      type: object
      description: |
        Custom field for tracking company data. Supports multiple field types:
        - `text`: Free-form text input
        - `boolean`: True/false toggle
        - `select`: Single selection from predefined options
      required:
        - type
        - field
      properties:
        type:
          type: string
          enum:
            - text
            - boolean
            - select
          description: Field type
          example: select
        field:
          type: string
          description: Field name/label
          example: Industry
        value:
          oneOf:
            - type: string
            - type: boolean
            - type: 'null'
          description: Current value (type depends on field type)
          example: AI/ML
        options:
          type: array
          items:
            type: string
          description: Available options (for select fields)
          example:
            - SaaS
            - Fintech
            - AI/ML
            - Developer Tools
        show_in_table:
          type: boolean
          description: Whether this field is displayed in the companies table view
          default: false
          example: true
  responses:
    BadRequestError:
      description: Bad request - invalid parameters or request body
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: Invalid request body
            data: null
    UnauthorizedError:
      description: Unauthorized - missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: Invalid or expired API key
            data: null
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: Internal server error
            data: null
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        API key authentication. Generate keys from your account settings.

        Include in header: `Authorization: Bearer YOUR_API_KEY`

````