> 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 bulk upload agreements

> Learn how to create and upload documents to a bulk upload job.

This topic demonstrates how to bulk upload agreements using Agreement Manager API.

## 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>/v1 Where \<domain> is api-d.docusign.com for the developer environment and api.docusign.com for production. |

## 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 OAuth grant types: Authorization Code Grant, Implicit Grant, and JSON Web Token (JWT) Grant. Choose the OAuth grant type appropriate for your scenario.

Agreement Manager OAuth access tokens are the same ones used for our [eSignature REST API](/docs/esign-rest-api/esign101/auth), although you must request one or more Agreement Manager scopes to call the Agreement Manager API. The endpoint calls made in this how-to require that you request the Agreement Manager-specific `adm_store_unified_repo_read` scope when obtaining your access token.

> **Note**
>
> See [Agreement Manager Authentication](/docs/agreement-manager-api/auth) for details and the full list of Agreement Manager scopes.

![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. Create bulk upload job and extract upload URLs

After you have a valid OAuth access token, you are ready to create a new bulk upload job. Make sure to substitute your valid OAuth access token for `{ACCESS_TOKEN}`, and to provide your base path and account ID for `{base_path}` and `{account_id}`.  This example uses 5 included documents; after the bulk upload job is created, one upload URL will be returned for each. Record these upload URLs and the bulk upload job ID, which will be needed for the next step.

**`Bash`**

```bash title="Bash"
printf \
'{
    "job_name": "Example bulk upload job",
    "expected_number_of_docs": 5,
    "language": "en-US"
}' >> $request_data

curl --request POST ${base_path}/accounts/${account_id}/upload/jobs \
     --header "Authorization: Bearer ${ACCESS_TOKEN}" \
     --header "Accept: application/json" \
     --header "Content-Type: application/json" \
     --data-binary @${request_data} \
     --output $response

# Extract job ID and upload URLs for each document
job_id=$(cat "$response" | grep -o '"id":"[^"]*' | head -1 | cut -d'"' -f4)
upload_urls=$(cat $response | grep -o '"upload_document":"[^"]*' | cut -d'"' -f4)
```

**`C#`**

```csharp title="C#"

        public static async Task<BulkJob> CreateBulkUpload(string basePath, string accessToken, string accountId, string jobName)
        {
            var client = IamClient.Builder()
                .WithServerUrl(basePath)
                .WithAccessToken(accessToken)
                .Build();

            var bulkUploadJob = new CreateBulkJob
            {
                JobName = jobName,
                ExpectedNumberOfDocs = 5,
                Language = "en-US",
            };

            return await client.AgreementManager.BulkJob.CreateBulkUploadJobAsync(bulkUploadJob, accountId);
        }
```

**`Java`**

```java title="Java"
@Override
protected Object doWork(WorkArguments args, ModelMap model, HttpServletResponse response)
        throws Exception {
    var accountId = session.getAccountId();
    var accessToken = user.getAccessToken();

    var jobInfo = NavigatorMethodsService.createBulkUploadJob(accountId, accessToken);
    session.setBulkJobId(jobInfo.getJobId());
    session.setBulkUploadUrls(jobInfo.getUploadUrls());

    return "redirect:/nav003/uploadDocuments";
}
```

**`PowerShell`**

```text title="PowerShell"
$demoFiles = @(
    (Join-Path $projectRoot "demo_documents/World_Wide_Corp_Battle_Plan_Trafalgar.docx"),
    (Join-Path $projectRoot "demo_documents/World_Wide_Corp_lorem.pdf"),
    (Join-Path $projectRoot "demo_documents/doc_1.html"),
    (Join-Path $projectRoot "demo_documents/Welcome.txt"),
    (Join-Path $projectRoot "demo_documents/Id.jpg")
)

$existingFiles = $demoFiles | Where-Object { Test-Path $_ }
if ($existingFiles.Count -eq 0) {
    Write-Output "No demo documents were found for upload."
    exit 0
}

$headers = @{
    Authorization = "Bearer $accessToken"
    Accept        = "application/json"
    "Content-Type" = "application/json"
}

$createBody = @{
    job_name                = "Example bulk upload job"
    expected_number_of_docs = $existingFiles.Count
    language                = "en-US"
} | ConvertTo-Json

$createResponse = Invoke-WebRequest `
    -Uri "$apiUri/accounts/$accountId/upload/jobs" `
    -Method POST `
    -Headers $headers `
    -Body $createBody

$createResponseText = $createResponse.Content
$createResponseJson = $createResponseText | ConvertFrom-Json
$jobId = $createResponseJson.id

$uploadUrlMatches = [regex]::Matches($createResponseText, '"upload_document"\s*:\s*"([^"]+)"')
$uploadUrls = @()
foreach ($match in $uploadUrlMatches) {
    $uploadUrls += ($match.Groups[1].Value -replace '\\/', '/')
}
```

## Step 3. Upload documents

Once the bulk upload job is created, you can begin adding documents by making PUT requests with the file binaries to the upload URLs returned in the previous step’s response.

**`Bash`**

```bash title="Bash"
# Array of demo documents to upload
declare -a demo_files=(
    "demo_documents/World_Wide_Corp_Battle_Plan_Trafalgar.docx"
    "demo_documents/World_Wide_Corp_lorem.pdf"
    "demo_documents/doc_1.html"
    "demo_documents/Welcome.txt"
    "demo_documents/Id.jpg"
)

# Convert to array (cross-platform: works on macOS and Linux)
upload_urls_array=()
while IFS= read -r url; do
    upload_urls_array+=("$url")
done <<<"$upload_urls"

# Upload each file
for i in "${!demo_files[@]}"; do
    file_path="${demo_files[$i]}"
    upload_url="${upload_urls_array[$i]}"

    # Extract filename from path
    filename=$(basename "$file_path")

    if [[ ! -f "$file_path" ]]; then
        echo "Skipping $filename - file not found: $file_path"
        continue
    fi

    if [[ -z "$upload_url" ]]; then
        echo "Skipping $filename - no upload URL found"
        continue
    fi

    case "$filename" in
        *.docx)
            content_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
            ;;
        *.pdf)
            content_type="application/pdf"
            ;;
        *.html)
            content_type="text/html"
            ;;
        *.txt)
            content_type="text/plain"
            ;;
        *.jpg|*.jpeg)
            content_type="image/jpeg"
            ;;
        *)
            content_type="application/octet-stream"
            ;;
    esac

    echo "Uploading $filename..."

    # Make PUT request with binary file content and required headers.
    curl --request PUT "$upload_url" \
         --header "x-ms-blob-type: BlockBlob" \
         --header "x-ms-meta-filename: ${filename}" \
         --header "Content-Type: ${content_type}" \
         --data-binary @"$file_path"
done
```

**`C#`**

```csharp title="C#"
public static async Task UploadDocuments(string[] uploadUrls, string[] filePaths)
{
    var httpClient = new HttpClient();
    var count = Math.Min(uploadUrls.Length, filePaths.Length);

    for (int i = 0; i < count; ++i)
    {
        string uploadUrl = uploadUrls[i];
        string filePath = filePaths[i];

        string fileName = Path.GetFileName(filePath);

        if (!File.Exists(filePath))
        {
            Console.WriteLine($"Skipping {fileName} - file not found: {filePath}");
            continue;
        }

        if (string.IsNullOrWhiteSpace(uploadUrl))
        {
            Console.WriteLine($"Skipping {fileName} - no upload URL found");
            continue;
        }

        using var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
        string contentType = GetContentType(fileName);

        var request = new HttpRequestMessage(HttpMethod.Put, uploadUrl);
        request.Headers.TryAddWithoutValidation("x-ms-blob-type", "BlockBlob");
        request.Headers.TryAddWithoutValidation("x-ms-meta-filename", fileName);
        request.Content = new StreamContent(fileStream);
        request.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);

        var response = await httpClient.SendAsync(request);
        if (!response.IsSuccessStatusCode)
        {
            string error = await response.Content.ReadAsStringAsync();

            Console.WriteLine(
                $"Failed to upload {fileName}. " +
                $"Status: {(int)response.StatusCode} {response.ReasonPhrase}. " +
                $"Response: {error}");

            continue;
        }
    }
}
```

**`Java`**

```java title="Java"
@GetMapping("/uploadDocuments")
public String getUploadDocuments(WorkArguments args, ModelMap model) throws Exception {
    super.onInitModel(args, model);
    return UPLOAD_DOCUMENTS_PAGE;
}

@PostMapping("/uploadDocuments")
public String postUploadDocuments(WorkArguments args, ModelMap model) throws Exception {
    if (session.getBulkUploadUrls() == null) {
        return "redirect:/nav003";
    }
    NavigatorMethodsService.uploadDocumentsToJob(session.getBulkUploadUrls());
    return "redirect:/nav003/completeUpload";
}
```

**`PowerShell`**

```text title="PowerShell"
for ($i = 0; $i -lt $existingFiles.Count; $i++) {
    $filePath = $existingFiles[$i]
    $uploadUrl = if ($i -lt $uploadUrls.Count) { $uploadUrls[$i] } else { $null }
    $fileName = [System.IO.Path]::GetFileName($filePath)

    if ([string]::IsNullOrWhiteSpace($uploadUrl)) {
        Write-Output "Skipping $fileName - no upload URL found"
        continue
    }

    $extension = [System.IO.Path]::GetExtension($filePath).ToLowerInvariant()
    $contentType = switch ($extension) {
        ".docx" { "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }
        ".pdf" { "application/pdf" }
        ".html" { "text/html" }
        ".txt" { "text/plain" }
        ".jpg" { "image/jpeg" }
        ".jpeg" { "image/jpeg" }
        default { "application/octet-stream" }
    }

    Write-Output "Uploading $fileName..."

    Invoke-WebRequest `
        -Uri $uploadUrl `
        -Method PUT `
        -Headers @{
            "x-ms-blob-type" = "BlockBlob"
            "x-ms-meta-filename" = $fileName
        } `
        -ContentType $contentType `
        -InFile $filePath | Out-Null
}
```

## Step 4. Mark the bulk upload job complete

After uploading each document to the bulk upload job, call the POST [BulkJob: uploadCompleteBulkJob](/docs/agreement-manager-api/reference/agreementmanager/bulkjob/uploadcompletebulkjob) endpoint to trigger ingestion of the documents and AI extraction.

> **Note**
>
> View the source code for this how-to on GitHub: [Bash](https://github.com/docusign/code-examples-bash/blob/master/examples/Navigator/eg003BulkUpload.sh), [C#](https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/Navigator/Controllers/Nav003BulkUploadController.cs), [Java](https://github.com/docusign/code-examples-java/blob/master/src/main/java/com/docusign/controller/navigator/examples/Nav003BulkUploadDocumentsController.java), [PowerShell](https://github.com/docusign/code-examples-powershell/blob/master/examples/Navigator/eg003BulkUpload.ps1).

**`Bash`**

```bash title="Bash"
curl --request POST "${base_path}/accounts/${account_id}/upload/jobs/${job_id}/actions/complete" \
     --header "Authorization: Bearer ${ACCESS_TOKEN}" \
     --header "Accept: application/json" \
     --header "Content-Type: application/json" \
     --output "$response"
