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

# Create Feed Configuration

> Set up an IMS inventory feed configuration for a dealership.

`POST /v1/ims/feeds`

<Warning>
  **AutoSnap-internal only.** This endpoint is restricted to AutoSnap admin clients. Customers must email AutoSnap support to onboard a new IMS feed; non-admin API keys receive `403 ADMIN_REQUIRED`.
</Warning>

Create a new IMS feed configuration. The system will poll the specified CSV file on SFTP every 60 seconds and import any changes into the `ims_vehicle` table.

Before creating, the endpoint validates that:

* The SFTP directory exists and contains the specified file
* The file was modified within the last 48 hours (provider must be actively pushing)
* No existing feed config exists for this dealership + provider combination

## Request Body

| Field                       | Type    | Required | Default | Description                                                                                                                                    |
| --------------------------- | ------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `api_key`                   | string  | Yes      | --      | Your API key                                                                                                                                   |
| `dealership_id`             | string  | Yes      | --      | Dealership public ID (e.g., `dlr_8cfc0b00a98b`)                                                                                                |
| `provider`                  | string  | Yes      | --      | IMS provider name. See supported providers below.                                                                                              |
| `ftp_path`                  | string  | Yes      | --      | Provider directory name on SFTP server (e.g., `vauto`, `firstlook`). This is the folder name under `/import/` where the provider pushes files. |
| `file_name`                 | string  | Yes      | --      | Exact CSV filename to monitor (e.g., `MP14015.csv`). Must exist in the `ftp_path` directory.                                                   |
| `dealer_identifier`         | string  | No       | `null`  | Dealer ID value within the CSV to filter rows. Required when multiple dealers share one CSV file (e.g., ProMax sends all dealers in one file). |
| `staleness_threshold_hours` | integer | No       | `48`    | Hours without a file update before an `ims.feed.stale` webhook fires.                                                                          |

### Supported Providers

| Provider        | Description            | FTP Directory   |
| --------------- | ---------------------- | --------------- |
| `vauto`         | vAuto                  | `vauto`         |
| `homenet`       | HomeNet                | `homenet`       |
| `vincue`        | VinCue                 | `vincue`        |
| `promax`        | ProMax                 | `promax`        |
| `maxdigital`    | MaxDigital / Firstlook | `firstlook`     |
| `inventoryplus` | InventoryPlus          | `inventoryplus` |
| `dealercenter`  | DealerCenter           | `dealercenter`  |
| `idms`          | IDMS                   | `idms`          |
| `ansira`        | Ansira                 | `ansira`        |

<Note>
  The `provider` field determines which field mapping is used to parse the CSV. The `ftp_path` field determines which directory on the SFTP server to look in. These may differ -- for example, MaxDigital uses `provider: "maxdigital"` but `ftp_path: "firstlook"`.
</Note>

## Example

```bash theme={null}
curl -X POST "https://api.autosnap.com/v1/ims/feeds" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "YOUR_API_KEY",
    "dealership_id": "dlr_8cfc0b00a98b",
    "provider": "vauto",
    "ftp_path": "vauto",
    "file_name": "MP14015.csv",
    "staleness_threshold_hours": 48
  }'
```

### Multi-dealer file example (ProMax)

When a provider sends all dealers in a single CSV, use `dealer_identifier` to filter:

```bash theme={null}
curl -X POST "https://api.autosnap.com/v1/ims/feeds" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "YOUR_API_KEY",
    "dealership_id": "dlr_abc123",
    "provider": "promax",
    "ftp_path": "promax",
    "file_name": "Preownedplus.csv",
    "dealer_identifier": "9553"
  }'
```

## Response

```json theme={null}
{
  "id": "ims_config_b9648b954a07",
  "status": "created"
}
```

The feed configuration is immediately active. The system polls SFTP every 60 seconds, checking for changes to the specified file.

<Warning>
  **The first import will not occur until the provider pushes a file.** Creating a feed config tells AutoSnap *where* to look — but if the provider hasn't sent the file yet, there is nothing to import. The 60-second polling means that once the file arrives, it will be picked up within a minute.

  To know when the first import completes, subscribe to the `ims.import.complete` webhook event **before** creating the feed config. This webhook fires as soon as the file is successfully parsed and all vehicles are imported. You can then call `GET /v1/ims/vehicles` to retrieve the inventory.

  If the file is already present on SFTP when you create the config (verified by the 48-hour freshness check), the first import will typically complete within 60 seconds.
</Warning>

## Errors

| Status | Detail                                      | Cause                                                                               |
| ------ | ------------------------------------------- | ----------------------------------------------------------------------------------- |
| `400`  | `No CSV files found in /import/{ftp_path}/` | The SFTP directory doesn't exist or is empty                                        |
| `400`  | `File '{file_name}' not found...`           | The specified file doesn't exist. Response includes a list of available files.      |
| `400`  | `File '{file_name}' is N days old...`       | The file hasn't been updated in over 48 hours. The provider isn't actively pushing. |
| `400`  | `Invalid provider`                          | Provider name not in the supported list                                             |
| `403`  | `Not authorized for this dealership`        | Your API key doesn't have access to this dealership                                 |
| `404`  | `Dealership not found`                      | Invalid or unknown dealership\_id                                                   |
| `409`  | `Feed config already exists...`             | A feed for this dealership + provider already exists                                |
| `502`  | `SFTP connection failed`                    | Could not connect to the SFTP server to validate the feed path and file             |


## OpenAPI

````yaml POST /v1/ims/feeds
openapi: 3.0.3
info:
  title: AutosnapAI Origin API
  description: Dealer resolution, inventory management, and webhook APIs
  version: 1.0.0
servers:
  - url: https://api.autosnap.com
    description: Production
security: []
paths:
  /v1/ims/feeds:
    post:
      tags:
        - ims
      summary: Create Feed Configuration
      description: >-
        Create a new IMS feed configuration. Validates that the file exists on
        SFTP and is less than 48 hours old.
      operationId: create_ims_feed
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeedConfigCreate'
      responses:
        '201':
          description: Feed created
          content:
            application/json:
              schema: {}
        '400':
          description: Validation error (file not found, stale, invalid provider)
        '403':
          description: Not authorized for this dealership
        '409':
          description: Feed config already exists for this dealership + provider
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    FeedConfigCreate:
      type: object
      required:
        - api_key
        - dealership_id
        - provider
        - ftp_path
        - file_name
      properties:
        api_key:
          type: string
          title: Api Key
        dealership_id:
          type: string
          title: Dealership Id
          description: Public ID (e.g. dlr_xxx) or internal ID
        provider:
          type: string
          title: Provider
          enum:
            - vauto
            - homenet
            - vincue
            - promax
            - maxdigital
            - inventoryplus
            - dealercenter
            - idms
            - ansira
        ftp_path:
          type: string
          title: FTP Path
          description: Provider directory name on SFTP (e.g. vauto, firstlook)
        file_name:
          type: string
          title: File Name
          description: Exact CSV filename on SFTP (e.g. MP14015.csv)
        dealer_identifier:
          type: string
          nullable: true
          title: Dealer Identifier
          description: Dealer ID within the CSV for multi-dealer files
        staleness_threshold_hours:
          type: integer
          title: Staleness Threshold Hours
          default: 48
      title: FeedConfigCreate
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````