# Custom Types Support in Rudder CLI

{{< youtube zrSLXb7r7-I >}}<br />

Building on our recent [Custom Types]({{< ref "releases/custom-types.md" >}}) release, you can now define Custom Types directly in your workspace configuration files and deploy them using [Rudder CLI]({{< ref "dev-tools/rudder-cli/" >}}). This enhancement brings Custom Types into your existing infrastructure-as-code workflows, enabling you to version control and programmatically manage complex data validation rules.

With workspace config and CLI support, you can now:

- **Define Custom Types as code**: Create a `custom-types.yaml` file alongside your existing Tracking Plan configurations, enabling version control and collaborative development of data governance rules.
- **Reference Custom Types in properties**: Use Custom Types as property types in your `properties.yaml` files, eliminating the need to redefine complex validation logic across multiple properties.
- **Deploy via CLI**: Use the `rudderstack tp apply` command to push Custom Types and their associated properties to your workspace, integrating seamlessly with your existing deployment workflows.

{{< success >}}
This release complements the existing [Data Catalog API]({{< ref "api/data-catalog-api/" >}}) and [Git-Based Data Catalog and Tracking Plan Management]({{< ref "dev-tools/rudder-cli/data-catalog-and-tracking-plans/" >}}), giving development teams full flexibility in how they manage data governance across their organization.
{{< /success>}}

## Get started

1. **Create a workspace config file**: Add `custom-types.yaml` to your Tracking Plan directory alongside your existing configuration files. 
2. **Define your Custom Types**: Define your custom type rules.
3. **Reference your Custom Types**: In your `properties.yaml` file, you can define a property that references your previously defined custom types.
4. **Validate and Deploy with CLI**: Use the [Rudder CLI]({{< ref "dev-tools/rudder-cli/" >}}) tool to validate the YAML configurations and apply changes to your workspace.

See the [Use Custom Data Types in Rudder CLI]({{< ref "dev-tools/rudder-cli/data-catalog-and-tracking-plans/data-catalog/custom-types.md" >}}) guide for more details on creating and managing custom types using Rudder CLI.

## Sample snippets

- **Defining custom types in workspace configuration files**

```yaml
version: "rudder/v0.1"
kind: "custom-types"
metadata:
  name: "ecommerce_types"
spec:
  types:
    # Product Type - Consolidates all product-related properties
    - id: Product_Object
      name: "Product_Object"
      description: "Custom type for product information including ID, SKU, name, category, pricing"
      type: "object"
      properties:
        - $ref: "#/properties/ecommerce_properties/product_id"
          required: true
        - $ref: "#/properties/ecommerce_properties/product_sku"
          required: true
        - $ref: "#/properties/ecommerce_properties/product_name"
          required: true
        - $ref: "#/properties/ecommerce_properties/product_category"
          required: true
        - $ref: "#/properties/ecommerce_properties/product_price"
          required: true
        - $ref: "#/properties/ecommerce_properties/product_msrp"
          required: false
```

- **Reference custom types within a property configuration**

```yaml
version: "rudder/v0.1"
kind: "properties"
metadata:
  name: "ecommerce_properties"
spec:
  properties:
    # Product Custom Type Property
    - id: "product"
      name: "product"
      type: "#/custom-types/ecommerce_types/Product_Object"
      description: "Product information object containing all product details"
```

- **Deploy the changes to your workspace**

```bash
rudder-cli apply -l
```