```

**`C#`**

```csharp title="C#"
public static async Task<BulkJob> CompleteBulkUploadJob(string basePath, string accessToken, string accountId, string jobId)
{
    var client = IamClient.Builder()
        .WithServerUrl(basePath)
        .WithAccessToken(accessToken)
        .Build();

    return await client.AgreementManager.BulkJob.UploadCompleteBulkJobAsync(accountId, jobId);
}
```

**`Java`**

```java title="Java"
@GetMapping("/completeUpload")
public String getCompleteUpload(WorkArguments args, ModelMap model) throws Exception {
    super.onInitModel(args, model);
    return COMPLETE_UPLOAD_PAGE;
}

@PostMapping("/completeUpload")
public String postCompleteUpload(WorkArguments args, ModelMap model) throws Exception {
    var jobId = session.getBulkJobId();
    if (jobId == null) {
        return "redirect:/nav003";
    }
    var accountId = session.getAccountId();
    var accessToken = user.getAccessToken();

    var completeUploadResult = NavigatorMethodsService.completeBulkUploadJob(accountId, accessToken, jobId);

    var jsonAgreement = NavigatorMethodsService.serializeObjectToJson(completeUploadResult.bulkJob().orElseThrow());
    DoneExample.createDefault(getTextForCodeExampleByApiType().ExampleName)
            .withMessage(getTextForCodeExampleByApiType().AdditionalPage.get(1).ResultsPageText)
            .withJsonObject(jsonAgreement)
            .addToModel(model, config);

    return DONE_EXAMPLE_PAGE;
```

