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

# Export

> Export metadata for a specific data slice or the entire data connector, in JSON or CSV format.

## Request Body

| Field                      | Type                  | Description                                                                        |
|----------------------------|-----------------------|------------------------------------------------------------------------------------|
| `data_connector_name`      | `str`                 | Name of the data connector to export metadata from.                                |
| `dataslice_id`             | `Optional[str]`       | ID of the dataslice to export metadata from. If omitted, all data is included.     |
| `export_file_level`        | `bool`                | `True` for file-level export, `False` for chunk-level export.                      |
| `export_format`            | `Optional[ExportFormat]` | Desired export format: `json` or `csv` (e.g., `"json"`, `"csv"`).               |
| `selected_metadata_fields` | `Optional[List[str]]` | List of metadata fields to include in the export.                                  |

## Response

- **200**: Metadata exported successfully  
    - Returns: A streaming file response containing the exported metadata in the requested format.
- **500**: Internal Server Error

## Example

```json
{
  "data_connector_name": "example-connector",
  "dataslice_id": "abc123",
  "export_file_level": true,
  "export_format": "json",
  "selected_metadata_fields": ["field1", "field2"]
}
```



## OpenAPI

````yaml /deasy-openapi-stainless.yml post /dataslice/export/metadata
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: /rest/unstructured
security: []
paths:
  /dataslice/export/metadata:
    post:
      tags:
        - Data Slices
      summary: Export
      description: >-
        Export metadata for a specific data slice or the entire data connector,
        in JSON or CSV format.


        ## Request Body


        | Field                      | Type                  |
        Description                                                                       
        |

        |----------------------------|-----------------------|------------------------------------------------------------------------------------|

        | `data_connector_name`      | `str`                 | Name of the data
        connector to export metadata from.                                |

        | `dataslice_id`             | `Optional[str]`       | ID of the
        dataslice to export metadata from. If omitted, all data is included.    
        |

        | `export_file_level`        | `bool`                | `True` for
        file-level export, `False` for chunk-level export.                     
        |

        | `export_format`            | `Optional[ExportFormat]` | Desired export
        format: `json` or `csv` (e.g., `"json"`, `"csv"`).               |

        | `selected_metadata_fields` | `Optional[List[str]]` | List of metadata
        fields to include in the export.                                  |


        ## Response


        - **200**: Metadata exported successfully  
            - Returns: A streaming file response containing the exported metadata in the requested format.
        - **500**: Internal Server Error


        ## Example


        ```json

        {
          "data_connector_name": "example-connector",
          "dataslice_id": "abc123",
          "export_file_level": true,
          "export_format": "json",
          "selected_metadata_fields": ["field1", "field2"]
        }

        ```
      operationId: export_data_slice_dataslice_export_metadata_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExportDatasliceMetadataRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '403':
          description: Missing token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '500':
          description: >-
            Internal Server Error. An unexpected error occurred while processing
            the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
      security:
        - BasicAuth: []
        - BearerAuth: []
          UserIdAuth: []
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from unstructured import UnstructuredClient

            client = UnstructuredClient(
                username=os.environ.get("UNSTRUCTURED_USERNAME"),  # This is the default and can be omitted
                password=os.environ.get("UNSTRUCTURED_PASSWORD"),  # This is the default and can be omitted
            )
            response = client.data_slice.export(
                data_connector_name="data_connector_name",
            )
            print(response)
        - lang: JavaScript
          source: >-
            import UnstructuredClient from 'unstructured-sdk';


            const client = new UnstructuredClient({
              authMethod: 'My Auth Method',
              username: process.env['UNSTRUCTURED_USERNAME'], // This is the default and can be omitted
              password: process.env['UNSTRUCTURED_PASSWORD'], // This is the default and can be omitted
            });


            const response = await client.dataSlice.export({
            data_connector_name: 'data_connector_name' });


            console.log(response);
components:
  schemas:
    ExportDatasliceMetadataRequest:
      properties:
        data_connector_name:
          type: string
          title: Data Connector Name
        dataslice_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Dataslice Id
        export_file_level:
          type: boolean
          title: Export File Level
          default: false
        export_format:
          anyOf:
            - $ref: '#/components/schemas/ExportFormat'
            - type: 'null'
        selected_metadata_fields:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Selected Metadata Fields
      type: object
      required:
        - data_connector_name
      title: ExportDatasliceMetadataRequest
    HTTPError:
      properties:
        detail:
          type: string
          title: Detail
      type: object
      required:
        - detail
      title: HTTPError
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ExportFormat:
      type: string
      enum:
        - json
        - csv
      title: ExportFormat
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
    BearerAuth:
      type: http
      scheme: bearer
    UserIdAuth:
      type: apiKey
      in: header
      name: X-User-ID

````