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.MultipleBatchAsync(
  new BatchParams
  {
    Requests = new List<MultipleBatchRequest>
    {
      new MultipleBatchRequest
      {
        Action = Enum.Parse<Action>("Upsert"),
        Body = new BatchCompositionAction(
          new Composition
          {
            ObjectID = "my-compo",
            Name = "my composition",
            Behavior = new CompositionBehavior(
              new CompositionInjectionBehavior
              {
                Injection = new Injection
                {
                  Main = new Main
                  {
                    Source = new CompositionSource
                    {
                      Search = new CompositionSourceSearch { Index = "foo" },
                    },
                  },
                  InjectedItems = new List<InjectedItem>
                  {
                    new InjectedItem
                    {
                      Key = "my-unique-injected-item-key",
                      Source = new InjectedItemSource(
                        new SearchSource
                        {
                          Search = new Algolia.Search.Models.Composition.Search
                          {
                            Index = "foo",
                          },
                        }
                      ),
                      Position = 2,
                      Length = 1,
                    },
                  },
                  Deduplication = new Deduplication
                  {
                    Positioning = Enum.Parse<DedupPositioning>("Highest"),
                  },
                },
              }
            ),
          }
        ),
      },
    },
  }
);

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

See the full API reference

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