> You are reading the Docusign Developer Documentation. For clean Markdown of any page, append .md to the page URL.
>
> Documentation indexes by section:
> - APIs and SDKs: https://docusign.docs.buildwithfern.com/docs/llms.txt
> - Platform 101: https://docusign.docs.buildwithfern.com/platform/llms.txt
> - Extension Apps: https://docusign.docs.buildwithfern.com/extension-apps/llms.txt
> - Docusign CLI: https://docusign.docs.buildwithfern.com/docusign-cli/llms.txt
>
> Authentication (OAuth, JWT Grant, M2M): https://docusign.docs.buildwithfern.com/platform/auth
> Webhooks and Connect: https://docusign.docs.buildwithfern.com/platform/webhooks
>
> OpenAPI specifications: https://docusign.docs.buildwithfern.com/openapi.json
> MCP server: https://docusign.docs.buildwithfern.com/_mcp/server

# How to apply a brand to an envelope

> Demonstrates how to apply a brand to an envelope using the eSignature REST API.

This topic demonstrates how to apply a brand to an envelope with the eSignature REST API.

> **Note**
>
> Run this code example from our [Quickstart](/docs/esign-rest-api/quickstart) or launcher projects: [Bash](https://github.com/docusign/code-examples-bash), [C#](https://github.com/docusign/code-examples-csharp), [Java](https://github.com/docusign/code-examples-java), [Node.js](https://github.com/docusign/code-examples-node), [PHP](https://github.com/docusign/code-examples-php), [PowerShell](https://github.com/docusign/code-examples-powershell), [Python](https://github.com/docusign/code-examples-python), or [Ruby](https://github.com/docusign/code-examples-ruby).

## Required data

Running the code in this how-to requires this data:

| Data element      | Description                                                                                                                                                                                                                                                                                                            |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \{API_ACCOUNT_ID} | A [GUID](http://guid.one/) value that identifies your account. This value is automatically generated by Docusign for any account you create. Copy the value from the **API Account ID** field on the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=appsAndKeys) page.                               |
| \{BASE_PATH}      | A string value that forms the root of the URL required to make API calls. The base path value in the example code is set to target the developer environment at https\://\<domain>/restapi Where \<domain> is demo.docusign.net for the developer environment and is the result of the GetUserInfo call in production. |
| \{BRAND_ID}       | A [GUID](http://guid.one/) value that identifies a brand. For more information, see [Branding](/docs/esign-rest-api/esign101/concepts/branding).                                                                                                                                                                       |
| \{SIGNER_EMAIL}   | A string value for the email address where the signer will receive a notification of the signing request.                                                                                                                                                                                                              |
| \{SIGNER_NAME}    | A string value for the full name of the signer.                                                                                                                                                                                                                                                                        |

## Step 1. Obtain your OAuth token

To make the API call shown in this how-to, you need a valid OAuth access token. Docusign supports access tokens for three different recommended OAuth grant types: Public Authorization Code Grant, Confidential Authorization Code Grant, and JSON Web Token (JWT) Grant. Choose the OAuth grant type appropriate for your scenario.

> **Note**
>
> See [Confidential Authorization Code Grant](/platform/auth/authcode#confidential-authorization-code-grant) for guidance on your options to get an Confidential Authorization Code Grant  OAuth token.

![Three icons that represent the three methods a user can use to obtain an OAuth token: JSON Web Token (JWT), Public Authorization Code Grant (ACG), and Confidential Authorization Code grant](/_fern-files/_img/64f473773042ee439449a096bf7673292b1585b86a4ccc55f82ba0dda41f61a1.webp)

## Step 2. Construct your API headers

After you have a valid OAuth access token, you are ready to construct the API headers that you will pass to the API call. Construct your headers like this, but make sure to substitute your valid OAuth access token for \{ACCESS_TOKEN}.

**`Bash`**

```bash title="Bash"
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
					'--header' "Accept: application/json" \
					'--header' "Content-Type: application/json")
```

**`C#`**

```csharp title="C#"
var docuSignClient = new DocuSignClient(basePath);
docuSignClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
```

**`Java`**

```java title="Java"
ApiClient apiClient = createApiClient(session.getBasePath(), user.getAccessToken());
```

**`Node.js`**

```javascript title="Node.js"
let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
```

**`PHP`**

```php title="PHP"
$config = new Configuration();
$config->setHost($args['base_path']);
$config->addDefaultHeader('Authorization', 'Bearer ' . $args['ds_access_token']);
$this->apiClient = new ApiClient($config);
```

**`PowerShell`**

```text title="PowerShell"
$headers = @{
    'Authorization' = "Bearer $accessToken";
    'Content-Type'  = "application/json";
  }
```

**`Python`**

```python title="Python"
api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"])
```

**`Ruby`**

```ruby title="Ruby"
configuration = DocuSign_eSign::Configuration.new
configuration.host = args[:base_path]
api_client = DocuSign_eSign::ApiClient.new configuration

api_client.default_headers['Authorization'] = "Bearer #{args[:access_token]}"
```

## Step 3. Construct the request body

Next, create the request body to create an envelope using your brand, substituting your brand ID for \{BRAND_ID}, your signer email for \{SIGNER_EMAIL} and your signer name for \{SIGNER_NAME}.

**`Bash`**

```bash title="Bash"
request_data=$(mktemp /tmp/request-brand-001.XXXXXX)
printf \
'{
	"documents": [{
		"documentBase64": "DQoNCg0KCQkJCXRleHQgZG9jDQoNCg0KDQoNCg0KUk0gIwlSTSAjCVJNICMNCg0KDQoNClxzMVwNCg0KLy9hbmNoMSANCgkvL2FuY2gyDQoJCS8vYW5jaDM=",
		"documentId": "1",
		"fileExtension": "txt",
		"name": "NDA"
	}],
	"emailBlurb": "Sample text for email body",
	"emailSubject": "Please Sign",
	"envelopeIdStamping": "true",
	"recipients": {
	"signers": [{
		"name": "'"${SIGNER_NAME}"'",
		"email": "'"${SIGNER_EMAIL}"'",
		"roleName": "signer",
		"note": "",
		"routingOrder": 1,
		"status": "sent",
				"tabs": {
				"signHereTabs": [{
					"documentId": "1",
					"name": "SignHereTab",
					"pageNumber": "1",
					"recipientId": "1",
					"tabLabel": "SignHereTab",
					"xPosition": "75",
					"yPosition": "572"
				}]
			},
		"deliveryMethod": "email",
		"recipientId": "1",
	}],
	},
	"brandId": "'$brand_id'",
	"status": "Sent"
}' >> $request_data
```

**`C#`**

```csharp title="C#"
EnvelopeDefinition env = CreateEnvelope(signerEmail, signerName, brandId, status, docPdf);
        public static EnvelopeDefinition CreateEnvelope(string signerEmail, string signerName, string brandId, string status, string docPdf)
        {
string docPdfBytes = Convert.ToBase64String(System.IO.File.ReadAllBytes(docPdf));

// create the envelope definition
EnvelopeDefinition env = new EnvelopeDefinition();
env.EmailSubject = "Please sign this document set";

// Create document objects, one per document
Document doc = new Document
{
    DocumentBase64 = docPdfBytes,
    Name = "Lorem Ipsum", // can be different from actual file name
    FileExtension = "pdf",
    DocumentId = "1",
};

// The order in the docs array determines the order in the envelope
env.Documents = new List<Document> { doc };

// create a signer recipient to sign the document, identified by name and email
// We're setting the parameters via the object creation
Signer signer1 = new Signer
{
    Email = signerEmail,
    Name = signerName,
    RecipientId = "1",
    RoutingOrder = "1",
};

// Create signHere fields (also known as tabs) on the documents,
// We're using anchor (autoPlace) positioning
//
// The DocuSign platform searches throughout your envelope's
// documents for matching anchor strings.
SignHere signHere = new SignHere
{
    AnchorString = "/sn1/",
    AnchorUnits = "pixels",
    AnchorYOffset = "10",
    AnchorXOffset = "20",
};

// Tabs are set per recipient / signer
Tabs signer1Tabs = new Tabs
{
    SignHereTabs = new List<SignHere> { signHere, },
};
signer1.Tabs = signer1Tabs;

// Add the recipients to the envelope object
Recipients recipients = new Recipients
{
    Signers = new List<Signer> { signer1 },
};
env.Recipients = recipients;
env.Status = status;

// Set the brand id.
env.BrandId = brandId;

return env;
        }
```

**`Java`**

```java title="Java"
EnvelopeDefinition envelope = ApplyBrandToEnvelopeService.makeEnvelope(
        args.getSignerEmail(),
        args.getSignerName(),
        args.getBrandId()
);
    public static EnvelopeDefinition makeEnvelope(
    String signerEmail,
    String signerName,
    String brandId) throws IOException {
// Reads a file from a local directory and create Document object.
Document document = EnvelopeHelpers.createDocumentFromFile(DOCUMENT_FILE_NAME, DOCUMENT_NAME, "1");

// Create a signer recipient to sign the document and associate sign tab
Tabs tabs = EnvelopeHelpers.createSingleSignerTab("/sn1/", ANCHOR_OFFSET_Y, ANCHOR_OFFSET_X);
Signer signer = new Signer()
        .email(signerEmail)
        .name(signerName)
        .recipientId("1")
        .routingOrder("1")
        .tabs(tabs);

Recipients recipients = new Recipients();
recipients.setSigners(Collections.singletonList(signer));

// Return envelope definition using created objects: the document,
// the recipients and obtained brand Id.
return new EnvelopeDefinition()
        .emailSubject("EG029. Please Sign")
        .documents(List.of(document))
        .recipients(recipients)
        .brandId(brandId)
        .status(EnvelopeHelpers.ENVELOPE_STATUS_SENT);
    }
```

**`Node.js`**

```javascript title="Node.js"
let envelope = makeEnvelope(args.envelopeArgs);
function makeEnvelope(args) {
console.log(args.brandId);
// Data for this method
// args.signerEmail
// args.signerName
// args.brandId
// args.status
// doc2File
// doc3File

// document 1 (html) has tag **signature_1**
// document 2 (docx) has tag /sn1/
// document 3 (pdf) has tag /sn1/
//
// The envelope has two recipients.
// recipient 1 - signer
// The envelope will be sent first to the signer

let doc2DocxBytes, doc3PdfBytes;
// Read files from a local directory
// The reads could raise an exception if the file is not available!
doc2DocxBytes = fs.readFileSync(args.doc2File);
doc3PdfBytes = fs.readFileSync(args.doc3File);

// Create the envelope definition
let env = new docusign.EnvelopeDefinition();
env.emailSubject = 'Please sign this document set';

// Add the documents
let doc1 = new docusign.Document();
  let doc1b64 = Buffer.from(document1(args)).toString('base64');
  let doc2b64 = Buffer.from(doc2DocxBytes).toString('base64');
  let doc3b64 = Buffer.from(doc3PdfBytes).toString('base64');
doc1.documentBase64 = doc1b64;
doc1.name = 'Order acknowledgement'; // Can be different from actual file name
doc1.fileExtension = 'html'; // Source data format. Signed docs are always PDF
doc1.documentId = '1'; // A label used to reference the doc

// Alternate pattern: using constructors for docs 2 and 3...
let doc2 = new docusign.Document.constructFromObject({
  documentBase64: doc2b64,
  name: 'Battle Plan', // Can be different from actual file name
  fileExtension: 'docx',
  documentId: '2',
});

let doc3 = new docusign.Document.constructFromObject({
  documentBase64: doc3b64,
  name: 'Lorem Ipsum', // Can be different from actual file name
  fileExtension: 'pdf',
  documentId: '3',
});

// The order in the docs array determines the order in the envelope
env.documents = [doc1, doc2, doc3];

// Create a signer recipient to sign the document, identified by name and email
// We're setting the parameters via the object constructor
let signer1 = docusign.Signer.constructFromObject({
  email: args.signerEmail,
  name: args.signerName,
  recipientId: '1',
  routingOrder: '1',
});
// routingOrder (lower means earlier) determines the order of deliveries
// to the recipients. Parallel routing order is supported by using the
// same integer as the order for two or more recipients

// Create signHere fields (also known as tabs) on the documents,
// We're using anchor (autoPlace) positioning
//
// The DocuSign platform searches throughout your envelope's
// documents for matching anchor strings. So the
// signHere2 tab will be used in both document 2 and 3 since they
// use the same anchor string for their "signer 1" tabs
let signHere1 = docusign.SignHere.constructFromObject({
    anchorString: '**signature_1**',
    anchorYOffset: '10',
    anchorUnits: 'pixels',
    anchorXOffset: '20',
  });
  let signHere2 = docusign.SignHere.constructFromObject({
    anchorString: '/sn1/',
    anchorYOffset: '10',
    anchorUnits: 'pixels',
    anchorXOffset: '20',
  });
// Tabs are set per recipient/signer
let signer1Tabs = docusign.Tabs.constructFromObject({
  signHereTabs: [signHere1, signHere2],
});
signer1.tabs = signer1Tabs;

// Add the recipients to the envelope object
let recipients = docusign.Recipients.constructFromObject({
  signers: [signer1],
});
env.recipients = recipients;

// Request that the envelope be sent by setting status to "sent".
// To request that the envelope be created as a draft, set status to "created"
env.status = args.status;
env.brandId = args.brandId;

return env;
}

/**
 * Creates document 1
 * @function
 * @private
 * @param {Object} args parameters for the envelope
 * @returns {string} A document in HTML format
 */

function document1(args) {
// Data for this method
// args.signerEmail
// args.signerName

return `
  <!DOCTYPE html>
  <html>
      <head>
        <meta charset="UTF-8">
      </head>
      <body style="font-family:sans-serif;margin-left:2em;">
      <h1 style="font-family: 'Trebuchet MS', Helvetica, sans-serif;
          color: darkblue;margin-bottom: 0;">World Wide Corp</h1>
      <h2 style="font-family: 'Trebuchet MS', Helvetica, sans-serif;
        margin-top: 0px;margin-bottom: 3.5em;font-size: 1em;
        color: darkblue;">Order Processing Division</h2>
      <h4>Ordered by ${args.signerName}</h4>
      <p style="margin-top:0em; margin-bottom:0em;">Email: ${args.signerEmail}</p>
      <p style="margin-top:3em;">
Candy bonbon pastry jujubes lollipop wafer biscuit biscuit. Topping brownie sesame snaps sweet roll pie. Croissant danish biscuit soufflé caramels jujubes jelly. Dragée danish caramels lemon drops dragée. Gummi bears cupcake biscuit tiramisu sugar plum pastry. Dragée gummies applicake pudding liquorice. Donut jujubes oat cake jelly-o. Dessert bear claw chocolate cake gummies lollipop sugar plum ice cream gummies cheesecake.
      </p>
      <!-- Note the anchor tag for the signature field is in white. -->
      <h3 style="margin-top:3em;">Agreed: <span style="color:white;">**signature_1**/</span></h3>
      </body>
  </html>
`;
}
```

**`PHP`**

```php title="PHP"
$envelope_definition = ApplyBrandToEnvelopeService::makeEnvelope(
    $args["envelope_args"],
    $clientService,
    $demoDocsPath,
    $docDocx,
    $docPDF
);
```

**`PowerShell`**

```text title="PowerShell"
$body = @"
{
	"documents": [{
		"documentBase64": "DQoNCg0KCQkJCXRleHQgZG9jDQoNCg0KDQoNCg0KUk0gIwlSTSAjCVJNICMNCg0KDQoNClxzMVwNCg0KLy9hbmNoMSANCgkvL2FuY2gyDQoJCS8vYW5jaDM=",
		"documentId": "1",
		"fileExtension": "txt",
		"name": "NDA"
	}],
	"emailBlurb": "Sample text for email body",
	"emailSubject": "Please Sign",
	"envelopeIdStamping": "true",
	"recipients": {
	"signers": [{
		"name": "$SIGNER_NAME",
		"email": "$SIGNER_EMAIL",
		"routingOrder": 1,
		"status": "created",
				"tabs": {
				"signHereTabs": [{
					"documentId": "1",
					"name": "SignHereTab",
					"pageNumber": "1",
					"recipientId": "1",
					"tabLabel": "SignHereTab",
					"xPosition": "75",
					"yPosition": "572"
				}]
			},
		"deliveryMethod": "email",
		"recipientId": "1",
	}]
	},
"brandId": "${brandID}",
"status": "Sent"
}
"@
```

**`Python`**

```python title="Python"
@classmethod
def make_envelope(cls, args):
    """
    Creates envelope
    """

    # Open the example file
    with open(path.join(demo_docs_path, DS_CONFIG["doc_pdf"]), "rb") as file:
        content_bytes = file.read()
    base64_file_content = base64.b64encode(content_bytes).decode("ascii")

    document = Document(
        document_base64=base64_file_content,
        name="lorem",
        file_extension="pdf",
        document_id=1
    )

    signer = Signer(
        email=args["signer_email"],
        name=args["signer_name"],
        recipient_id="1",
        routing_order="1"
    )

    sign_here = SignHere(
        anchor_string="/sn1/",
        anchor_units="pixels",
        anchor_y_offset="572",
        anchor_x_offset="75"
    )

    signer.tabs = Tabs(sign_here_tabs=[sign_here])

    envelope_definition = EnvelopeDefinition(
        email_subject="Please Sign",
        documents=[document],
        recipients=Recipients(signers=[signer]),
        status="sent",
        brand_id=args["brand_id"],
    )

    return envelope_definition
```

**`Ruby`**

```ruby title="Ruby"
envelope_definition = make_envelope(args[:envelope_args])
  def make_envelope(envelope_args)
envelope_definition = DocuSign_eSign::EnvelopeDefinition.new
envelope_definition.email_blurb = 'Sample text for email body'
envelope_definition.email_subject = 'Please Sign'
envelope_definition.envelope_id_stamping = true
envelope_definition.brand_id = envelope_args[:brands]

# Add the documents and create the document models
pdf_filename = 'World_Wide_Corp_lorem.pdf'
document1 = DocuSign_eSign::Document.new(
  # Create the Docusign Document object
  documentBase64: Base64.encode64(File.binread(File.join('data', pdf_filename))),
  name: 'NDA', # Can be different from actual file name
  fileExtension: 'pdf', # Many different document types are accepted
  documentId: '1' # A label used to reference the doc
)

envelope_definition.documents = [document1]

# Create the signer recipient model
signer1 = DocuSign_eSign::Signer.new
signer1.name = envelope_args[:signer_name]
signer1.email = envelope_args[:signer_email]
signer1.role_name = 'signer'
signer1.note = ''
signer1.routing_order = '1'
signer1.status = envelope_args[:status]
signer1.delivery_method = 'email'
signer1.recipient_id = '1'

sign_here1 = DocuSign_eSign::SignHere.new
sign_here1.document_id = '1'
sign_here1.name = 'SignHereTab'
sign_here1.page_number = '1'
sign_here1.recipient_id = '1'
sign_here1.tab_label = 'SignHereTab'
sign_here1.x_position = '75'
sign_here1.y_position = '572'

# Add the tabs model (including the sign_here tabs) to the signer
# The Tabs object wants arrays of the different field/tab types
signer1_tabs = DocuSign_eSign::Tabs.new({
                                          signHereTabs: [sign_here1]
                                        })
signer1.tabs = signer1_tabs

# Add the recipients to the envelope object
recipients = DocuSign_eSign::Recipients.new(
  signers: [signer1]
)

# Request that the envelope be sent by setting status to 'sent'
# To request that the envelope be created as a draft, set status to 'created'
envelope_definition.recipients = recipients
envelope_definition.status = envelope_args[:status]
envelope_definition
  end
```

## Step 4. Call the eSignature REST API

Now that you have constructed your API headers and request body, you can send the envelope with the [Envelopes:create](/docs/esign-rest-api/reference/envelopes/envelopes/create) method and include the request body with an applied brand ID. Here’s how you make the call, but make sure to substitute your API account ID for \{ACCOUNT_ID}.

> **Note**
>
> View the source code for this how-to on GitHub: [Bash](https://github.com/docusign/code-examples-bash/blob/master/examples/eSignature/eg029ApplyingBrandEnvelope.sh), [C#](https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/eSignature/Examples/ApplyBrandToEnvelope.cs), [Java](https://github.com/docusign/code-examples-java/blob/master/src/main/java/com/docusign/controller/eSignature/services/ApplyBrandToEnvelopeService.java), [Node.js](https://github.com/docusign/code-examples-node/blob/master/lib/eSignature/examples/applyBrandToEnvelope.js), [PHP](https://github.com/docusign/code-examples-php/blob/master/src/Services/Examples/eSignature/ApplyBrandToEnvelopeService.php), [PowerShell](https://github.com/docusign/code-examples-powershell/blob/master/examples/eSignature/eg029ApplyingBrandEnvelope.ps1), [Python](https://github.com/docusign/code-examples-python/blob/master/app/eSignature/examples/eg029_brands_apply_to_envelope.py), or [Ruby](https://github.com/docusign/code-examples-ruby/blob/main/app/services/e_sign/eg029_brands_apply_to_envelope_service.rb).

**`Bash`**

```bash title="Bash"
Status=$(curl -w '%{http_code}' -i --request POST ${base_path}/v2.1/accounts/${account_id}/envelopes \
     "${Headers[@]}" \
     --data-binary @${request_data} \
     --output ${response})
```

**`C#`**

```csharp title="C#"
EnvelopesApi envelopesApi = new EnvelopesApi(docuSignClient);

var response = envelopesApi.CreateEnvelopeWithHttpInfo(accountId, env);
response.Headers.TryGetValue("X-RateLimit-Remaining", out string remaining);
response.Headers.TryGetValue("X-RateLimit-Reset", out string reset);

if (reset != null && remaining != null)
{
    DateTime resetDate = DateTimeOffset.FromUnixTimeSeconds(long.Parse(reset)).UtcDateTime;
    Console.WriteLine("API calls remaining: " + remaining);
    Console.WriteLine("Next Reset: " + resetDate);
}

return response.Data;
```

**`Java`**

```java title="Java"
EnvelopeSummary envelopeSummary = ApplyBrandToEnvelopeService.applyBrandToEnvelope(
        envelopesApi,
        session.getAccountId(),
        envelope
);
    public static EnvelopeSummary applyBrandToEnvelope(
    EnvelopesApi envelopesApi,
    String accountId,
    EnvelopeDefinition envelope) throws ApiException {
var createEnvelopeResponse = envelopesApi.createEnvelopeWithHttpInfo(accountId, envelope,
        envelopesApi.new CreateEnvelopeOptions());
Map<String, List<String>> headers = createEnvelopeResponse.getHeaders();
java.util.List<String> remaining = headers.get("X-RateLimit-Remaining");
List<String> reset = headers.get("X-RateLimit-Reset");

if (remaining != null & reset != null) {
    Instant resetInstant = Instant.ofEpochSecond(Long.parseLong(reset.get(0)));
    System.out.println("API calls remaining: " + remaining);
    System.out.println("Next Reset: " + resetInstant);
}

return createEnvelopeResponse.getData();
    }
```

**`Node.js`**

```javascript title="Node.js"
results = await envelopesApi.createEnvelope(args.accountId, {
  envelopeDefinition: envelope,
}, (error, data, response) => {
    const headers = response?.headers;

    const remaining = headers?.['x-ratelimit-remaining'];
    const reset = headers?.['x-ratelimit-reset'];

    if (remaining && reset) {
      const resetInstant = new Date(Number(reset) * 1000);

      console.log(`API calls remaining: ${remaining}`);
      console.log(`Next Reset: ${resetInstant.toISOString()}`);
    }
});
let envelopeId = results.data.envelopeId;
```

**`PHP`**

```php title="PHP"
$envelope_api = $clientService->getEnvelopeApi();
$createdEnvelope = $envelope_api->createEnvelopeWithHttpInfo(
    $args['account_id'],
    $envelope_definition
);

$remaining = $createdEnvelope[2]['X-RateLimit-Remaining'] ?? null;
$reset = $createdEnvelope[2]['X-RateLimit-Reset'] ?? null;

if ($remaining !== null && $reset !== null) {
    $resetInstant = (new DateTime())->setTimestamp((int)$reset);
    error_log("API calls remaining: $remaining");
    error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
}
```

**`PowerShell`**

```text title="PowerShell"
$uri = "https://demo.docusign.net/restapi/v2.1/accounts/$APIAccountId/envelopes"
try {
	Write-Output "Response:"
	$result = Invoke-WebRequest -uri $uri -headers $headers -body $body -method POST
	$result.content
}
catch {
	$int = 0
	foreach ($header in $_.Exception.Response.Headers) {
		if ($header -eq "X-DocuSign-TraceToken") { Write-Output "TraceToken : " $_.Exception.Response.Headers[$int] }
		$int++
	}
	Write-Output "Error : "$_.ErrorDetails.Message
	Write-Output "Command : "$_.InvocationInfo.Line
}
```

**`Python`**

```python title="Python"
envelope_api = EnvelopesApi(api_client)
envelope_definition = cls.make_envelope(args["envelope_args"])

# Call the eSignature REST API
(response, status, headers) = envelope_api.create_envelope_with_http_info(account_id=args["account_id"], envelope_definition=envelope_definition)

remaining = headers.get("X-RateLimit-Remaining")
reset = headers.get("X-RateLimit-Reset")

if remaining is not None and reset is not None:
    reset_date = dt.fromtimestamp(int(reset), tz=timezone.utc)
    print(f"API calls remaining: {remaining}")
    print(f"Next Reset: {reset_date}")
```

**`Ruby`**

```ruby title="Ruby"
results, _status, headers = envelope_api.create_envelope_with_http_info args[:account_id], envelope_definition

remaining = headers['X-RateLimit-Remaining']
reset = headers['X-RateLimit-Reset']

if remaining && reset
  reset_date = Time.at(reset.to_i).utc
  puts "API calls remaining: #{remaining}"
  puts "Next Reset: #{reset_date}"
end
```

## Expected response

If you run this code example from our Quickstart or launcher projects, you should see a JSON response similar to the code shown.

**`Sample response`**

```json title="Sample response"
{
  "envelopeId": "c740c278-xxxx-xxxx-xxxx-99b1de594ca0",
  "uri": "/envelopes/c740c278-xxxx-xxxx-xxxx-99b1de594ca0",
  "statusDateTime": "2020-08-11T17:19:56.4000000Z",
  "status": "sent"
}
```

## Next steps

* Run this code example from our [Quickstart](/docs/esign-rest-api/quickstart) or launcher projects:    [Bash](https://github.com/docusign/code-examples-bash), [C#](https://github.com/docusign/code-examples-csharp), [Java](https://github.com/docusign/code-examples-java), [Node.js](https://github.com/docusign/code-examples-node), [PHP](https://github.com/docusign/code-examples-php), [PowerShell](https://github.com/docusign/code-examples-powershell), [Python](https://github.com/docusign/code-examples-python), or [Ruby](https://github.com/docusign/code-examples-ruby).
* Learn more about [branding](/docs/esign-rest-api/esign101/concepts/branding).
* Learn about [creating and using templates](/docs/esign-rest-api/esign101/concepts/templates/creating).
* Review [Working with Templates](https://support.docusign.com/s/document-item?bundleId=xry1643227563338\&topicId=dqj1578456412286.html\&rsc_301) on Docusign Support.
* See how to [Go-Live](/docs/esign-rest-api/go-live) with a completed app and find the base path for API calls in the production environment.