> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-commerce/17.latest/key-concepts/umbraco-commerce-builder.md).

# Umbraco Commerce Builder

Learn more about the different options for configured Umbraco Commerce.

When it comes to configuring and extending Umbraco Commerce, such as by registering your own event handlers, we achieve this with the `IUmbracoCommerceBuilder` interface that can be accessed via a delegate function passed into the `AddUmbracoCommerce()` extension method called on the `IUmbracoBuilder` interface when explicitly registering Umbraco Commerce.

```csharp
builder.CreateUmbracoBuilder()
    .AddBackOffice()
    .AddWebsite()
    .AddUmbracoCommerce(umbracoCommerceBuilder => {
    // Configure Umbraco Commerce here
    })
    .AddDeliveryApi()
    .AddComposers()
    .Build();

```

## Registering Dependencies

The `IUmbracoCommerceBuilder` interface gives you access to the current `IServiceCollection` and `IConfiguration` to allow you to register dependencies like you would with the [`IUmbracoBuilder` interface](/umbraco-commerce/17.latest/key-concepts/dependency-injection.md#registering-dependencies) but its primary use case would be to access Umbraco Commerce's own collection builders, such as for registering validation or notification events, and any other Umbraco Commerce-specific configuration APIs.

```csharp
...
.AddUmbracoCommerce(umbracoCommerceBuilder => {

    // Register validation events
    umbracoCommerceBuilder.WithValidationEvent<ValidateOrderProductAdd>()
            .RegisterHandler<MyOrderProductAddValidationHandler>();

})
...
```

As per the [Dependency Injection docs](/umbraco-commerce/17.latest/key-concepts/dependency-injection.md), whilst you can register your dependencies directly within this configuration delegate, you may prefer to group your dependencies registration code into an extension method.

```csharp
public static class UmbracoCommerceUmbracoBuilderExtensions
{
    public static IUmbracoCommerceBuilder AddMyDependencies(this IUmbracoCommerceBuilder builder)
    {
        // Register my dependencies here via the builder parameter
        ...

        // Return the builder to continue the chain
        return builder;
    }
}
```

```csharp
...
.AddUmbracoCommerce(umbracoCommerceBuilder => {

    umbracoCommerceBuilder.AddMyDependencies();

})
...
```

{% hint style="info" %}
If using a composer to register `IUmbracoCommerceBuilder` extensions and their dependencies, the composer needs to run before `UmbracoCommerceComposer` otherwise it will use the default configuration.
{% endhint %}

```csharp
public static class StoreBuilderExtensions
{
	public static IUmbracoBuilder AddMyStore(this IUmbracoBuilder umbracoBuilder)
	{
		umbracoBuilder.AddUmbracoCommerce(v =>
		{
			...
		});

		return umbracoBuilder;
	}
}
```

```csharp
[ComposeBefore(typeof(UmbracoCommerceComposer))]
public class StoreComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.AddMyStore();
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/umbraco-commerce/17.latest/key-concepts/umbraco-commerce-builder.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
