> For the complete documentation index, see [llms.txt](https://dev.ucommerce.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.ucommerce.net/readme/how-to/executing-a-pipeline.md).

# Executing a pipeline

### Injecting and Executing a Pipeline

#### Inject the Pipeline

If you want to execute a pipeline from somewhere else, first, inject it into the constructor. This is demonstrated in the `MyController` constructor, which takes an `IPipeline<PipelineInputType, PipelineOutputType>` as a parameter:

```csharp
public MyController(IPipeline<PipelineInputType, PipelineOutputType> pipeline)
{
    _myPipeline = pipeline;
}
```

#### Execute the Pipeline

When you're ready to execute the pipeline, create an instance of the input type and populate it with your desired parameters. Then, use the `_myPipeline.Execute` method to process the input and get the output from the result.\
Here's how you can do it:

```csharp
var input = new PipelineInputType()
{
    Property1 = true,
    Property2 = 42,
    Property3 = "Hello",
};
var response = await _myPipeline.Execute(input, token);
var output = response.EnsureSuccess();
```

`response.EnsureSuccess()` throws a `PipelineException` if any exceptions happen during the execution of the pipeline, otherwise, it will return the output (result) of the pipeline execution. The exceptions and output are also directly accessible using `response.Errors` and `response.Output` respectively.
