Skip to content

Copy Attachment API

This document outlines how to use the Attachments API to copy attachments. Before proceeding, ensure you have a foundational understanding of document definitions and documents.

For v1 API calls, go to this copy attachment documentation.

Core Resource Path

The core path structure for all attachment operations, including copying, 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

While the provided document doesn't explicitly show a COPY HTTP method for the /attachments endpoint, a copy operation would typically involve a POST or PUT request to a new location, potentially using the save endpoint's structure or a dedicated copy endpoint if one exists. Assuming a save-like approach for copying:

URL HTTP Method Description
/attachments?valuePath={valuePath}&actionType={actionType}&shouldUpdateDocument={shouldUpdateDocument} POST / PUT To "copy" an attachment, you would typically retrieve the original attachment and then "save" it to a new location or with a new name using this endpoint. This involves uploading the attachment data to a specific valuePath.

Using the API Script

You can use the internal REST.call() script to perform API operations.

Example

An example on how to copy the attachments looks like this:

curl -X POST "[Main API Domain]/api/v2/documents/copyAttachments" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "environment-id: YOUR_ENVIRONMENT_ID" \
  -d '[
      {
        "source": {
          "ddName": "MyDocumentDef", 
          "_id": "doc123",          
          "valuePath": "picture",
          "fileNames": ["report.pdf", "image.png"]
        },
        "target": {
          "ddName": "MyDocumentDef", 
          "_id": "doc123",           
          "valuePath": "ingredients.1.picture"
        },
      }
    ]'
This will not return any special and returns the default return value.