---
title: 6. Defining child resources
description: Defining child resources
llmstxt: true
---

Sometimes your resource types will need to have child resources that relate to their parent types. You can identify that a resource type is the child of another resource by using the `@parentResource` decorator.

For example, here's how you could create a new `WidgetPart` resource under the `Widget` defined above:

```typespec
/** A WidgetPart resource belonging to a Widget resource. */
@resource("parts")
@parentResource(Widget)
model WidgetPart {
  @key("partName")
  name: string;

  /** The part number. */
  number: string;
}
```

When you use the standard resource operations with child resource types, their operation routes will include the route of the parent resource. For example, we might define the following operations for `WidgetPart`:

```typespec
import "@azure-tools/typespec-azure-core";

using Azure.Core;
using Azure.Core.Traits;

alias ServiceTraits = SupportsRepeatableRequests &
  SupportsConditionalRequests &
  SupportsClientRequestId;

alias Operations = Azure.Core.ResourceOperations<ServiceTraits>;

/** Creates a WidgetPart */
op createWidgetPart is Operations.ResourceCreateWithServiceProvidedName<WidgetPart>;

/** Get a WidgetPart */
op getWidgetPart is Operations.ResourceRead<WidgetPart>;
```

These operations will be defined under the route path:

```
/widgets/{widgetName}/parts/{partName}
```
