> 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 pause a signature workflow

> Demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient.

eSignature REST API 2.1 only

This topic demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient. For information on resuming a workflow, see [How to unpause a signature workflow](/docs/esign-rest-api/how-to/unpause-workflow).

> **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. |
| \{SIGNER1_EMAIL}  | A string value for the email address of the first recipient.                                                                                                                                                                                                                                                           |
| \{SIGNER2_EMAIL}  | A string value for the email address of the second recipient.                                                                                                                                                                                                                                                          |
| \{SIGNER1_NAME}   | A string value for the name of the first recipient.                                                                                                                                                                                                                                                                    |
| \{SIGNER2_NAME}   | A string value for the name of the second recipient.                                                                                                                                                                                                                                                                   |

## 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"
EnvelopesApi envelopesApi = createEnvelopesApi(this.session.getBasePath(), this.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 = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.add("Authorization", "Bearer $oAuthAccessToken")
$headers.add("Accept", "application/json")
$headers.add("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[:basePath]

api_client = DocuSign_eSign::ApiClient.new configuration
api_client.set_default_header('Authorization', "Bearer #{args[:accessToken]}")
```

## Step 3. Construct the request body

Next, create the request body. To create an envelope using the eSignature API, you need to construct an envelope body in JSON format. Replace \{SIGNER1_EMAIL}, \{SIGNER1_NAME}, \{SIGNER2_EMAIL}, and \{SIGNER2_NAME} with your recipients’ data in the JSON request body.

The `workflow` section contains the information necessary to determine the action; in this case, `pause_before`, and the trigger `routing_order`, will cause the workflow to pause before the envelope is sent to the second recipient.

**`Bash`**

```bash title="Bash"
printf \
  '{
  "documents": [
    {
      "documentBase64": "DQoNCg0KDQoJCVdlbGNvbWUgdG8gdGhlIERvY3VTaWduIFJlY3J1aXRpbmcgRXZlbnQNCgkJDQoJCQ0KCQlQbGVhc2UgU2lnbiBpbiENCgkJDQoJCQ0KCQk=",
      "documentId": "1",
      "fileExtension": "txt",
      "name": "Welcome"
    }
  ],
  "emailSubject": "EnvelopeWorkflowTest",
  "workflow":
  {
    "workflowSteps":
    [
        {
            "action": "pause_before",
            "triggerOnItem": "routing_order",
            "itemId": "2"
        }
    ]
  },
  "recipients": {
    "signers": [
      {
        "email": "'"${SIGNER1_EMAIL}"'",
        "name": "'"${SIGNER1_NAME}"'",
        "recipientId": "1",
        "routingOrder": "1",
        "tabs": {
          "signHereTabs": [
            {
              "documentId": "1",
              "pageNumber": "1",
              "tabLabel": "Sign Here",
              "xPosition": "200",
              "yPosition": "200"
            }
          ]
        }
      },
      {
        "email": "'"${SIGNER2_EMAIL}"'",
        "name": "'"${SIGNER2_NAME}"'",
        "recipientId": "2",
        "routingOrder": "2",
        "tabs": {
          "signHereTabs": [
            {
              "documentId": "1",
              "pageNumber": "1",
              "tabLabel": "Sign Here",
              "xPosition": "300",
              "yPosition": "200"
            }
          ]
        }
      }
    ]
  },
"status": "Sent"
}
' >>$request_data
```

**`C#`**

```csharp title="C#"
var envelope = MakeEnvelope(recipient1Email, recipient1Name, recipient2Email, recipient2Name);
        private static EnvelopeDefinition MakeEnvelope(string recipient1Email, string recipient1Name, string recipient2Email, string recipient2Name)
        {
var document = new Document()
{
    DocumentBase64 = "DQoNCg0KDQoJCVdlbGNvbWUgdG8gdGhlIERvY3VTaWduIFJlY3J1aXRpbmcgRXZlbnQNCgkJDQoJCQ0KCQlQbGVhc2UgU2lnbiBpbiENCgkJDQoJCQ0KCQk=",
    DocumentId = "1",
    FileExtension = "txt",
    Name = "Welcome",
};

var workflowStep = new WorkflowStep()
{
    Action = "pause_before",
    TriggerOnItem = "routing_order",
    ItemId = "2",
};

var signer1 = new Signer()
{
    Email = recipient1Email,
    Name = recipient1Name,
    RecipientId = "1",
    RoutingOrder = "1",
    Tabs = new Tabs
    {
        SignHereTabs = new List<SignHere>
        {
            new SignHere()
            {
                DocumentId = "1",
                PageNumber = "1",
                TabLabel = "Sign Here",
                XPosition = "200",
                YPosition = "200",
            },
        },
    },
};

var signer2 = new Signer()
{
    Email = recipient2Email,
    Name = recipient2Name,
    RecipientId = "2",
    RoutingOrder = "2",
    Tabs = new Tabs
    {
        SignHereTabs = new List<SignHere>
        {
            new SignHere()
            {
                DocumentId = "1",
                PageNumber = "1",
                TabLabel = "Sign Here",
                XPosition = "300",
                YPosition = "200",
            },
        },
    },
};

var envelopeDefinition = new EnvelopeDefinition()
{
    Documents = new List<Document> { document },
    EmailSubject = "EnvelopeWorkflowTest",
    Workflow = new Workflow { WorkflowSteps = new List<WorkflowStep> { workflowStep } },
    Recipients = new Recipients { Signers = new List<Signer> { signer1, signer2 } },
    Status = "Sent",
};

return envelopeDefinition;
        }
```

**`Java`**

```java title="Java"
public static EnvelopeDefinition createEnvelope(
        String signerName,
        String signerEmail,
        String signerName2,
        String signerEmail2) throws IOException {
    Document document = EnvelopeHelpers.createDocumentFromFile(DOCUMENT_FILE_NAME, DOCUMENT_NAME, DOCUMENT_ID);

    WorkflowStep workflowStep = new WorkflowStep();
    workflowStep.setAction(EnvelopeHelpers.WORKFLOW_STEP_ACTION_PAUSE);
    workflowStep.setTriggerOnItem(EnvelopeHelpers.WORKFLOW_TRIGGER_ROUTING_ORDER);
    workflowStep.setItemId("2");

    Workflow workflow = new Workflow();
    workflow.setWorkflowSteps(Collections.singletonList(workflowStep));

    SignHere signHere1 = new SignHere();
    signHere1.setName("SignHereTabs");
    signHere1.setXPosition("200");
    signHere1.setYPosition("200");
    signHere1.setTabLabel("Sign Here");
    signHere1.setPageNumber("1");
    signHere1.setDocumentId(document.getDocumentId());

    Signer signer1 = new Signer();
    signer1.setName(signerName);
    signer1.setEmail(signerEmail);
    signer1.setRoutingOrder("1");
    signer1.setRecipientId("1");
    signer1.setTabs(EnvelopeHelpers.createSignerTabs(signHere1));

    SignHere signHere2 = new SignHere();
    signHere2.setName("SignHereTabs");
    signHere2.setXPosition("300");
    signHere2.setYPosition("200");
    signHere2.setTabLabel("Sign Here");
    signHere2.setPageNumber("1");
    signHere2.setDocumentId(document.getDocumentId());

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

    Recipients recipients = new Recipients();
    recipients.setSigners(Arrays.asList(signer1, signer2));

    EnvelopeDefinition envelope = new EnvelopeDefinition();
    envelope.setEmailSubject("EnvelopeWorkflowTest");
    envelope.setDocuments(Collections.singletonList(document));
    envelope.setStatus(EnvelopeHelpers.ENVELOPE_STATUS_SENT);
    envelope.setRecipients(recipients);
    envelope.setWorkflow(workflow);

    return envelope;
}
```

**`Node.js`**

```javascript title="Node.js"
const documentTxtExample = fs.readFileSync(args.docFile);
const encodedExampleDocument =
  Buffer.from(documentTxtExample).toString('base64');
const document = docusign.Document.constructFromObject({
  documentBase64: encodedExampleDocument,
  name: 'Welcome',
  fileExtension: 'txt',
  documentId: 1,
});

// Create signHere fields (also known as tabs) on the documents
const signHere1 = docusign.SignHere.constructFromObject({
  documentId: 1,
  pageNumber: 1,
  tabLabel: 'Sign Here',
  xPosition: 200,
  yPosition: 200,
});
const signHere2 = docusign.SignHere.constructFromObject({
  documentId: 1,
  pageNumber: 1,
  tabLabel: ' Sign Here',
  xPosition: 300,
  yPosition: 200,
});

// Create the signer recipient models
// routingOrder (lower means earlier) determines the order of deliveries
// to the recipients.
// Also add the tabs model (including the sign_here tabs) to the signer
const signer1 = docusign.Signer.constructFromObject({
  email: args['signer1Email'],
  name: args['signer1Name'],
  recipientId: 1,
  routingOrder: 1,
  tabs: docusign.Tabs.constructFromObject({
    signHereTabs: [signHere1],
  }),
});
const signer2 = docusign.Signer.constructFromObject({
  email: args['signer2Email'],
  name: args['signer2Name'],
  recipientId: 2,
  routingOrder: 2,
  tabs: docusign.Tabs.constructFromObject({
    signHereTabs: [signHere2],
  }),
});

// The envelope has two recipients: recipient 1 - signer1 and recipient 2 - signer2.
// The envelope will be sent first to the signer1.
// After it is signed, a signature workflow will be paused.
// After resuming (unpause) the signature workflow will send to the second recipient
const recipients = docusign.Recipients.constructFromObject({
  signers: [signer1, signer2],
});

// Create a workflow model
// Signature workflow will be paused after it is signed by the first signer
const workflowStep = docusign.WorkflowStep.constructFromObject({
  action: 'pause_before',
  triggerOnItem: 'routing_order',
  itemId: 2,
});
const workflow = docusign.Workflow.constructFromObject({
  workflowSteps: [workflowStep],
});

// Put our created values (document, status, workflow, recipients)
// to our EnvelopeDefinition object.
// 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"
return docusign.EnvelopeDefinition.constructFromObject({
  emailSubject: 'EnvelopeWorkflowTest',
  documents: [document],
  status: args.status,
  workflow,
  recipients,
});
```

**`PHP`**

```php title="PHP"
$envelope_args = $args['envelope_args'];
$envelope_api = $clientService->getEnvelopeApi();
$envelope_definition = PauseSignatureWorkflowService::makeEnvelope($envelope_args, $demoDocsPath);
    public static function makeEnvelope(array $envelope_args, $demoDocsPath): EnvelopeDefinition
    {
# The envelope has two recipients
# Recipient 1 - signer1
# Recipient 2 - signer2
# The envelope will be sent first to the signer1
# After it is signed, a signature workflow will be paused
# After resuming (unpause) the signature workflow will send to the second recipient

# Create the top-level envelope definition
$envelope_definition = new EnvelopeDefinition([
    'email_subject' => "EnvelopeWorkflowTest",
]);

# Read the file
$content_bytes = file_get_contents($demoDocsPath . $GLOBALS['DS_CONFIG']['doc_txt']);
$base64_file_content = base64_encode($content_bytes);

# Create the document model
$document = new Document([ # Create the DocuSign document object
    'document_base64' => $base64_file_content,
    'name' => 'Example document', # Can be different from actual file name
    'file_extension' => 'txt', # 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.
$envelope_definition->setDocuments([$document, ]);

# Create the signer recipient models
# routing_order (lower means earlier) determines the order of deliveries
# to the recipients.
$signer1 = new Signer([ # The signer1
    'email' => $envelope_args['signer1_email'],
    'name' => $envelope_args['signer1_name'],
    'recipient_id' => "1",
    'routing_order' => "1",
]);

$signer2 = new Signer([ # The signer2
    'email' => $envelope_args['signer2_email'],
    'name' => $envelope_args['signer2_name'],
    'recipient_id' => "2",
    'routing_order' => "2",
]);

# Create SignHere fields (also known as tabs) on the documents.
$sign_here1 = new SignHere([
    'document_id' => "1",
    'page_number' => "1",
    'tab_label' => "Sign Here",
    'x_position' => "200",
    'y_position' => "200",
]);

$sign_here2 = new SignHere([
    'document_id' => "1",
    'page_number' => "1",
    'tab_label' => "Sign Here",
    'x_position' => "300",
    'y_position' => "200",
]);

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

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

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

# Create a workflow model
# Signature workflow will be paused after it is signed by the first signer
$workflow_step = new WorkflowStep([
    'action' => "pause_before",
    'trigger_on_item' => "routing_order",
    'item_id' => "2",
]);
$workflow = new Workflow([
    'workflow_steps' => [$workflow_step, ],
]);
# Add the workflow to the envelope object
$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($envelope_args['status']);
return $envelope_definition;
    }
```

**`PowerShell`**

```text title="PowerShell"
@{
    documents    =
    @(
        @{
            "documentBase64" = "DQoNCg0KDQoJCVdlbGNvbWUgdG8gdGhlIERvY3VTaWduIFJlY3J1aXRpbmcgRXZlbnQNCgkJDQoJCQ0KCQlQbGVhc2UgU2lnbiBpbiENCgkJDQoJCQ0KCQk=";
            "documentId"     = "1";
            "fileExtension"  = "txt";
            "name"           = "Welcome"
        };
    );
    emailSubject = "EnvelopeWorkflowTest";
    "workflow"   =
    @{
        "workflowSteps" =
        @(
            @{
                "action"        = "pause_before";
                "triggerOnItem" = "routing_order";
                "itemId"        = "2"
            };
        );
    };
    recipients   = @{
        signers =
        @(
            @{
                email        = $SIGNER1_EMAIL;
                name         = $SIGNER1_NAME;
                recipientId  = "1";
                routingOrder = "1";
                tabs         = @{
                    signHereTabs = @(
                        @{
                            documentId = "1";
                            pageNumber = "1";
                            tabLabel   = "Sign Here";
                            xPosition  = "200";
                            yPosition  = "200"
                        };
                    );
                };
            };
            @{
                email        = $SIGNER2_EMAIL;
                name         = $SIGNER2_NAME;
                recipientId  = "2";
                routingOrder = "2";
                tabs         =
                @{
                    signHereTabs =
                    @(
                        @{
                            documentId = "1";
                            pageNumber = "1";
                            tabLabel   = "Sign Here";
                            xPosition  = "300";
                            yPosition  = "200"
                        };
                    );
                };
            };
        );
    };
    status       = "sent"
} | ConvertTo-Json -Depth 32 > $requestData
```

**`Python`**

```python title="Python"
env = EnvelopeDefinition(email_subject="EnvelopeWorkflowTest")

# Read file from a local directory
# The reads could raise an exception if the file is not available!
with open(path.join(demo_docs_path, DS_CONFIG["doc_txt"]), "rb") as file:
    doc_docx_bytes = file.read()
doc_b64 = base64.b64encode(doc_docx_bytes).decode("ascii")

# Create the document model.
document = Document(  # Create the DocuSign document object
    document_base64=doc_b64,
    name="Welcome",  # Can be different from actual file name
    file_extension="txt",  # Many different document types are accepted
    document_id="1"  # The label used to reference the doc
)

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

# Create the signer recipient models
# routing_order (lower means earlier) determines the order of deliveries
# to the recipients.
signer1 = Signer(
    email=args["signer1_email"],
    name=args["signer1_name"],
    recipient_id="1",
    routing_order="1"
)
signer2 = Signer(
    email=args["signer2_email"],
    name=args["signer2_name"],
    recipient_id="2",
    routing_order="2"
)

# Create SignHere fields (also known as tabs) on the documents.
sign_here1 = SignHere(
    document_id="1",
    page_number="1",
    tab_label="Sign Here",
    x_position="200",
    y_position="200"
)

sign_here2 = SignHere(
    document_id="1",
    page_number="1",
    tab_label="Sign Here",
    x_position="300",
    y_position="200"
)

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

# Create a workflow model
# Signature workflow will be paused after it is signed by the first signer
workflow_step = WorkflowStep(
    action="pause_before",
    trigger_on_item="routing_order",
    item_id="2"
)
workflow = Workflow(workflow_steps=[workflow_step, ])
# Add the workflow to the envelope object
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"]
return env
```

**`Ruby`**

```ruby title="Ruby"
envelope_definition = DocuSign_eSign::EnvelopeDefinition.new(emailSubject: 'EnvelopeWorkflowTest')

# Create the document model.
document = DocuSign_eSign::Document.new(
  documentBase64: 'DQoNCg0KDQoJCVdlbGNvbWUgdG8gdGhlIERvY3VTaWduIFJlY3J1aXRpbmcgRXZlbnQNCgkJDQoJCQ0KCQlQbGVhc2UgU2lnbiBpbiENCgkJDQoJCQ0KCQk=',
  documentId: 1,
  fileExtension: 'txt',
  name: 'Welcome'
)

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

# Create the signer recipient models
# routing_order (lower means earlier) determines the order of deliveries
# to the recipients.
signer_1 = DocuSign_eSign::Signer.new(
  email: signers[:signerEmail1],
  name: signers[:signerName1],
  recipientId: 1,
  routingOrder: 1
)
signer_2 = DocuSign_eSign::Signer.new(
  email: signers[:signerEmail2],
  name: signers[:signerName2],
  recipientId: 2,
  routingOrder: 2
)

# Create SignHere fields (also known as tabs) on the documents.
sign_here_1 = DocuSign_eSign::SignHere.new(
  documentId: 1,
  pageNumber: 1,
  tabLabel: 'Sign Here',
  xPosition: 200,
  yPosition: 200
)
sign_here_2 = DocuSign_eSign::SignHere.new(
  documentId: 1,
  pageNumber: 1,
  tabLabel: 'Sign Here',
  xPosition: 300,
  yPosition: 200
)

# Add the tabs models (including the sign_here tabs) to the signer
# The Tabs object uses arrays of the different field/tab types
signer_1.tabs = DocuSign_eSign::Tabs.new(
  signHereTabs: [sign_here_1]
)
signer_2.tabs = DocuSign_eSign::Tabs.new(
  signHereTabs: [sign_here_2]
)

# Add the recipients to the envelope object
recipients = DocuSign_eSign::Recipients.new(signers: [signer_1, signer_2])
envelope_definition.recipients = recipients

# Create a workflow model
# Signature workflow will be paused after it is signed by the first signer
workflow_step = DocuSign_eSign::WorkflowStep.new(
  action: 'pause_before',
  triggerOnItem: 'routing_order',
  itemId: 2
)
workflow = DocuSign_eSign::Workflow.new(workflowSteps: [workflow_step])
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 to "created"
envelope_definition.status = args[:status]
```

## Step 4. Call the eSignature REST API

Now that you have constructed your API headers and request body, you can make a request to the eSignature REST API endpoint and include the JSON body to create a new envelope. 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/eg032PauseSignatureWorkflow.sh), [C#](https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/eSignature/Examples/PauseSignatureWorkflow.cs), [Java](https://github.com/docusign/code-examples-java/blob/master/src/main/java/com/docusign/controller/eSignature/services/PauseSignatureWorkflowService.java), [Node.js](https://github.com/docusign/code-examples-node/blob/master/lib/eSignature/examples/pauseSignatureWorkflow.js), [PHP](https://github.com/docusign/code-examples-php/blob/master/src/Services/Examples/eSignature/PauseSignatureWorkflowService.php), [PowerShell](https://github.com/docusign/code-examples-powershell/blob/main/examples/eSignature/eg032PauseSignatureWorkflow.ps1), [Python](https://github.com/docusign/code-examples-python/blob/master/app/eSignature/examples/eg032_pause_signature_workflow.py), or [Ruby](https://github.com/docusign/code-examples-ruby/blob/main/app/services/e_sign/eg032_pauses_signature_workflow_service.rb).

**`Bash`**

```bash title="Bash"
Status=$(curl --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);
```

**`Java`**

```java title="Java"
EnvelopeSummary envelopeSummary = PauseSignatureWorkflowService.pauseSignatureWorkflow(
        envelopesApi,
        this.session.getAccountId(),
        envelope
);
```

**`Node.js`**

```javascript title="Node.js"
const envelopesApi = new docusign.EnvelopesApi(dsApiClient);
const envelope = await envelopesApi.createEnvelope(args.accountId, {
  envelopeDefinition,
}, (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"
$envelope = $envelope_api->createEnvelopeWithHttpInfo($args["account_id"], $envelope_definition);

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

**`Python`**

```python title="Python"
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"
envelopes_api = DocuSign_eSign::EnvelopesApi.new(api_client)
results, _status, headers = envelopes_api.create_envelope_with_http_info(
  args[:accountId],
  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"
Request:

{
  "documents": [
    {
      "documentBase64": "DQoNCg0KDQoJCVdlbGNvbWUgdG8gdGhlIERvY3VTaWduIFJlY3J1aXRpbmcgRXZlbnQNCgkJDQoJCQ0KCQlQbGVhc2UgU2lnbiBpbiENCgkJDQoJCQ0KCQk=",
      "documentId": "1",
      "fileExtension": "txt",
      "name": "Welcome"
    }
  ],
  "emailSubject": "EnvelopeWorkflowTest",
  "workflow":
  {
    "workflowSteps":
    [
        {
            "action": "pause_before",
            "triggerOnItem": "routing_order",
            "itemId": "2"
        }
    ]
  },
  "recipients": {
    "signers": [
      {
        "email": "FirstSigner@example.com",
        "name": "Felicity Signer",
        "recipientId": "1",
        "routingOrder": "1",
        "tabs": {
          "signHereTabs": [
            {
              "documentId": "1",
              "pageNumber": "1",
              "tabLabel": "Sign Here",
              "xPosition": "200",
              "yPosition": "200"
            }
          ]
        }
      },
      {
        "email": "PausedSigner@example.com",
        "name": "Paul Signer",
        "recipientId": "2",
        "routingOrder": "2",
        "tabs": {
          "signHereTabs": [
            {
              "documentId": "1",
              "pageNumber": "1",
              "tabLabel": "Sign Here",
              "xPosition": "300",
              "yPosition": "200"
            }
          ]
        }
      }
    ]
  },
"status": "Sent"
}
Envelope Id:  6909296e-xxxx-xxxx-xxxx-e02f22ea80ec
```

## 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 [Advanced Recipient Routing (ARR)](/docs/esign-rest-api/esign101/concepts/recipients/pause-unpause-workflow).
* See [How to unpause a signature workflow](/docs/esign-rest-api/how-to/unpause-workflow).
* See [How to use conditional recipients](/docs/esign-rest-api/how-to/use-conditional-recipients).
* 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.