---
title: "Full example in .NET"
description: "Full example of an Amplia Reg integration in .NET: a console application that creates an order, pre-fills the holder, sends documents and lists the status changes."
canonical: "https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/full-example"
locale: "en"
product: "Amplia Reg"
last_updated: "2026-11-17"
---

# Full example in .NET

The console application below goes through a full integration with the [.NET client library](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/dotnet-client). It chooses the
certificate type, creates the order, pre-fills the holder data, sends a document and lists the status changes.

## Before you start

* The endpoint and an API key of an application with the **Sales app** role. See [Get started](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/get-started#api-key).
* The .NET 8 SDK or later.

The example creates a real order on the instance. If the instance has the [RFB prior query](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/verify-holder#rfb-query) configured, the order
creation checks the holder's data. Use real data, with the name as the Brazilian Revenue Service has it. To cancel the order afterwards, see [Cancel an order](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/cancel-order).

## Create the project

1. Create a console application:

   ```bash
   dotnet new console -n AmpliaRegExample
   ```

2. Go to the project folder:

   ```bash
   cd AmpliaRegExample
   ```

3. Add the client library and the hosting package:

   ```bash
   dotnet add package Lacuna.AmpliaRegNg.Client
   ```

   ```bash
   dotnet add package Microsoft.Extensions.Hosting
   ```

4. Replace the content of *Program.cs* with the code in the next section.
5. In the code, replace the endpoint, the API key, the holder data and the file path with your values.
6. Run the project:

   ```bash
   dotnet run
   ```

## Code

```cs
using Lacuna.AmpliaRegNg.Api;
using Lacuna.AmpliaRegNg.Api.CertificateTypes;
using Lacuna.AmpliaRegNg.Api.Contact;
using Lacuna.AmpliaRegNg.Api.Holders;
using Lacuna.AmpliaRegNg.Api.Orders;
using Lacuna.AmpliaRegNg.Client;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = Host.CreateApplicationBuilder(args);

builder.Services.AddAmpliaReg(options => {
	options.Endpoint = "https://ampliareg.yourcompany.com/";
	options.ApiKey = "your-app|YOUR_KEY";
});

using var host = builder.Build();
var ampliaReg = host.Services.GetRequiredService<IAmpliaRegService>();

// Holder data
var cpf = "07917307000";
var name = "Holder Name"; // Name as the Brazilian Revenue Service has it
var birthDate = new DateTime(1995, 10, 15);

// 1. List the certificate types and choose an e-CPF type
var certTypes = await ampliaReg.ListCertificateTypesAsync(new CertificateTypeListParameters {
	IsDisabled = false,
});
var certType = certTypes.First(c => c.BrazilParameters?.BrazilType == PkiBrazilCertificateTypes.PessoaFisica);
Console.WriteLine($"Certificate type: {certType.Name} ({certType.Code})");

// 2. Create the order
var order = await ampliaReg.CreateOrderAsync(new OrderCreateRequest<BrazilOrderCreateParameters> {
	CertificateType = CertificateTypeReference.FromCode(certType.Code),
	IssueType = IssueTypes.Presential,
	Parameters = new BrazilOrderCreateParameters {
		Cpf = cpf,
		Name = name,
		BirthDate = birthDate.ToString("yyyy-MM-dd"),
	},
	Validity = certType.ValidityOptions.First(),
});
Console.WriteLine($"Order created: {order.Number} ({order.Id})");

// 3. Pre-fill the holder's address and contact
await ampliaReg.PreFillHolderAsync(order.Number, new UpdateHolderInformationRequest<BrazilUpdateHolderParameters> {
	Parameters = new BrazilUpdateHolderParameters {
		Address = new BrazilHolderAddressRequest {
			ZipCode = "70000-000",
			Street = "Rua Exemplo",
			Number = "100",
			District = "Centro",
			City = "Brasília",
			StateCode = "DF",
			Country = "Brazil",
		},
	},
	Contact = new ContactData {
		Phone = "+5511999990000",
		EmailAddress = "holder@example.com",
	},
});

// 4. Send the holder documents. The library uploads the files
await ampliaReg.AddHolderFilesAsync(
	order.Number,
	new List<HolderFileReference2> {
		new HolderFileReference2 {
			Type = HolderFileTypes.Identification.ToString(),
			Subtype = HolderFileSubtypes.Cnh,
			DocumentPart = DocumentParts.FrontComplete,
			File = FileReference.FromFile(@"C:\AppData\Documents\cnh.pdf"),
		},
	},
	HolderTypeReference.FromCode("PF")
);

// 5. List the status changes of the last day, one page at a time
var startDate = DateTimeOffset.Now.AddDays(-1);
var offset = 0;
while (true) {
	var page = await ampliaReg.ListOrderStatusTransitionsAsync(new OrderStatusTransitionSearchParams {
		StartDate = startDate,
		Offset = offset,
		Limit = 100,
	});
	if (!page.Items.Any()) {
		break;
	}
	foreach (var change in page.Items) {
		Console.WriteLine($"Order {change.OrderNumber}: {change.PreviousStatus} -> {change.Status} on {change.Date}");
	}
	offset += page.Items.Count();
}
```

## What each step does

| Step | Call | Page |
|---|---|---|
| 1 | Lists the enabled certificate types and chooses an e-CPF type | [Create orders](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/create-order#certificate-types) |
| 2 | Creates the order with in-person validation. The `Number` in the response is the order number | [Create orders](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/create-order#brazil) |
| 3 | Sends the address and the contact of the holder, so that the agent does not have to type them | [Pre-fill the holder data](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/prefill-holder) |
| 4 | Sends the front of the holder's driver's license | [Holder documents](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/add-holder-files) |
| 5 | Lists the status changes of the orders of the application | [Recover missed changes](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/webhooks#reconcile) |

In production, receive the status changes by [webhook](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/webhooks). Use the list in step 5 only to recover the changes that your
application missed.

## See also

* [Use the .NET library](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/dotnet-client)
* [Get started](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/get-started)
* [Error codes](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/error-codes)
