Resources
Uploads
Upload a local PDF, DOCX, or PNG for an envelope, keep a template permanently, and check its placeholders with the SignatureAPI CLI uploads commands.
The uploads commands turn a file on your machine into a URL you can use as a document’s url in envelopes create, and show what SignatureAPI found in it.
| Command | API operations |
|---|---|
uploads create | Create an upload URL, then Store an upload with --key |
uploads inspect | Retrieve upload structure |
Uploads belong to the account, not to a mode, so these commands take no --mode. Any credential works: the sign-in, a test key, or a live key.
Upload a local document
npx signatureapi uploads create contract.pdfThe result shows the upload ID (upl_...) and its URL. Use the URL as a document’s url in an envelope body. The upload expires after 24 hours.
The file can be a PDF, DOCX, or PNG, up to your account’s maximum document size. Its extension and its first bytes must agree. A larger file fails with validation-error before any bytes are sent.
The CLI uploads through an upload URL: it requests a signed URL for the file, then sends the bytes to it. That is why it takes files over 4.5 MB. From your own code, use Create an upload, the recommended way for files up to 4.5 MB. Upload URLs are for larger files.
Upload and send in one step
Read the URL from the --json result and put it into the envelope body with jq:
url=$(npx signatureapi uploads create contract.pdf --json | jq -r 'select(.type == "result") | .data.url')
jq --arg url "$url" '.documents[0].url = $url' envelope.json | npx signatureapi envelopes create --body -envelope.json is the body from Request bodies. Its places need the [[client_signs_here]] and [[provider_signs_here]] placeholders in your document; check them first.
Keep a template permanently
With --key, the CLI also stores the upload under that key, and it does not expire:
npx signatureapi uploads create template.pdf --key contract-template-v2A key is 1 to 100 lowercase letters, digits, hyphens, and underscores, unique within the account. SignatureAPI can refuse to store it, for example with upload-key-conflict when another upload has that key. The result is then upload_not_stored, and its url still works as a temporary upload.
Check placeholders before you send
uploads inspect shows a PDF or DOCX upload’s structure: its pages, the [[key]] placeholders it found, and, for DOCX templates, its template fields. Run it before you create the envelope to check that every place key has its placeholder.
The text output shows the format and the page count. The placeholders are in the --json result:
npx signatureapi uploads inspect upl_3JJz6t1o8A5YjX5VpnX27Z --json \
| jq -c 'select(.type == "result") | .data.placeholders[] | {key, page_number, errors}'{"key":"client_signs_here","page_number":1,"errors":[]}
{"key":"provider_signs_here","page_number":1,"errors":[]}A placeholder with entries in errors can’t be used as written, for example because its key is used twice. See Retrieve upload structure for every field.
Command reference
Generated from the help of the published signatureapi package.
uploads create
Upload a local PDF, DOCX or PNG and show the URL to use as a document's url in envelopes create. Uploads expire after 24 hours unless --key stores them permanently, and belong to the account, not a mode.
Usagenpx signatureapi uploads create <path> [options]
| Argument | Description |
|---|---|
<path> | PDF, DOCX or PNG file to upload, up to the account's maximum document size. Required. |
| Option | Description |
|---|---|
--key <key> | Store the upload permanently under this key (permanent uploads don't expire). |
Global options: --api-key-var, --credential-store, --json.
# Upload a contract
npx signatureapi uploads create contract.pdf
# Upload and keep the URL for a script
npx signatureapi uploads create contract.pdf --json
# Upload a template and keep it permanently
npx signatureapi uploads create template.pdf --key contract-template-v2Related: Upload
uploads inspect
Show the analyzed structure of a PDF or DOCX upload: pages, the placeholders found and, for DOCX templates, the template fields. Uploads belong to the account, not a mode.
Usagenpx signatureapi uploads inspect <upload-id> [options]
| Argument | Description |
|---|---|
<upload-id> | ID of the upload (upl_...), as uploads create shows it. Required. |
Global options: --api-key-var, --credential-store, --json.
# Inspect an uploaded contract
npx signatureapi uploads inspect upl_...Related: Upload