internal async Task <Response <string> > AddAsync(string id, string twin, DigitalTwinsAddOptions digitalTwinsAddOptions = null, CancellationToken cancellationToken = default)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (twin == null)
            {
                throw new ArgumentNullException(nameof(twin));
            }

            using DiagnosticScope scope = _clientDiagnostics.CreateScope("DigitalTwinsClient.Add");
            scope.Start();
            try
            {
                using HttpMessage message = CreateAddRequest(id, twin, digitalTwinsAddOptions);
                await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

                switch (message.Response.Status)
                {
                case 200:
                case 202:
                {
                    string value = default;
                    using JsonDocument document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                    value = document.RootElement.GetRawText();
                    return(Response.FromValue(value, message.Response));
                }

                case 201:
                    return(Response.FromValue <string>(null, message.Response));
        internal HttpMessage CreateAddRequest(string id, string twin, DigitalTwinsAddOptions digitalTwinsAddOptions)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Put;
            var uri = new RawRequestUriBuilder();

            uri.Reset(endpoint);
            uri.AppendPath("/digitaltwins/", false);
            uri.AppendPath(id, true);
            uri.AppendQuery("api-version", apiVersion, true);
            request.Uri = uri;
            if (digitalTwinsAddOptions?.Traceparent != null)
            {
                request.Headers.Add("traceparent", digitalTwinsAddOptions.Traceparent);
            }
            if (digitalTwinsAddOptions?.Tracestate != null)
            {
                request.Headers.Add("tracestate", digitalTwinsAddOptions.Tracestate);
            }
            request.Headers.Add("If-None-Match", "*");
            request.Headers.Add("Content-Type", "application/json");
            request.Headers.Add("Accept", "application/json");
            var content = new StringRequestContent(twin);

            request.Content = content;
            return(message);
        }