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

# Manage Data Source

> Manage your uploaded data sources with full CRUD operations. List, view details, access data, delete, and download your data sources.

<Note>
  All operations require authentication using Bearer tokens. Make sure you have
  your API credentials ready.
</Note>

## List All Data Sources

Retrieve a paginated list of all your uploaded data sources.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://secure-api.getclaro.ai/api/v2/datasources?page=1&limit=20" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```python Python theme={null}
  import requests

  headers = {"Authorization": "Bearer YOUR_API_KEY"}
  params = {"page": 1, "limit": 20}

  response = requests.get(
      "https://secure-api.getclaro.ai/api/v2/datasources",
      headers=headers,
      params=params
  )
  ```

  ```javascript JavaScript theme={null}
  const params = new URLSearchParams({
    page: 1,
    limit: 20,
  });

  const response = await fetch(
    `https://secure-api.getclaro.ai/api/v2/datasources?${params}`,
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
      },
    }
  );
  ```

  ```json Success Response theme={null}
  {
    "dataSources": [
      {
        "datasourceId": "550e8400-e29b-41d4-a716-446655440000",
        "fileName": "products.csv",
        "contentType": "text/csv",
        "fileSize": 245760,
        "status": "completed",
        "uploadedAt": "2024-03-14T15:30:00Z",
        "processedAt": "2024-03-14T15:32:00Z"
      },
      {
        "datasourceId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
        "fileName": "suppliers.pdf",
        "contentType": "application/pdf",
        "fileSize": 512000,
        "status": "processing",
        "uploadedAt": "2024-03-14T16:00:00Z",
        "processedAt": null
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 20,
      "total": 45,
      "totalPages": 3
    }
  }
  ```

  ```json Authentication Error theme={null}
  {
    "error": "Authentication required",
    "code": "UNAUTHORIZED",
    "details": {
      "message": "Bearer token missing or invalid"
    }
  }
  ```
</CodeGroup>

## Get Data Source Details

Retrieve detailed information about a specific data source.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://secure-api.getclaro.ai/api/v2/datasources/$DATASOURCE_ID" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```python Python theme={null}
  import requests

  headers = {"Authorization": "Bearer YOUR_API_KEY"}
  datasource_id = "your-datasource-id"  # Replace with your datasource ID

  response = requests.get(
      f"https://secure-api.getclaro.ai/api/v2/datasources/{datasource_id}",
      headers=headers
  )
  ```

  ```javascript JavaScript theme={null}
  const datasourceId = "your-datasource-id"; // Replace with your datasource ID

  const response = await fetch(
    `https://secure-api.getclaro.ai/api/v2/datasources/${datasourceId}`,
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
      },
    }
  );
  ```

  ```json Success Response theme={null}
  {
    "datasourceId": "550e8400-e29b-41d4-a716-446655440000",
    "fileName": "products.csv",
    "contentType": "text/csv",
    "fileSize": 245760,
    "status": "completed",
    "uploadedAt": "2024-03-14T15:30:00Z",
    "processedAt": "2024-03-14T15:32:00Z",
    "columns": [
      {
        "name": "product_id",
        "type": "string",
        "sampleValues": ["PROD001", "PROD002", "PROD003"]
      },
      {
        "name": "product_name",
        "type": "string",
        "sampleValues": ["Widget A", "Widget B", "Widget C"]
      },
      {
        "name": "price",
        "type": "number",
        "sampleValues": [29.99, 39.99, 49.99]
      }
    ],
    "rowCount": 1250,
    "processingStats": {
      "cleanedRows": 1250,
      "errors": 0,
      "warnings": 3
    }
  }
  ```

  ```json Not Found Error theme={null}
  {
    "error": "Data source not found",
    "code": "DATASOURCE_NOT_FOUND",
    "details": {
      "datasourceId": "invalid-uuid-format"
    }
  }
  ```
</CodeGroup>

## Get Data Source Data

Retrieve paginated data from a specific data source.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://secure-api.getclaro.ai/api/v2/datasources/$DATASOURCE_ID/data?page=1&limit=50" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```python Python theme={null}
  import requests

  headers = {"Authorization": "Bearer YOUR_API_KEY"}
  params = {"page": 1, "limit": 50}
  datasource_id = "your-datasource-id"  # Replace with your datasource ID

  response = requests.get(
      f"https://secure-api.getclaro.ai/api/v2/datasources/{datasource_id}/data",
      headers=headers,
      params=params
  )
  ```

  ```javascript JavaScript theme={null}
  const datasourceId = "your-datasource-id"; // Replace with your datasource ID
  const params = new URLSearchParams({
    page: 1,
    limit: 50,
  });

  const response = await fetch(
    `https://secure-api.getclaro.ai/api/v2/datasources/${datasourceId}/data?${params}`,
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
      },
    }
  );
  ```

  ```json Success Response theme={null}
  {
    "data": [
      {
        "product_id": "PROD001",
        "product_name": "Widget A",
        "price": 29.99,
        "category": "Electronics"
      },
      {
        "product_id": "PROD002",
        "product_name": "Widget B",
        "price": 39.99,
        "category": "Electronics"
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 50,
      "total": 1250,
      "totalPages": 25
    },
    "columns": [
      { "name": "product_id", "type": "string" },
      { "name": "product_name", "type": "string" },
      { "name": "price", "type": "number" },
      { "name": "category", "type": "string" }
    ]
  }
  ```

  ```json Processing Error theme={null}
  {
    "error": "Data source still processing",
    "code": "PROCESSING_IN_PROGRESS",
    "details": {
      "status": "processing",
      "estimatedCompletion": "2024-03-14T15:35:00Z"
    }
  }
  ```
</CodeGroup>

## Delete Data Source

Permanently delete a data source and all its associated data.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE "https://secure-api.getclaro.ai/api/v2/datasources/$DATASOURCE_ID" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```python Python theme={null}
  import requests

  headers = {"Authorization": "Bearer YOUR_API_KEY"}
  datasource_id = "your-datasource-id"  # Replace with your datasource ID

  response = requests.delete(
      f"https://secure-api.getclaro.ai/api/v2/datasources/{datasource_id}",
      headers=headers
  )
  ```

  ```javascript JavaScript theme={null}
  const datasourceId = "your-datasource-id"; // Replace with your datasource ID

  const response = await fetch(
    `https://secure-api.getclaro.ai/api/v2/datasources/${datasourceId}`,
    {
      method: "DELETE",
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
      },
    }
  );
  ```

  ```json Success Response theme={null}
  {
    "message": "Data source deleted successfully",
    "datasourceId": "550e8400-e29b-41d4-a716-446655440000",
    "deletedAt": "2024-03-14T16:45:00Z"
  }
  ```

  ```json Not Found Error theme={null}
  {
    "error": "Data source not found",
    "code": "DATASOURCE_NOT_FOUND",
    "details": {
      "datasourceId": "550e8400-e29b-41d4-a716-446655440000"
    }
  }
  ```
</CodeGroup>

## Generate Download URL

Generate a signed URL to download the original data source file.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://secure-api.getclaro.ai/api/v2/datasources/$DATASOURCE_ID/download" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"expiresIn": 3600}'
  ```

  ```python Python theme={null}
  import requests

  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }
  data = {"expiresIn": 3600}  # 1 hour
  datasource_id = "your-datasource-id"  # Replace with your datasource ID

  response = requests.post(
      f"https://secure-api.getclaro.ai/api/v2/datasources/{datasource_id}/download",
      headers=headers,
      json=data
  )
  ```

  ```javascript JavaScript theme={null}
  const datasourceId = "your-datasource-id"; // Replace with your datasource ID

  const response = await fetch(
    `https://secure-api.getclaro.ai/api/v2/datasources/${datasourceId}/download`,
    {
      method: "POST",
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        expiresIn: 3600, // 1 hour
      }),
    }
  );
  ```

  ```json Success Response theme={null}
  {
    "downloadUrl": "https://secure-api.getclaro.ai/download/550e8400-e29b-41d4-a716-446655440000?token=abc123...",
    "fileName": "products.csv",
    "expiresAt": "2024-03-14T17:45:00Z",
    "fileSize": 245760
  }
  ```

  ```json Not Found Error theme={null}
  {
    "error": "Data source not found",
    "code": "DATASOURCE_NOT_FOUND",
    "details": {
      "datasourceId": "550e8400-e29b-41d4-a716-446655440000"
    }
  }
  ```
</CodeGroup>

## Query Parameters

### List Data Sources

* `page` (integer): Page number (default: 1)
* `limit` (integer): Items per page (default: 20, max: 100)
* `status` (string): Filter by status (`processing`, `completed`, `failed`)
* `contentType` (string): Filter by content type (`text/csv`, `application/pdf`, etc.)

### Get Data Source Data

* `page` (integer): Page number (default: 1)
* `limit` (integer): Rows per page (default: 50, max: 1000)
* `sort` (string): Sort by column name (default: original order)
* `order` (string): Sort order (`asc` or `desc`, default: `asc`)
* `filter` (string): Filter expression (e.g., `price > 100`)

### Generate Download URL

* `expiresIn` (integer): URL expiration time in seconds (default: 3600, max: 86400)

## Error Codes

| Code                     | Description                       |
| ------------------------ | --------------------------------- |
| `UNAUTHORIZED`           | Authentication required           |
| `DATASOURCE_NOT_FOUND`   | Data source doesn't exist         |
| `PROCESSING_IN_PROGRESS` | Data source still being processed |
| `INVALID_PARAMETERS`     | Invalid query parameters          |
| `ACCESS_DENIED`          | Insufficient permissions          |

## Next Steps

<CardGroup cols={2}>
  <Card title="Upload Data Source" icon="upload" href="/api-reference/upload-datasource">
    Upload new data sources for cleaning and organization
  </Card>

  <Card title="Create Dataset" icon="database" href="/api-reference/create-dataset">
    Create datasets from your cleaned data sources
  </Card>
</CardGroup>
