Skip to main content

Creating a PIM product

Sometimes you need to create a new PIM product programmatically. This article explains how to create a PIM product using the BackOffice API, including selecting a personalization workflow and processing pipeline.

Using the API

Before you start, ensure your app has the necessary credentials to make API calls:

  1. In your tenant, go to Settings > External apps and register your app.
  2. Implement authentication in your app as described in the Authorization article.

C# API Client

To use the C# API client, initialize it with the required configuration:

var httpClient = new HttpClient();
var backOfficeApiConfiguration = new Aurigma.BackOfficeApi.ApiClientConfiguration()
{
ApiUrl = BACKOFFICE_API_URL,
AuthorizationToken = AUTH_TOKEN
};
var productsApiClient = new ProductsManagementApiClient(backOfficeApiConfiguration, httpClient);

Creating a PIM Product

To create a PIM product, you need to:

  1. Retrieve the available personalization workflows and processing pipelines.
  2. Create the product using the selected workflow and pipeline.

Example

// Load available workflows and pipelines
var workflows = await productsApiClient.GetAvailablePersonalizationWorkflowsAsync(tenantId: TENANT_ID);
var pipelines = await productsApiClient.GetAvailableProcessingPipelinesAsync(tenantId: TENANT_ID);

// Create a new product
var product = await productsApiClient.CreateProductAsync(
tenantId: TENANT_ID,
body: new CreateProductDto()
{
Name = "Test Product",
Description = "Test Product Description",
Tags = [],
CustomFields = { },
Options = new List<CreateProductOptionDto>()
{
new CreateProductOptionDto()
{
Title = "Test Product Option",
Traits = [],
Values = new List<CreateProductOptionValueDto>()
{
new CreateProductOptionValueDto() { Value = "Value#1" },
new CreateProductOptionValueDto() { Value = "Value#2" }
},
UseForMockupBinding = true,
UseForDesignBinding = true,
UseForDocumentBinding = true,
}
},
ProcessingPipelineId = pipelines.Items.FirstOrDefault()?.Id ?? 0,
PersonalizationWorkflowId = workflows.Items.FirstOrDefault()?.Id ?? 0,
});
important

Ensure that tenantId is correctly specified in the parameters. It must match the tenantId encoded in the authorization token.

Was this page helpful?