Files API Calls


List Files on a Task

GET /tasks/{task_id}/files.json

This lets you query the list of files for a Task.

Response

{
    "project": {
        "company": "Demo 1 Company",
        "name": "demo",
        "files": [
            {
                "project-id": "999",
                "uploaded-by-user-last-name": "User",
                "name": "readme.txt",
                "uploaded-date": "2014-03-28T16:29:45Z",
                "uploaded-by-userId": "999",
                "description": "",
                "extraData": "",
                "comments-count": "0",
                "version-id": "32",
                "private": "0",
                "status": "active",
                "category-id": "13",
                "version": "1",
                "originalName": "readme.txt",
                "id": "999",
                "last-changed-on": "2014-03-28T16:29:45Z",
                "size": "1612",
                "versions": [],
                "file-source": "teamworkpm",
                "uploaded-by-user-first-name": "Demo",
                "category-name": "Demo Category"
            }
        ],
        "id": "999"
    }
}

See Files in data reference


List Files on a Project

GET /projects/{project_id}/files.json

This lets you query the list of files for a project.

If a file is an image, there will be an additional key called thumbURL in the response with a link to the image thumbnail.

Response

{
    "project": {
        "company": "Demo 1 Company",
        "name": "demo",
        "files": [
            {
                "project-id": "999",
                "uploaded-by-user-last-name": "User",
                "name": "readme.txt",
                "uploaded-date": "2014-03-28T16:29:45Z",
                "uploaded-by-userId": "999",
                "description": "",
                "extraData": "",
                "comments-count": "0",
                "version-id": "32",
                "private": "0",
                "status": "active",
                "category-id": "13",
                "version": "1",
                "originalName": "readme.txt",
                "id": "999",
                "last-changed-on": "2014-03-28T16:29:45Z",
                "size": "1612",
                "versions": [],
                "thumbURL": "https://tw-s3.teamworkpm.net/action=getThumb&ref=xx.xxxx.xxx.xxxxxx.x",
                "file-source": "teamworkpm",
                "uploaded-by-user-first-name": "Demo",
                "category-name": "Demo Category"
            }
        ],
        "id": "999"
    }
}

See Files in data reference


Get a Single File

GET /files/{file_id}.json

This returns all details about an individual file. Crucially - this call also returns the download URL which is valid only for an hour.

Response

{
    "file": {
        "project-id": "999",
        "uploaded-by-user-last-name": "User",
        "name": "readme.txt",
        "uploaded-date": "2014-03-28T16:29:45Z",
        "uploaded-by-userId": "999",
        "description": "",
        "comments-count": "0",
        "version-id": "32",
        "private": "0",
        "download-URL": "http://demo1company.teamwork.com/?action=viewFile&sd=35e756ad...",
        "category-id": "13",
        "project-name": "demo",
        "version": "1",
        "originalName": "readme.txt",
        "id": "999",
        "size": "1612",
        "file-source": "teamworkpm",
        "uploaded-by-user-first-name": "Demo",
        "category-name": "Demo Category"
    },
    "STATUS": "OK"
}

See Files in data reference


Add a File to a Project

POST /projects/{project_id}/files.json

This call adds a file to the project.

The file must have been uploaded already and you must have the pendingFileRef  handle - see uploading files

Request

{
  "file": {
    "name": "thisfile.txt",
    "description": "Some description",
    "private": "0",
    "category-id": "0",
    "category-name": "My new category",
    "pendingFileRef": "tf_F7495964-D850-E64B-E22057A09616E9B3",
    "tags": "tag1,tag2,tag3"
  }
}

See Files in data reference


Add a new File Version to a File

POST /files/{file_id}.json

This call adds a new file version to an existing file.

The file version file must have been uploaded already and you must have the pendingFileRef handle - see uploading files

Request

{
  "fileversion": {
    "pendingFileRef": "tf_F7F01655",
    "description": "An optional description"
  }
}

Response

{
  "STATUS": "OK",
  "fileId" : 256,
  "fileVersionId" : 999,
  "versionNo" : 2
}


Delete a File from a Project

DELETE /files/{file_id}.json

This call deletes a file from a project.


Get a short URL for sharing a file

GET /files/{file_id}/sharedlink.json

This call will provide a short link to a file to make it easier to share, in the format of http://twk.pm/xxxxxx

If you have multiple versions of a file, you can request a short link to other versions by appending 'version'.

GET /files/{file_id}/sharedlink.json?version=2

'version' is optional and is set to 1 by default.

Response

{
  "STATUS": "OK",
  "url": "http://twk.pm/xxxxxxxx"
}


Copy or Move a file to another project

This will allow you to COPY a file that already exists in one project in to another project.

Perform a PUT to /files/{file_id}/copy.json

This will allow you to MOVE a file that already exists in one project in to another project.

Perform a PUT to /files/{file_id}/move.json

In either case, in the body include a target Project ID:

Request

{
"projectId": 1234567
}

Response

{
  "STATUS": "OK"
}


Add or update a Project logo

This will add an image to become a Project logo. It will replace the existing logo if there is one in place.

First, use the file upload API call to upload a file and receive back a file reference string.

Then, perform the following to update a project:

Perform a PUT to /projects/{project_id}.json

Using the following body content:

Request

{
   "project": {
	"logoPendingFileRef":"{your_uploaded_file_reference}"
   }
}

Response

{
  "STATUS": "OK"
}