Save Attachment API
This document focuses on how to use the Attachments API to save (upload or update) attachments. Before proceeding, ensure you have a foundational understanding of document definitions and documents.
To save a document in v1 check this documentation.
Core Resource Path
The core path structure for all attachment operations, including saving, is:
api/v2/document-definitions/[DDname or DDid]/documents/[documentId or externalId]/attachments
Parameters
These parameters must be updated to correspond to the correct document definition and document:
Parameter | Description |
---|---|
DDname or DDid | Replace with the name or ID of the Document Definition. |
documentId or externalId | Replace with the ID or the external ID of the specific Document. |
Endpoints
The following endpoint is available for saving attachments:
URL | HTTP Method | Description |
---|---|---|
/attachments?valuePath={valuePath}&actionType={actionType}&shouldUpdateDocument={shouldUpdateDocument} |
POST / PUT | Saves (uploads or updates) an attachment for a specific document at a given valuePath. Includes parameters for action type and whether to update the document. |
Using the API Script
You can use the internal REST.call() script to make API calls.
Example: Save (Upload) a New Attachment (cURL)
This example demonstrates how to upload a new attachment to a specific valuePath within a document using a POST request. When sending file data, remember to use Content-Type: multipart/form-data. Fill in your API domain, IDs, and access token.
curl -X POST "[Main API Domain]/api/v2/document-definitions/YOUR_DD_ID/documents/YOUR_DOCUMENT_ID/attachments?valuePath=YOUR_VALUE_PATH&actionType=Upload&shouldUpdateDocument=true" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "environment-id": environmentId