API
Login Sign Up

Attachments

Listing attachments

GET https://api.groovehq.com/v1/attachments

Parameters

Name Type Required Notes
message string Yes The ID of the message to list attachments for

Example Response

Status: 200 OK

{
  "attachments": [{
    "filename": "an-attachment.pdf",
    "size": 100249,
    "url": "http://bucket-name.s3.amazonaws.com/?1429889868",
  }]
}

Introduction to uploading attachments on a message

POST https://uploader.groovehq.com/messages/:message_id/attachments

Uploading attachments to a message is handled through the Groove uploader API. This API uses the same authentication as the core Groove API, but it is located at:

https://uploader.groovehq.com instead of https://api.groovehq.com.

The attachments endpoint is polymorphic and can understand both single binary file uploads as well as multipart/form-data uploads (allowing for multiple files in a single request).

Because this endpoint supports multiple files, it will always do its best to fulfill as many file uploads as possible. You should always check the success boolean and errors array of each response object.

Upload limits

  • Messages have a limit of 25 attachments
  • Each attachment is limited to a 20mb file size

Uploading a single binary

POST https://uploader.groovehq.com/messages/:message_id/attachments

Content-Type is defined by binary

You can send a single binary file, which is supported by most clients.

Parameters

Name Type Required Notes
filename string Yes The name of the file being uploaded

Example Request

curl "https://uploader.groovehq.com/messages/4517239960/attachments?filename=image.jpg" \
  -H "Authorization: Bearer 41529cf5de0f4daa10098ff4881521c0cfea8b127d8e11bc5cc2cadb974e9a72" \
  -H "Content-Type: image/jpeg" \
  --data-binary @./samples/image.jpg \
  -X POST

Example Success Response

Status: 200 OK

{
  "attachment": {
    "attachment_file_name": "image.jpg",
    "attachment_content_type": "image/jpeg",
    "attachment_file_size": 32768,
    "success": true
  }
}

Example Error Response

Status: 200 OK

{
  "attachment": {
    "attachment_file_name": "image.jpg",
    "attachment_content_type": "image/jpeg",
    "attachment_file_size": 20971520,
    "success": false,
    "errors": [
      "Filesize exceeded maximum limit of 20971520 bytes"
    ]
  }
}

Uploading multiple files in a single request

POST https://uploader.groovehq.com/messages/:message_id/attachments

Content-Type must be multipart/form-data

Multiple files may be uploaded in the same request by submitting the request as a multipart/form-data. As stated before, the endpoint will try to upload as many files as it can, and will return attachments with success and errors fields that you should check.

Example Request

curl -X POST \
  -H "Authorization: Bearer 41529cf5de0f4daa10098ff4881521c0cfea8b127d8e11bc5cc2cadb974e9a72" \
  -F "file=@./samples/image.jpg" \
  -F "file=@./samples/data.xml" \
  "https://uploader.groovehq.docker/messages/4517239960/attachments"

Example Response (mixed success)

Status: 200 OK

{
  "attachments": [
    {
      "attachment_file_name": "image.jpg",
      "attachment_content_type": "image/jpeg",
      "attachment_file_size": 32768,
      "success": true
    },
    {
      "attachment_file_name": "data.xml",
      "attachment_content_type": "application/xml",
      "attachment_file_size": 20971520,
      "success": false,
      "errors": [
        "Filesize exceeded maximum limit of 20971520 bytes"
      ]
    }
  ]
}

Remaining attachments available on message

GET https://uploader.groovehq.com/messages/:message_id/attachments/remaining

Because our api limits messages to 25 attachments, you should check to make sure there are enough attachments remaining for the number of files you are preparing to upload.

Example Response

Status: 200 OK

{
  "remaining_attachments_count": 12
}