> ## 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.

# Create

> Create a new data slice based on specified conditions.

## Request Body

| Field             | Type           | Description                                                                |
|-------------------|----------------|----------------------------------------------------------------------------|
| `dataslice_name`  | `str`          | The name to assign to the newly created data slice.                        |
| `condition`       | `Optional[List[Dict]]` | (Legacy) List of file qualifying conditions.                         |
| `condition_new`   | `Optional[Any]` | New format: advanced file qualifying conditions.                           |
| `description`     | `Optional[str]` | Description of the data slice.                                             |
| `status`          | `str`          | The status of the data slice (e.g., active).                               |
| `data_points`     | `Optional[int]` | Number of data points in the data slice.                                   |
| `latest_taxonomy`    | `Optional[Dict]` | Most recent taxonomy reference/metadata.                                      |
| `taxonomy_id`        | `Optional[str]` | ID of the related taxonomy, if applicable.                                    |
| `data_connector_name` | `str`      | Name of the data connector (vector database profile).                      |
| `parent_dataslice_id` | `Optional[str]` | (Optional) Parent data slice ID, for lineage.                        |

## Response

- **201**: Data slice created successfully  
    - Returns: `{ "dataslice_id": "<uuid>" }`
- **500**: Internal Server Error.

## Example

```json
{
  "dataslice_name": "Customer Purchases Q2",
  "condition": [
    { "field": "created_date", "op": "gte", "value": "2024-04-01" }
  ],
  "description": "Purchase data from Q2 2024",
  "status": "active",
  "data_points": 4000,
  "data_connector_name": "prod-warehouse"
}
```



## OpenAPI

````yaml /deasy-openapi-stainless.yml post /dataslice/create
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: /rest/unstructured
security: []
paths:
  /dataslice/create:
    post:
      tags:
        - Data Slices
      summary: Create
      description: >-
        Create a new data slice based on specified conditions.


        ## Request Body


        | Field             | Type           |
        Description                                                               
        |

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

        | `dataslice_name`  | `str`          | The name to assign to the newly
        created data slice.                        |

        | `condition`       | `Optional[List[Dict]]` | (Legacy) List of file
        qualifying conditions.                         |

        | `condition_new`   | `Optional[Any]` | New format: advanced file
        qualifying conditions.                           |

        | `description`     | `Optional[str]` | Description of the data
        slice.                                             |

        | `status`          | `str`          | The status of the data slice
        (e.g., active).                               |

        | `data_points`     | `Optional[int]` | Number of data points in the
        data slice.                                   |

        | `latest_taxonomy`    | `Optional[Dict]` | Most recent taxonomy
        reference/metadata.                                      |

        | `taxonomy_id`        | `Optional[str]` | ID of the related taxonomy,
        if applicable.                                    |

        | `data_connector_name` | `str`      | Name of the data connector
        (vector database profile).                      |

        | `parent_dataslice_id` | `Optional[str]` | (Optional) Parent data slice
        ID, for lineage.                        |


        ## Response


        - **201**: Data slice created successfully  
            - Returns: `{ "dataslice_id": "<uuid>" }`
        - **500**: Internal Server Error.


        ## Example


        ```json

        {
          "dataslice_name": "Customer Purchases Q2",
          "condition": [
            { "field": "created_date", "op": "gte", "value": "2024-04-01" }
          ],
          "description": "Purchase data from Q2 2024",
          "status": "active",
          "data_points": 4000,
          "data_connector_name": "prod-warehouse"
        }

        ```
      operationId: create_dataslice_route_dataslice_create_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatasliceRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateDatasliceResponse'
        '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
            )
            data_slice = client.data_slice.create(
                data_connector_name="data_connector_name",
                dataslice_name="dataslice_name",
            )
            print(data_slice.dataslice_id)
        - 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 dataSlice = await client.dataSlice.create({
              data_connector_name: 'data_connector_name',
              dataslice_name: 'dataslice_name',
            });

            console.log(dataSlice.dataslice_id);
components:
  schemas:
    CreateDatasliceRequest:
      properties:
        dataslice_name:
          type: string
          title: Dataslice Name
        condition:
          anyOf:
            - $ref: '#/components/schemas/Condition-Input'
            - type: 'null'
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        status:
          type: string
          title: Status
          default: active
        data_points:
          anyOf:
            - type: integer
            - type: 'null'
          title: Data Points
        latest_taxonomy:
          anyOf:
            - type: object
            - type: 'null'
          title: Latest Taxonomy
        taxonomy_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Taxonomy Id
        data_connector_name:
          type: string
          title: Data Connector Name
        parent_dataslice_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Dataslice Id
      type: object
      required:
        - dataslice_name
        - data_connector_name
      title: CreateDatasliceRequest
    CreateDatasliceResponse:
      properties:
        dataslice_id:
          type: string
          title: Dataslice Id
      type: object
      required:
        - dataslice_id
      title: CreateDatasliceResponse
    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
    Condition-Input:
      properties:
        condition:
          anyOf:
            - $ref: '#/components/schemas/LogicCondition'
            - type: 'null'
        children:
          anyOf:
            - items:
                $ref: '#/components/schemas/Condition-Input'
              type: array
            - type: 'null'
          title: Children
        tag:
          anyOf:
            - $ref: '#/components/schemas/BaseTag'
            - type: 'null'
      type: object
      title: Condition
    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
    LogicCondition:
      type: string
      enum:
        - AND
        - OR
      title: LogicCondition
    BaseTag:
      properties:
        name:
          type: string
          title: Name
        values:
          items:
            anyOf:
              - type: string
              - type: number
              - type: integer
          type: array
          title: Values
          default: []
        operator:
          anyOf:
            - type: string
            - type: 'null'
          title: Operator
          default: any
      type: object
      required:
        - name
      title: BaseTag
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
    BearerAuth:
      type: http
      scheme: bearer
    UserIdAuth:
      type: apiKey
      in: header
      name: X-User-ID

````