Skip to content

Uploads

Create an upload URL

Get a signed, single-use URL to PUT a PDF, DOCX or PNG file to, up to your account's maximum document size, then use the upload in an envelope.

POST
/ v1 / upload-urls

Upload a file from your server in two requests: describe the file to get a signed upload URL, then PUT the file’s bytes to that URL. The result is a temporary upload that you use as a document’s url.

Use this for files larger than 4.5 MB, up to your account’s maximum document size (10 MB by default). For smaller files, Create an upload is simpler: one call, at most 4.5 MB per request. Any API key works, test or live: uploads belong to your account, not to a mode.

How it works

  • The API checks media_type and size against your account’s limits when you request the upload URL, before you send any bytes.
  • Requesting an upload URL creates nothing: the PUT creates the upload. An upload URL you don’t use expires after five minutes.
  • The PUT must carry the size and SHA-256 you declared. Bytes that don’t match are refused.

How to upload a file

1

Request an upload URL

Read the file and compute its size in bytes and the SHA-256 of its bytes, as 64 lowercase hexadecimal characters. Send them with the file’s media_type to POST /v1/upload-urls.

The response has an upload_url to send the bytes to, the reference the upload will have, and expires_in, the seconds left to use upload_url (300).

2

PUT the bytes

Send a PUT request to upload_url before it expires. The body is the raw file bytes, exactly the ones you described, not a multipart form. Set these headers:

HeaderValue
Content-TypeThe media_type you sent
Content-LengthThe size you sent (most HTTP clients set it for you)
x-amz-content-sha256The sha256 you sent

The PUT needs no API key: the signed URL carries the authorization. A 2xx response means the file is stored and the upload exists. If the PUT fails, request a new upload URL and try again.

3

Use the upload in an envelope

Pass reference as the url of a document when you create an envelope:

Document in the create envelope request
{
  "url": "https://api.signatureapi.com/v1/uploads/upl_3JJz6t1o8A5YjX5VpnX27Z",
  "format": "pdf"
}
cURL
FILE=contract.pdf
SIZE=$(wc -c < "$FILE" | tr -d ' ')
SHA256=$(shasum -a 256 "$FILE" | cut -d ' ' -f 1)

RESPONSE=$(curl -s -X POST https://api.signatureapi.com/v1/upload-urls \
  -H "X-API-Key: $SIGNATUREAPI_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"media_type\": \"application/pdf\", \"size\": $SIZE, \"sha256\": \"$SHA256\"}")

curl -X PUT "$(echo "$RESPONSE" | jq -r .upload_url)" \
  -H "Content-Type: application/pdf" \
  -H "x-amz-content-sha256: $SHA256" \
  --data-binary "@$FILE"

echo "$RESPONSE" | jq -r .reference
TypeScript
import { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";

const bytes = await readFile("contract.pdf");
const sha256 = createHash("sha256").update(bytes).digest("hex");

const response = await fetch("https://api.signatureapi.com/v1/upload-urls", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.SIGNATUREAPI_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ media_type: "application/pdf", size: bytes.length, sha256 }),
});
const { upload_url, reference } = await response.json();

const put = await fetch(upload_url, {
  method: "PUT",
  headers: { "Content-Type": "application/pdf", "x-amz-content-sha256": sha256 },
  body: bytes,
});
if (!put.ok) throw new Error(`Upload failed: ${put.status} ${await put.text()}`);

console.log(reference); // the document url
Python
import hashlib
import os

import requests

with open("contract.pdf", "rb") as f:
    data = f.read()
sha256 = hashlib.sha256(data).hexdigest()

response = requests.post(
    "https://api.signatureapi.com/v1/upload-urls",
    headers={"X-API-Key": os.environ["SIGNATUREAPI_KEY"]},
    json={"media_type": "application/pdf", "size": len(data), "sha256": sha256},
)
upload = response.json()

put = requests.put(
    upload["upload_url"],
    headers={"Content-Type": "application/pdf", "x-amz-content-sha256": sha256},
    data=data,
)
put.raise_for_status()

print(upload["reference"])  # the document url

Request upload URLs from your server, not from the browser. The request needs your API key, which must never be exposed to the client.

Body Parameters

media_typestringrequired

The media type of the file.

  • application/pdf
  • application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • image/png

Example "application/pdf"

sizeintegerrequired

The size of the file in bytes, up to the account's maximum document size.

minimum 1Example 102400

sha256stringrequired

The SHA-256 hash of the file bytes, as 64 lowercase hexadecimal characters.

pattern ^[a-f0-9]{64}$Example "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"

Returns

Returns a 200 OK status code and the upload URL on success, or an error otherwise. A size over your account’s maximum document size returns a validation-error.

The signed, single-use URL to PUT the file bytes to, with content-type, content-length and x-amz-content-sha256 (the declared SHA-256), before it expires.

format uriExample "https://uploads.signatureapi.com/v1/uploads/upl_1sAAaVfabdt0esVjmSTmLA?token=example-signed-token"

referencestring

The upload's URL. It can be used as a document url once the PUT lands.

format uriExample "https://api.signatureapi.com/v1/uploads/upl_3joO7lxE8HVhOZmkCHFCxK"

expires_ininteger

The number of seconds until upload_url expires.

minimum 1Example 300

Once the PUT succeeds, reference works anywhere a document URL is accepted, and Retrieve an upload returns it. The upload is temporary and is deleted 24 hours after the PUT. To keep it for reuse across envelopes, store the upload with the upload ID, the last path segment of reference.

Errors on the PUT

The PUT is refused, and nothing is stored, when:

The body itself is also checked: bytes whose SHA-256 differs from x-amz-content-sha256 are refused with a 400.

Request a new upload URL for each new attempt.