Skip to main content
Question

404 "The URL provided does not resolve to a resource" when creating envelope via REST API (Java/Spring RestTemplate)

  • July 30, 2026
  • 1 reply
  • 19 views

Forum|alt.badge.img

I'm getting a 404 The URL provided does not resolve to a resource when POSTing to create an envelope from a Spring Boot app using RestTemplate.

My URL is built like this:

java

String url = baseUrl + accountId + "/envelopes";
// baseUrl = https://na4.docusign.net/restapi/v2.1/

I'm sending a POST with a Bearer token and a JSON envelope body containing a base64 PDF document.

What I've tried: confirmed the access token is generated successfully, confirmed the account ID is correct.

Question: Is my endpoint path correct? Do I need an accounts/ segment, and how do I confirm the correct base_uri for my account's region?

Environment: Java 17, Spring Boot, DocuSign eSignature REST API v2.1.

1 reply

Forum|alt.badge.img

Hi there,

Thanks for sharing the details; the issue is with the endpoint path you’re using.

1. Correct envelope create endpoint

Right now your code is building:

String url = baseUrl + accountId + "/envelopes";
// baseUrl = https://na4.docusign.net/restapi/v2.1/

That produces:

https://na4.docusign.net/restapi/v2.1/{accountId}/envelopes

The correct eSignature REST API v2.1 endpoint for creating an envelope is:

POST /restapi/v2.1/accounts/{accountId}/envelopes

So you do need the accounts segment.

You can adjust your Java code to:

String baseUri = "https://na4.docusign.net"; // see section 3 for how to get this dynamically
String url = baseUri + "/restapi/v2.1/accounts/" + accountId + "/envelopes";

Make sure you’re including:

Authorization: Bearer {access_token}
Content-Type: application/json

and a valid JSON envelope definition (with your base64-encoded PDF document).

2. Why you’re seeing 404

If you call:

/restapi/v2.1/{accountId}/envelopes

(without /accounts/), that path doesn’t exist on the API, so Docusign responds with:

404 – The URL provided does not resolve to a resource

Adding /accounts/{accountId} to the path resolves this.

3. How to get the correct base_uri for your account/region

Instead of hardcoding https://na4.docusign.net, it’s best practice to derive the base URI from the OAuth userinfo endpoint for the access token you’re using.

For the demo (sandbox) environment:

GET https://account-d.docusign.com/oauth/userinfo
Authorization: Bearer {access_token}

For production:

GET https://account.docusign.com/oauth/userinfo
Authorization: Bearer {access_token}

The response includes an accounts array. A typical entry looks like:

{
"account_id": "12345678",
"account_name": "My Account",
"base_uri": "https://na4.docusign.net"
}

Use:

  • base_uri as your base (e.g., https://na4.docusign.net)
  • account_id as your accountId

Then build your envelope URL as:

String baseUri = userInfoAccount.getBaseUri();   // e.g., https://na4.docusign.net
String accountId = userInfoAccount.getAccountId();

String url = baseUri + "/restapi/v2.1/accounts/" + accountId + "/envelopes";

This ensures you always call the correct regional cluster for the account associated with that token.

If you’re still getting a 404 after updating the path, feel free to share the exact JSON error body (including errorCode and message) and we can help dig further.

Regards,
Marwan Badreldin
Developer Support Engineer II, Docusign