Attachments are binary files, such as photos, that are attached to data points in a session.

Photos are by far the most common type of attachment, but other files may be attached depending on the project.

Attachments can be manipulated downloaded, uploaded (replaced or added) or deleted from a session. Actions that change attachments automatically save the session to reflect the changes to its attachments.


GET /api/v1/project/:project_id/sessions/:session_id/attachments/:id
Fetch the raw data of a file attached to a session

The raw attachment is returned in the response body, with a response Content-Type set to application/octet-stream

This api call returns a 404 Not Found error if there is no attachment in the named point.

Params

Param name Description
project_id
required

The project ID number

Validations:

  • Must be a Integer

session_id
required

The session UUID

Validations:

  • Must be a String

id
required

The name of the point containing an attached file to be downloaded.

Validations:

  • Must be a String


PUT /api/v1/project/:project_id/sessions/:session_id/attachments/:id
Upload a new file and store it as an attachment to a session

The raw attachment is uploaded and attached to the session. Any previous value of the session in that point name is replaced. If the previous value was an attachment, then the previous attachment is also deleted from the system.

This api call will accept a standard form upload post (content-type = ‘multipart/form-data’), in which case the attached file is expected to be in a form field named “attachment”.

This api call will also accept a raw upload (content-type = ‘application/octet-stream’). In this case the request body is saved as is into the attachment. To specify a filename for the attachment, use a “filename” query parameter in the request URI.

This api call returns a 400 Bad Request error if the content type was not recognised or the attachment was not found in the request (eg: incorrect form field name).

On a successful request, this endpoint returns a JSON response with the result set to a hash with the following keys:

  • length => the length of the file that was uploaded
  • md5 => a hex digest of the contents of the file.

These will allow the calling application to determine that the file was indeed delivered and saved correctly.

Params

Param name Description
project_id
required

The project ID number

Validations:

  • Must be a Integer

session_id
required

The session UUID

Validations:

  • Must be a String

id
required

The name of the point containing an attached file.

Validations:

  • Must be a String


DELETE /api/v1/project/:project_id/sessions/:session_id/attachments/:id
Delete an attached file from a session

This api call will remove an attachment from a session. The point value is removed from the session and the attached file is deleted from the system.

This api call returns a 404 Not Found error if there was no attachment saved in the given point of the session.

A successful request returns a standard JSON response with a result of true.

Params

Param name Description
project_id
required

The project ID number

Validations:

  • Must be a Integer

session_id
required

The session UUID

Validations:

  • Must be a String

id
required

The name of the point containing an attached file.

Validations:

  • Must be a String