**`PowerShell`**

```text title="PowerShell"
$completeResponse = Invoke-WebRequest `
    -Uri "$apiUri/accounts/$accountId/upload/jobs/$jobId/actions/complete" `
    -Method POST `
    -Headers $headers
```

## 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"
{
    "id": "8d04f00b-xxxx-xxxx-xxxx-bd50c6345692",
    "name": "Example bulk upload job",
    "status": "UPLOAD_COMPLETE",
    "status_enum": [
        "OPEN",
        "UPLOAD_COMPLETE",
        "IN_PROGRESS",
        "COMPLETE",
        "FAILED",
        "CANCELED"
    ],
    "created_at": "2026-05-19T22:38:27.596695Z",
    "modified_at": "2026-05-19T22:38:27.596695Z",
    "expires_at": "2026-05-21T22:38:27.596695Z",
    "ttl_period": "P2D",
    "upload_settings": {
        "ai_extraction": true
    },
    "metadata": {
        "response_timestamp": "2026-05-19T22:38:51.558607395Z",
        "response_duration": 51
    }
}
```

## Next steps

* Learn how to [Unlock Your Historical Agreements: Agreement Manager API Bulk Ingestion Made Simple](https://www.docusign.com/blog/developers/navigator-api-bulk-ingestion-made-simple).
* See the Agreement Manager [Bulk Jobs API reference](/docs/agreement-manager-api/reference/agreementmanager#bulkjob).
* Learn about concepts of [bulk upload](/docs/agreement-manager-api/concepts/bulk-upload-agreements) in Agreement Manager API.