# Preview source original file

Preview the original files associated with the knowledge base as a binary stream.

```text
GET $CLOUDSIGMA_API_BASE/semantic-models/{model_id}/sources/file/{file_id}/preview
```

## Before you call this API

Configure the [regional API endpoint and authentication](https://omnifabric.cloudsigma.com/docs/developer/endpoints-and-authentication.html.md), and select the target workspace.

`file_id` is the file ID of the original source file, not `row_id` in [query data source list](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/knowledge-bases/list-data-sources.html.md)].

## Request example

```bash
curl -L "$CLOUDSIGMA_API_BASE/semantic-models/$MODEL_ID/sources/file/$FILE_ID/preview" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -o preview.bin
```

## Successful response

Returns `200` and a file binary stream on success, without using a JSON response envelope.

| Header | Description |
| --- | --- |
| `Content-Type` | File MIME type; `application/octet-stream` if not recognized. |
| `Content-Disposition` | Returns the inline preview file name if there is one. |

Office files may be returned converted to PDF; ZIP source files may be returned with their Markdown content. So the response should be handled based on the actual `Content-Type`.

## Common mistakes

| HTTP Status Codes | Error Codes | Common Causes | Recommended Actions |
| --- | --- | --- | --- |
| `400` | `ErrParamInvalid` | `model_id` or `file_id` are not valid. | Use a non-empty file ID with no leading or trailing whitespace. |
| `403` | `ErrForbidden` | Does not have read permission for the target knowledge base. | Check workspace and knowledge base authorizations. |
| `404` | `ErrNotFound` | The file does not belong to a source accessible to this knowledge base. | Confirm the knowledge base ID and source document ID. |

## Follow-up operations

When you need to read segmentation, version and structured document information, use [Query document details](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/knowledge-bases/get-document.html.md) instead.
