title: How can I add custom metadata at runtime to document(s) created from a template
body: <p>I am using composite templates to create an envelope. Every template will only have one document. I need to individually process every document that comes back signed. In order to do that I need to add metadata to each document that is being sent. How can I do that while also using composite templates before I send the envelope?
  I know all about envelope metadata and custom fields but what if I need it more specific to documents and I'm not working with the actual documents? Here I'm working with the templates that contain the documents.
  Here is the c# code I have so far</p>
  <pre><code>List&lt;CompositeTemplate&gt; compositeTemplates = new List&lt;CompositeTemplate&gt;();
  Recipients recipientsServerTemplate = new Recipients();
  List&lt;Signer&gt; signers = new List&lt;Signer&gt;();
          List&lt;CarbonCopy&gt; carbonCopies = new List&lt;CarbonCopy&gt;();
  
       
          Signer signer1 = new Signer();
          signer1.Email = signerEmail;
          signer1.Name = signerName;
          signer1.RoleName = &quot;signer&quot;;
          signer1.RecipientId = &quot;1&quot;;
          signer1.Tabs = tabs;
          signers.Add(signer1);
  
         
          CarbonCopy cc1 = new CarbonCopy();
          cc1.Email = ccEmail;
          cc1.Name = ccName;
          cc1.RoleName = &quot;cc&quot;;
          cc1.RecipientId = &quot;2&quot;;
          carbonCopies.Add(cc1);
  
          recipientsServerTemplate.Signers = signers;
          recipientsServerTemplate.CarbonCopies = carbonCopies;
  
  
          int i = 1;
          foreach (string templateId in templateIds)
          {
              //add custom fields //this is per envelope. I need it more specific in my case
              TextCustomField textcustomField = new TextCustomField
              {
                  Name = &quot;MyCustomField&quot; + i.ToString(),
                  Required = &quot;false&quot;,
                  Show = &quot;false&quot;,
                  Value =  &quot;653022&quot; 
              };
              CustomFields cf = new CustomFields
              {
                  TextCustomFields = new List&lt;TextCustomField&gt; { textcustomField }
              };
  
              List&lt;ServerTemplate&gt; ServerTemplates = new List&lt;ServerTemplate&gt;();
              List&lt;InlineTemplate&gt; InlineTemplates = new List&lt;InlineTemplate&gt;();
              CompositeTemplate CT = new CompositeTemplate
              {
                  CompositeTemplateId = i.ToString()
              };
  
              ServerTemplate ST = new ServerTemplate
              {
                  Sequence = i.ToString(),
                  TemplateId = templateId
              };
              
  
              InlineTemplate IT = new InlineTemplate
              {
                  Recipients = recipientsServerTemplate,
                  Sequence = (i+1).ToString(),
                  CustomFields = cf//this is for the whole envelope
              };
              
              InlineTemplates.Add(IT);
              ServerTemplates.Add(ST);
              CT.ServerTemplates = ServerTemplates;
              CT.InlineTemplates = InlineTemplates;
              compositeTemplates.Add(CT);
              
              i++;
          }
  
  
          EnvelopeDefinition env = new EnvelopeDefinition
          {
              Status = &quot;sent&quot;,
              CompositeTemplates = compositeTemplates
          };
  </code></pre>