---
title: "Starting a pipeline batch programmatically"
slug: "starting-a-pipeline-batch-programmatically"
abstract: "An example of starting a Data Exchange Framework pipeline batch programmatically."
---
# Starting a pipeline batch programmatically

You can start pipeline batches programmatically. For example:

```csharp
Guid tenantId = ... //identify the tenant that owns the pipeline batch
Guid pipelineBatchId = ... //identity the pipeline batch
IEnumerable<PipelineBatch> batches = null;
tasks = Sitecore.DataExchange.Context.PipelineBatchRepository.GetPipelineBatches(tenantId);
if (batches != null)
    {
        PipelineBatch pipelineBatch = batches.FirstOrDefault(x => x.ID == pipelineBatchId);
        if (pipelineBatch != null)
            {
                var runner = new InProcessPipelineBatchRunner();
                if (runner.Run(pipelineBatch))
                    {
                        //pipeline batch was started
                    }
            }
    }

```

> [!note]
> A pipeline batch can run for a long time, depending on its content. Unless you are certain that the pipeline batch can finish in a short amount of time, you might prefer to run it in a [Sitecore task](https://doc.sitecore.com/xp/en/developers/def/80/data-exchange-framework/scheduling-a-pipeline-batch.html "Scheduling a pipeline batch").