> 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 send an envelope with delayed routing

> Describes how to send an envelope and set a delay between the steps of your envelope's routing order.

eSignature REST API 2.1 only

This topic demonstrates how to delay an envelope’s delivery between recipients using the delayed routing feature.

> **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. |
| \{DELAY}              | The amount of time to delay sending the envelope to the specified recipient represented as a string formatted as a [C# TimeSpan constant](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings#the-constant-c-format-specifier).                                               |
| \{DOCS_PATH}          | A string value for the file path to the folder containing the documents you want to include in the [envelope](/docs/esign-rest-api/esign101/concepts/envelopes).                                                                                                                                                       |
| \{DOCUMENT_ID}        | A document identifier such as a name or ID. You can get a [list of envelope documents](/docs/esign-rest-api/how-to/list-envelope-documents) to obtain this information.                                                                                                                                                |
| Document to be signed | You must provide at least one document to be signed. Document used in this how-to:- [PDF file](https://github.com/docusign/code-examples-java/blob/master/src/main/resources/World_Wide_Corp_lorem.pdf)                                                                                                                |
| \{RECIPIENT_ID}       | A unique string value that you assign to identify each recipient. This value assigns tabs on a per-[recipient](/docs/esign-rest-api/esign101/concepts/recipients) basis.                                                                                                                                               |
| \{SIGNER1_EMAIL}      | A string value for the email address where the first signer will receive a notification of the signing request.                                                                                                                                                                                                        |
| \{SIGNER2_EMAIL}      | A string value for the email address where the second signer will receive a notification of the signing request.                                                                                                                                                                                                       |
| \{SIGNER1_NAME}       | A string value for the full name of the first signer.                                                                                                                                                                                                                                                                  |
| \{SIGNER2_NAME}       | A string value for the full name of the second 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 the request body

Next, create the request body. Construct an envelope definition with two signers. Set the routing order so that one recipient has a routing order of `"1"` and the other has a routing order of `"2"`. The delayed routing feature will use the routing order to determine where to add a delay when sending the envelope. Then add the `workflowSteps` to the envelope definition.

The `workflowSteps` section describes the delayed routing for one of the recipients in the envelope. In the accompanying code, the action field is set to `"pause_before"` and the `triggerOnItem` field is set to `"routing_order"` with an `itemId` of `"2"`. `DELAY` indicates the time lapse after the envelope is sent to the first recipient and before the envelope is sent to the second recipient.

**`Bash`**

```bash title="Bash"
printf \
'{
    "emailSubject": "Please sign this document set",
    "documents": [
        {
            "documentBase64": "' >> $request_data
            cat $doc1_base64 >> $request_data
            printf '",
            "name": "Lorem Ipsum",
            "fileExtension": "pdf",
            "documentId": "1"
        }
    ],
    "workflow": {
        "workflowSteps": [{
            "action": "pause_before",
            "triggerOnItem": "routing_order",
            "itemId": 2,
            "delayedRouting": {
                "rules": [{
                    "delay": "'"${DELAY}"'"
                }]
            }
        }]
    },
    "recipients": {
        "signers": [
            {
                "email": "'"${SIGNER_EMAIL}"'",
                "name": "'"${SIGNER_NAME}"'",
                "recipientId": "1",
                "routingOrder": "1",
                "tabs": {
                    "signHereTabs": [
                        {
                            "anchorString": "/sn1/",
                            "anchorUnits": "pixels",
                            "anchorXOffset": "20",
                            "anchorYOffset": "10"
                        }
                    ]
                }
            },
            {
                "email":  "'"${SIGNER_EMAIL2}"'",
                "name": "'"${SIGNER_NAME2}"'",
                "recipientId": "2",
                "routingOrder": "2",
                "tabs": {
                    "signHereTabs": [
                        {
                            "xPosition": "400",
                            "yPosition": "172",
                            "documentId": "1",
                            "pageNumber": "1"
                        }
                    ]
                }

            }
        ]
    },
    "status": "sent"
}' >> $request_data
```

**`C#`**

```csharp title="C#"
// The envelope has a single recipient.
// recipient 1 - signer
// read file from a local directory
// The reads could raise an exception if the file is not available!
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 = signer1Email,
    Name = signer1Name,
    RecipientId = "1",
    RoutingOrder = "1",
};

Signer signer2 = new Signer
{
    Email = signer2Email,
    Name = signer2Name,
    RecipientId = "2",
    RoutingOrder = "2",
};

// Add the workflow step that sets a delay for the second signer
Workflow workflow = new Workflow();
var workflowStep = new WorkflowStep();
workflowStep.Action = "pause_before";
workflowStep.TriggerOnItem = "routing_order";
workflowStep.ItemId = "2";
workflowStep.DelayedRouting = new DocuSign.eSign.Model.DelayedRouting();
var delayRouteRule = new EnvelopeDelayRule();
delayRouteRule.Delay = new TimeSpan(delay, 0, 0).ToString();
workflowStep.DelayedRouting.Rules = new List<EnvelopeDelayRule> { delayRouteRule };
workflow.WorkflowSteps = new List<WorkflowStep> { workflowStep };
env.Workflow = workflow;

// 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 document,
// 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.
SignHere signHere1 = new SignHere
{
    AnchorString = "/sn1/",
    AnchorUnits = "pixels",
    AnchorYOffset = "10",
    AnchorXOffset = "20",
};

SignHere signHere2 = new SignHere
{
    AnchorString = "/sn1/",
    AnchorUnits = "pixels",
    AnchorYOffset = "10",
    AnchorXOffset = "120",
};

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

// Add the recipients to the envelope object
Recipients recipients = new Recipients
{
    Signers = new List<Signer> { signer1, signer2 },
};
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 to "created"
env.Status = "sent";
```

**`Java`**

```java title="Java"
Tabs signer1Tabs = EnvelopeHelpers.createSignerTabs(
        EnvelopeHelpers.createSignHere("/sn1/", ANCHOR_OFFSET_Y, ANCHOR_OFFSET_X));

Tabs signer2Tabs = EnvelopeHelpers.createSignerTabs(
        EnvelopeHelpers.createSignHere("/sn1/", ANCHOR_OFFSET_Y, ANCHOR_OFFSET_X_2));

// Create a signer recipient to sign the document, identified by name
// and email. We're setting the parameters via the object creation.
// 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.
Signer signer = new Signer();
signer.setEmail(signerEmail);
signer.setName(signerName);
signer.setRecipientId("1");
signer.setRoutingOrder("1");
signer.setTabs(signer1Tabs);

Signer signer2 = new Signer();
signer2.setEmail(signerEmail2);
signer2.setName(signerName2);
signer2.setRecipientId("2");
signer2.setRoutingOrder("2");
signer2.setTabs(signer2Tabs);

// The order in the docs array determines the order in the envelope
EnvelopeDefinition envelope = new EnvelopeDefinition();
envelope.setEmailSubject("Please sign this document set");
envelope.setDocuments(Arrays.asList(
        EnvelopeHelpers.createDocumentFromFile(DOCX_DOCUMENT_FILE_NAME, DOCX_DOCUMENT_NAME,
                "2"),
        EnvelopeHelpers.createDocumentFromFile(PDF_DOCUMENT_FILE_NAME, PDF_DOCUMENT_NAME,
                "3")));
envelope.setRecipients(EnvelopeHelpers.createTwoSigners(signer, signer2));

// Add the workflow to delay the second recipient

String delayFormatted = delay + ":00:00";
EnvelopeDelayRule rule = new EnvelopeDelayRule();
rule.setDelay(delayFormatted);

DelayedRouting delayedRouting = new DelayedRouting();
delayedRouting.setRules(List.of(rule));

WorkflowStep workflowStep = new WorkflowStep();
workflowStep.setAction("pause_before");
workflowStep.setTriggerOnItem("routing_order");
workflowStep.setItemId("2");
workflowStep.setStatus("pending");
workflowStep.setDelayedRouting(delayedRouting);

Workflow workflow = new Workflow();
workflow.setWorkflowSteps(List.of(workflowStep));
envelope.setWorkflow(workflow);

// Request that the envelope be sent by setting |status| to "sent".
// To request that the envelope be created as a draft, set to "created"
envelope.setStatus(status);

return envelope;
```

**`Node.js`**

```javascript title="Node.js"
let docPdfBytes;
// read files from a local directory
// The reads could raise an exception if the file is not available!
docPdfBytes = fs.readFileSync(args.docPdf);

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

// add the document
let doc = new docusign.Document();
let docb64 = Buffer.from(docPdfBytes).toString('base64');
doc.documentBase64 = docb64;
doc.name = 'Lorem Ipsum'; // can be different from actual file name
doc.fileExtension = 'pdf'; // Source data format. Signed docs are always pdf.
doc.documentId = '1'; // a label used to reference the doc

// The order in the docs array determines the order in the envelope
env.documents = [doc];

// 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.signer1Email,
  name: args.signer1Name,
  recipientId: '1',
  routingOrder: '1',
});

let signer2 = docusign.Signer.constructFromObject({
  email: args.signer2Email,
  name: args.signer2Name,
  recipientId: '2',
  routingOrder: '2',
});
// 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 a workflow model
// Add the workflow rule that sets the delay in hours before the envelope is routed to the second signer
let delayTime = '0.' + args.delay.toString() + ':00:00';
const rule = docusign.EnvelopeDelayRule.constructFromObject({
  delay: delayTime
});
const delayedRouting = docusign.DelayedRouting.constructFromObject({
  rules: [rule]
});

// Create a workflow model
const workflowStep = docusign.WorkflowStep.constructFromObject({
  action: 'pause_before',
  triggerOnItem: 'routing_order',
  itemId: 2,
  delayedRouting: delayedRouting
});
const workflow = docusign.Workflow.constructFromObject({
  workflowSteps: [workflowStep]
});
env.workflow = workflow;

// Create signHere fields (also known as tabs) on the document,
// We're using anchor (autoPlace) positioning for the signHere1 tab
// and we're using absolute positioning for the signHere2 tab.
//
// The DocuSign platform searches throughout your envelope's
// documents for matching anchor strings.
let signHere1 = docusign.SignHere.constructFromObject({
    anchorString: '/sn1/',
    anchorYOffset: '10',
    anchorUnits: 'pixels',
    anchorXOffset: '20',
  });
  let signHere2 = docusign.SignHere.constructFromObject({
    xPosition: '320',
    yPosition: '175',
    pageNumber: '1',
    documentId: '1'
  });
// Tabs are set per recipient / signer
let signer1Tabs = docusign.Tabs.constructFromObject({
  signHereTabs: [signHere1],
});
signer1.tabs = signer1Tabs;

let signer2Tabs = docusign.Tabs.constructFromObject({
  signHereTabs: [signHere2],
});
signer2.tabs = signer2Tabs;

// Add the recipients to the envelope object
let recipients = docusign.Recipients.constructFromObject({
  signers: [signer1, signer2]
});
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 to "created"
env.status = 'sent';
```

**`PHP`**

```php title="PHP"
# Create the signer recipient models
$signer1 = new Signer([
    'email' => $args['signer1_email'], 'name' => $args['signer1_name'],
    'recipient_id' => "1", 'routing_order' => "1"
    ]);
$signer2 = new Signer([
    'email' => $args['signer2_email'], 'name' => $args['signer2_name'],
    'recipient_id' => "2", 'routing_order' => "2"
    ]);
# 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.

return DelayedRoutingService::addSignerToTheDelivery($signer1, $signer2, $envelope_definition, $args);
    }

    public static function addSignerToTheDelivery($signer1, $signer2, $envelope_definition, $args)
    {
# 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.
$sign_here1 = new SignHere([
                               'anchor_string' => '**signature_1**', 'anchor_units' => 'pixels',
                               'anchor_y_offset' => '10', 'anchor_x_offset' => '20']);
$sign_here2 = new SignHere([
                               'anchor_string' => '/sn1/', 'anchor_units' =>  'pixels',
                               'anchor_y_offset' => '10', 'anchor_x_offset' => '20']);
$sign_here3 = new SignHere([
                               'anchor_string' => '**signature_1**', 'anchor_units' => 'pixels',
                               'anchor_y_offset' => '10', 'anchor_x_offset' => '120']);
$sign_here4 = new SignHere([
                               'anchor_string' => '/sn1/', 'anchor_units' =>  'pixels',
                               'anchor_y_offset' => '10', 'anchor_x_offset' => '120']);

# Add the tabs model (including the sign_here tabs) to the signer
# The Tabs object wants arrays of the different field/tab types
$signer1->setTabs(new Tabs([
                               'sign_here_tabs' => [$sign_here1, $sign_here2]]));

$signer2->setTabs(new Tabs([
                               'sign_here_tabs' => [$sign_here3, $sign_here4]]));

# Add the recipients to the envelope object
$recipients = new Recipients([
                                 'signers' => [$signer1, $signer2]]);
$envelope_definition->setRecipients($recipients);

# Add the workflow to delay the second recipient
$delay = (string)$args['delay'] . ':00:00';
$rule = new EnvelopeDelayRuleApiModel([
    'delay' => $delay
]);
$delayed_routing = new DelayedRoutingApiModel([
    'rules' => [$rule]
]);
$workflow_step = new WorkflowStep([
    'action' => 'pause_before',
    'trigger_on_item' => 'routing_order',
    'item_id' => '2',
    'delayed_routing' => $delayed_routing
]);

$workflow = new Workflow([
    'workflow_steps'  =>  [$workflow_step]
]);

$envelope_definition->setWorkflow($workflow);
# Request that the envelope be sent by setting |status| to "sent".
# To request that the envelope be created as a draft, set to "created"
$envelope_definition->setStatus($args["status"]);
```

**`PowerShell`**

```text title="PowerShell"
@{
    emailSubject = "Please sign this document set";
    documents    = @(
        @{
            documentBase64 = "$(Get-Content $docBase64)";
            name           = "Lorem Ipsum";
            fileExtension  = "pdf";
            documentId     = "1";
        }; );
    workflow = @{
        workflowSteps = @(
            @{
                action = "pause_before";
                triggerOnItem = "routing_order";
                itemId = "2";
                delayedRouting = @{
                    rules = @(
                        @{
                            delay = $DelayTimeSpan.ToString();
                        };
                    );
                };
            };
        );
    };
    recipients   = @{
        signers      = @(
            @{
                email        = $variables.SIGNER_EMAIL;
                name         = $variables.SIGNER_NAME;
                recipientId  = "1";
                routingOrder = "1";
                tabs         = @{
                    signHereTabs = @(
                        @{
                            anchorString  = "/sn1/";
                            anchorUnits   = "pixels";
                            anchorXOffset = "20";
                            anchorYOffset = "10";
                        };
                    );
                };
            };
            @{
                email        = $Signer2Email;
                name         = $Signer2Name;
                recipientId  = "2";
                routingOrder = "2";
                tabs         = @{
                    signHereTabs = @(
                        @{
                            anchorString  = "/sn1/";
                            anchorUnits   = "pixels";
                            anchorXOffset = "120";
                            anchorYOffset = "10";
                        };
                    );
                };
            };
        );
    };
    status       = "sent";
} | ConvertTo-Json -Depth 32 > $requestData
```

**`Python`**

```python title="Python"
env = EnvelopeDefinition(
    email_subject="Please sign this document"
)

with open(path.join(demo_docs_path, doc_pdf_path), "rb") as file:
    doc1_pdf_bytes = file.read()
doc1_b64 = base64.b64encode(doc1_pdf_bytes).decode("ascii")

# Create the document models
document1 = Document(  # create the DocuSign document object
    document_base64=doc1_b64,
    name="Lorem Ipsum",  # can be different from actual file name
    file_extension="pdf",  # many different document types are accepted
    document_id="1"  # a label used to reference the doc
)
# The order in the docs array determines the order in the envelope
env.documents = [document1]

# Create the signer recipient model
signer1 = Signer(
    email=args["signer_email"],
    name=args["signer_name"],
    recipient_id="1",
    routing_order="1"
)
# routingOrder (lower means earlier) determines the order of deliveries
# to the recipients.

# create a second recipient
signer2 = Signer(
    email=args["signer_email2"],
    name=args["signer_name2"],
    recipient_id="2",
    routing_order="2"
)

# 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.

sign_here1 = SignHere(
    anchor_string="/sn1/",
    anchor_units="pixels",
    anchor_y_offset="10",
    anchor_x_offset="20"
)

sign_here2 = SignHere(
    x_position = "320",
    y_position = "175",
    page_number = "1",
    document_id = "1"
)

# 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 = Tabs(sign_here_tabs=[sign_here1])
signer2.tabs = Tabs(sign_here_tabs=[sign_here2])

# Add the recipients to the envelope object
recipients = Recipients(signers=[signer1, signer2])
env.recipients = recipients

delay = "0." + args["delay"] + ":00:00"

workflow = Workflow()

workflow_step = WorkflowStep()
workflow_step.action = "pause_before"
workflow_step.trigger_on_item = "routing_order"
workflow_step.item_id = "2"
delayed_routing = DelayedRouting(rules=[EnvelopeDelayRule(delay=delay)])
workflow_step.delayed_routing = delayed_routing
workflow.workflow_steps = [workflow_step]
env.workflow = workflow

# Request that the envelope be sent by setting |status| to "sent".
# To request that the envelope be created as a draft, set to "created"
env.status = args["status"]
```

**`Ruby`**

```ruby title="Ruby"
envelope_definition = DocuSign_eSign::EnvelopeDefinition.new

envelope_definition.email_subject = 'Please sign this document'

# Add the document
# Read file from a local directory
# The reads could raise an exception if the file is not available!
doc_pdf = Rails.application.config.doc_pdf
doc_b64 = Base64.encode64(File.binread(File.join('data', doc_pdf)))

# Create the document model
document = DocuSign_eSign::Document.new(
  # Create the Docusign document object
  documentBase64: doc_b64,
  name: 'Lorem Ipsum', # Can be different from actual file name
  fileExtension: 'pdf', # Many different document types are accepted
  documentId: '1' # A label used to reference the doc
)

# The order in the docs array determines the order in the envelope
envelope_definition.documents = [document]

# Create the signer recipient model
signer1 = DocuSign_eSign::Signer.new
signer1.email = envelope_args[:signer1_email]
signer1.name = envelope_args[:signer1_name]
signer1.recipient_id = '1'
signer1.routing_order = '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

signer2 = DocuSign_eSign::Signer.new
signer2.email = envelope_args[:signer2_email]
signer2.name = envelope_args[:signer2_name]
signer2.recipient_id = '2'
signer2.routing_order = '2'

# Create signHere fields (also known as tabs) on the document
# We're using anchor (autoPlace) positioning for the sign_here1 tab
# and we're using absolute positioning for the sign_here2 tab.
#
# The Docusign platform searches throughout your envelope's documents for matching
# anchor strings.
sign_here1 = DocuSign_eSign::SignHere.new(
  anchorString: '/sn1/',
  anchorYOffset: '10',
  anchorUnits: 'pixels',
  anchorXOffset: '20'
)

sign_here2 = DocuSign_eSign::SignHere.new(
  xPosition: '320',
  yPosition: '175',
  pageNumber: '1',
  documentId: '1'
)

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

signer2_tabs = DocuSign_eSign::Tabs.new({
                                          signHereTabs: [sign_here2]
                                        })

signer1.tabs = signer1_tabs
signer2.tabs = signer2_tabs

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

envelope_definition.recipients = recipients

# Create recipientRules model
delay_time = "0.#{envelope_args[:delay]}:00:00"
rule = DocuSign_eSign::EnvelopeDelayRule.new(delay: delay_time)

delayed_routing = DocuSign_eSign::DelayedRouting.new(rules: [rule])

# Create a workflow model
workflow_step = DocuSign_eSign::WorkflowStep.new(
  action: 'pause_before',
  triggerOnItem: 'routing_order',
  itemId: 2,
  delayedRouting: delayed_routing
)
workflow = DocuSign_eSign::Workflow.new(workflowSteps: [workflow_step])
# Add the workflow to the envelope object
envelope_definition.workflow = workflow

# 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.status = envelope_args[:status]
envelope_definition
```

## Step 3. Call the eSignature REST API

Now that you have constructed your API headers and request body, you can schedule the envelope with the [Envelopes:create](/docs/esign-rest-api/reference/envelopes/envelopes/create) method. 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/eg036DelayedRouting.sh), [C#](https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/eSignature/Examples/DelayedRouting.cs), [Java](https://github.com/docusign/code-examples-java/blob/master/src/main/java/com/docusign/controller/eSignature/examples/EG036ControllerDelayedRouting.java), [Node.js](https://github.com/docusign/code-examples-node/blob/master/lib/eSignature/examples/delayedRouting.js), [PHP](https://github.com/docusign/code-examples-php/blob/master/src/Services/Examples/eSignature/DelayedRoutingService.php), [PowerShell](https://github.com/docusign/code-examples-powershell/blob/master/examples/eSignature/eg036DelayedRouting.ps1), [Python](https://github.com/docusign/code-examples-python/blob/master/app/eSignature/examples/eg036_delayed_routing.py), or [Ruby](https://github.com/docusign/code-examples-ruby/blob/master/app/services/e_sign/eg036_delayed_routing_service.rb).

**`Bash`**

```bash title="Bash"
curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
     --header "Content-Type: application/json" \
     --data-binary @${request_data} \
     --request POST ${base_path}/v2.1/accounts/${account_id}/envelopes \
     --output $response
```

**`C#`**

```csharp title="C#"
EnvelopesApi envelopesApi = new EnvelopesApi(docuSignClient);
var results = envelopesApi.CreateEnvelopeWithHttpInfo(accountId, env);
results.Headers.TryGetValue("X-RateLimit-Remaining", out string remaining);
results.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);
}
```

**`Java`**

```java title="Java"
var results = envelopesApi.createEnvelopeWithHttpInfo(
        session.getAccountId(),
        envelope,
        envelopesApi.new CreateEnvelopeOptions());
Map<String, List<String>> headers = results.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);
}
```

**`Node.js`**

```javascript title="Node.js"
let 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()}`);
   }
  });
