Skip to content

Save Attachment

This REST call allows you to save attachment field including attached files.

URL

api/v1/documents/attachments

Method

POST

Header parameters
Parameter Type Required Description
X-User-Id String Yes The ID of the user who wants to trigger the REST action. This ID is returned by the authentication call.
X-Auth-Token String Yes The authentication token that the authentication call returned.
Query parameters
Field Type Required Description
environmentId String Yes The ID of the environment.
ddName String Yes The name of the document definition on which the source document is based.
documentId String No The internal ID of the document. Either the __id_ or externalId field should be supplied.
externalId String No The external ID of the source document. Either the __id_ or externalId field should be supplied.
fieldName String Yes The name of the field from which the attachment should be downloaded.
lineName String No If the attachment field is part of a line, enter the name of the line here.
lineId String No The ID of the line from which the attachments should be copied.
lineExternalId String No The external ID of the line from which the attachment should be downloaded. If the lineName field has a value, either the lineId or lineExternalId should be entered.
actionType String No One of "append" or "replace". If argument omitted default value "append" will be used.
Body

Body of the request should contain only files. Files will be attached to the field specified in query parameters.

Response
Success

Info: response contains only attachments that was added in the request.

{
    "status": "success",
    "message": "Attachments was successfully saved",
    "attachments": [
        {
            "_id": "175f7edf15f5d8ecd560af4e",
            "_fileName": "cookbook.png",
            "store": "image",
            "_type": "image/png",
            "_size": 7907
        },
        {
            "_id": "1fff8528b9822a0b5aedc22c",
            "_fileName": "tickets.pdf",
            "store": "attachment",
            "_type": "application/pdf",
            "_size": 62067
        }
    ]
}
Fail

In case of any error JSON response will be provided:

{
    "status": "error",
    "error": "The message of error will go here"
}

Example

curl -X POST \
  '/api/v1/attachments?ddName=menuItem&documentId=3DKKq68tvhpu9bk24&fieldName=preparationInstructions&lineName=ingredients&lineId=74240700f347e0b8063b940d&environmentId=maxedy_pizza' \
  -H 'x-auth-token: 6Erh0CLMMjLO8T_OMWFPbQD_PIwE30CcLdJ1GFBO4gc' \
  -H 'x-user-id: a6gA9rYaGTFKPrT5P' \
  -F attachment1=@/path/to/file/in/file/system/cookbook.png \
  -F attachment2=@/path/to/file/in/file/system/tickets.pdf