Skip to main content
Required ACL: editSettings

Usage

// Initialize the client
var client = new CompositionClient(
  new CompositionConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
);

// Call the API
var response = await client.PutCompositionAsync(
  "my-compo",
  new Composition
  {
    ObjectID = "my-compo",
    Name = "my composition",
    SortingStrategy = new Dictionary<string, string>
    {
      { "Price-asc", "products-low-to-high" },
      { "Price-desc", "products-high-to-low" },
    },
    Behavior = new CompositionBehavior(
      new CompositionInjectionBehavior
      {
        Injection = new Injection
        {
          Main = new Main
          {
            Source = new CompositionSource
            {
              Search = new CompositionSourceSearch { Index = "products" },
            },
          },
        },
      }
    ),
  }
);

// print the response
Console.WriteLine(response);

See the full API reference

For more details about input parameters and response fields.
Last modified on February 20, 2026