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

# Get Import Rows

> Retrieve paginated rows from an import session with filtering and sorting

# Get Import Rows

Retrieve the parsed and validated rows of an import session. Supports pagination, error-only filtering, column sorting, and cascading column filters for building review UIs.

## Request

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

### Path Parameters

<ParamField path="import_id" type="string" required>
  UUID of the import session

  **Example:** `"11111111-1111-1111-1111-111111111111"`
</ParamField>

### Query Parameters

<ParamField query="page" type="integer" default="1">
  Page number (1-indexed)
</ParamField>

<ParamField query="page_size" type="integer" default="50">
  Rows per page (1–500)
</ParamField>

<ParamField query="errors_only" type="boolean" default="false">
  When `true`, only return rows with validation errors
</ParamField>

<ParamField query="sort_by" type="string">
  Column key to sort by. Must match `[a-zA-Z0-9_]+`.

  **Example:** `sort_by=weight`
</ParamField>

<ParamField query="sort_direction" type="string">
  Sort direction: `asc` or `desc`. Only used when `sort_by` is set.
</ParamField>

<ParamField query="filters" type="string">
  JSON-encoded object mapping column keys to arrays of allowed values. AND across columns, IN within a column.

  **Example:** `filters={"country":["Spain","France"],"fuel":["diesel"]}`

  Limits: max 20 filter keys, 500 values per key.
</ParamField>

## Response

<ResponseField name="import_id" type="string">
  UUID of the import session
</ResponseField>

<ResponseField name="rows" type="array[object]">
  Paginated row data

  <Expandable title="Row Object">
    <ResponseField name="row_index" type="integer">
      Zero-based index of the row in the original file
    </ResponseField>

    <ResponseField name="data" type="object">
      Row data keyed by target column name
    </ResponseField>

    <ResponseField name="errors" type="object">
      Validation errors keyed by column. Each value is an array of `{rule, params, message}` objects.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="page" type="integer">
  Current page number
</ResponseField>

<ResponseField name="page_size" type="integer">
  Rows per page
</ResponseField>

<ResponseField name="total_pages" type="integer">
  Total number of pages
</ResponseField>

<ResponseField name="total_rows" type="integer">
  Total row count (respects `errors_only` and `filters`)
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/v2/imports/11111111-1111-1111-1111-111111111111/rows?page=1&page_size=20&errors_only=true&sort_by=weight&sort_direction=asc" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}"
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import requests
  import os

  headers = {
      "x-api-key": os.getenv("DCYCLE_API_KEY"),
      "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
  }

  import_id = "11111111-1111-1111-1111-111111111111"

  response = requests.get(
      f"https://api.dcycle.io/v2/imports/{import_id}/rows",
      headers=headers,
      params={
          "page": 1,
          "page_size": 20,
          "errors_only": True,
          "sort_by": "weight",
          "sort_direction": "asc",
      },
  )

  result = response.json()
  print(f"Showing {len(result['rows'])}/{result['total_rows']} error rows")
  for row in result["rows"]:
      print(f"  Row {row['row_index']}: {list(row['errors'].keys())}")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  const headers = {
    'x-api-key': process.env.DCYCLE_API_KEY,
    'x-organization-id': process.env.DCYCLE_ORG_ID,
  };

  const importId = '11111111-1111-1111-1111-111111111111';

  axios.get(`https://api.dcycle.io/v2/imports/${importId}/rows`, {
    headers,
    params: { page: 1, page_size: 20, errors_only: true, sort_by: 'weight', sort_direction: 'asc' },
  }).then(response => {
    const { rows, total_rows } = response.data;
    console.log(`${rows.length}/${total_rows} error rows`);
    rows.forEach(r => console.log(`  Row ${r.row_index}: ${Object.keys(r.errors)}`));
  });
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "import_id": "11111111-1111-1111-1111-111111111111",
  "rows": [
    {
      "row_index": 14,
      "data": {
        "origin": "Valencia",
        "destination": "Sevilla",
        "weight": "abc",
        "vehicle_type": "van",
        "date": "2024-03-16"
      },
      "errors": {
        "weight": [
          {
            "rule": "type_numeric",
            "params": {"value": "abc"},
            "message": "Expected a numeric value"
          }
        ]
      }
    }
  ],
  "page": 1,
  "page_size": 20,
  "total_pages": 1,
  "total_rows": 3
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}
```

### 403 Forbidden

**Cause:** The authenticated user is not a member of the organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}
```

### 404 Not Found

**Cause:** The import session does not exist or belongs to another organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Not Found"}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Patch Rows" icon="pen-to-square" href="/api-reference/imports/patch-rows">
    Fix validation errors in specific rows
  </Card>

  <Card title="Validate Import" icon="circle-check" href="/api-reference/imports/validate">
    Run validation on mapped rows
  </Card>
</CardGroup>