```

**`PHP`**

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

$remaining = $envelopeResponse[2]['X-RateLimit-Remaining'] ?? null;
$reset = $envelopeResponse[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"
Invoke-RestMethod `
    -Uri "${apiUri}/v2.1/accounts/${accountId}/envelopes" `
    -Method 'POST' `
    -Headers @{
    'Authorization' = "Bearer $accessToken";
    'Content-Type'  = "application/json";
} `
    -InFile (Resolve-Path $requestData).Path `
    -OutFile $response
```

**`Python`**

```python title="Python"
api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"])
envelopes_api = EnvelopesApi(api_client)
(results, status, headers) = envelopes_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.

In addition, the signer receives an email containing a signing link that they can use to open and electronically sign a document using the Docusign mobile app or the Docusign website. After signing is complete, the recipient receives a carbon copy (CC) of the email that includes all of the completed and signed documents.

**`Sample response`**

```json title="Sample response"
{
    "envelopeId":"ceae82a7-xxxx-xxxx-xxxx-2cba454ad40b",
    "uri":"/envelopes/ceae82a7-xxxx-xxxx-xxxx-2cba454ad40b",
    "statusDateTime":"2022-02-28T23:12:07.9830000Z",
    "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 [Delayed routing](/docs/esign-rest-api/esign101/concepts/recipients/delayed-routing).
* Learn [How to schedule an envelope](/docs/esign-rest-api/how-to/schedule-an-envelope).
* 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.