This topic includes the following:

  • How to upload a document

  • How to replace an existing document

  • How to update the metadata in a document

  • How to delete a document after you have created a package

Uploading Documents

Uploading a Single Document

To upload a document after creating a package, you will need to make a multipart-form POST request.

HTTP Request

POST /api/cs-packages/{packageId}/documents
JS

HTTP Headers

Accept: text/html
Content-Type: multipart/form-data
Authorization: Bearer access_token
JS

Request Payload

------WebKitFormBoundary1bNO60n7FqP5WO4t
				Content-Disposition: form-data; name="file"; filename="testDocumentExtraction.pdf"
				Content-Type: application/pdf
				%PDF-1.5
				%µµµµ
				1 0 obj
				<>>>
				endobj.... 
				------WebKitFormBoundary1bNO60n7FqP5WO4t
				Content-Disposition: form-data; name="payload"
				{
				"name": "Example Document",
				"description": "Example Description",
				"id": "Document1"
				}
			------WebKitFormBoundary1bNO60n7FqP5WO4t--
JS

For a complete description of each field, see the Request Payload Table section below. 

Response Payload

{
				"status": "",
				"description": "Example Description",
				"id": "Document1",
				"data": {
				"ese_document_texttag_extract_needed": "false"
				},
				"approvals": [
				{
				"id": "k1r2qMRtCsI5",
				"role": "48d0c024-0609-4255-9087-941a66f80738",
				"data": null,
				"signed": null,
				"accepted": null,
				"fields": [],
				"name": ""
				}
				],
				"pages": [
				{
				"id": "",
				"top": 0,
				"height": 1030,
				"width": 796,
				"left": 0,
				"index": 0,
				"version": 0
				}
				],
				"external": null,
				"extract": false,
				"signedHash": null,
				"signerVerificationToken": null,
				"index": 1,
				"fields": [],
				"name": "Example Document",
				"size": 185808
			}
JS

Uploading Multiple Documents

To upload multiple documents in one call, you would use the same API URL but modify the request body in the following way:

HTTP Request

POST /api/cs-packages/{packageId}/documents
JS

HTTP Headers

Accept: text/html
Content-Type: multipart/form-data
Authorization: Bearer access_token
JS

Request Payload

------WebKitFormBoundary1bNO60n7FqP5WO4t
				Content-Disposition: form-data; name="file"; filename="doc1.pdf"
				Content-Type: application/pdf
				%PDF-1.5
				%µµµµ
				1 0 obj
				<>>>
				endobj.... 
				------WebKitFormBoundary1bNO60n7FqP5WO4t
				Content-Disposition: form-data; name="file"; filename="doc2.pdf"
				Content-Type: application/pdf
				%PDF-1.5
				%µµµµ
				1 0 obj
				<>>>
				endobj.... 
				------WebKitFormBoundary1bNO60n7FqP5WO4t
				Content-Disposition: form-data; name="payload"
				[
				{
				"name": "Document1",
				"description": "Example Description",
				"id": "Document1"
				},
				{
				"name": "Document2",
				"description": "Example Description",
				"id": "Document2"
				}
				]
			------WebKitFormBoundary1bNO60n7FqP5WO4t--
JS

Replacing an Existing Document

Replacing an existing document in a transaction can also be done using the upload document API. This is useful, for example, if you would like to replace the document, but still keep the layout of the fields and signatures.

To do so, make a multipart-form POST request where the document JSON payload carries the same document ID as the original document:

HTTP Request

POST /api/cs-packages/{packageId}/documents
JS

HTTP Headers

Accept: text/html 
Content-Type: multipart/form-data 
Authorization: Bearer access_token
JS

Request Payload

------WebKitFormBoundary1bNO60n7FqP5WO4t
				Content-Disposition: form-data; name="file"; filename="doc1.pdf"
				Content-Type: application/pdf
				%PDF-1.5
				%µµµµ
				1 0 obj
				<>>>
				endobj.... 
				------WebKitFormBoundary1bNO60n7FqP5WO4t
				Content-Disposition: form-data; name="payload"
				{
				"name": "Replaced Document",
				"id": "keep_the_document_id_same"
				}
				------WebKitFormBoundary1bNO60n7FqP5WO4t--
JS

Similarly, you can replace multiple documents using the following request:

Request Payload

------WebKitFormBoundary1bNO60n7FqP5WO4t
				Content-Disposition: form-data; name="file"; filename="doc1.pdf"
				Content-Type: application/pdf

				%PDF-1.5
				%µµµµ
				1 0 obj
				<>>>
				endobj.... 
				------WebKitFormBoundary1bNO60n7FqP5WO4t
				Content-Disposition: form-data; name="file"; filename="doc2.pdf"
				Content-Type: application/pdf

				%PDF-1.5
				%µµµµ
				1 0 obj
				<>>>
				endobj.... 
				------WebKitFormBoundary1bNO60n7FqP5WO4t

				Content-Disposition: form-data; name="payload"
				[
				{
				"name": "Replaced Document1",
				"id": "keep_the_document1_id_same"
				},
				{
				"name": "Replaced Document2",
				"id": "keep_the_document2_id_same"
				}
				]------WebKitFormBoundary1bNO60n7FqP5WO4t--
JS

Updating Document Metadata

To update the metadata for a document, you will need to create your JSON using the updated document metadata:

{
				"name": "Example Document",
				"description": "Example Description"
			}
JS

Then use the following command:

PUT https://services.congamerge.com/api/cs-packages/{packageId}/documents/{documentId}
JS

The call above will only update the document level attributes you defined in your new JSON payload and not any other embedded attributes that can be updated.

Deleting a Document

To delete a document, make a DELETE request to the following URI:

https://services.congamerge.com/api/cs-packages/{packageId}/documents/{documentId}
JS

Results

After running your code, if you log in to Sign and navigate to your transaction, you will be able to log into your Sign account and view the documents you just added.

Request Payload Table

PropertyTypeEditableRequiredDefaultSample Values
namestringYesNon/aExample Document 
descriptionstringYesNon/aExample Document 
idstringYesNon/aDocument1