Uploading files to your Teamwork account is straight forward and utilizes 2 API Calls.

Step 1 - Create a Pending File Handle

The first thing to do is to get the actual file uploaded to the Teamwork platform.

To do this you make an API Call to POST /pendingFiles.json

The actual file contents are sent via a form field called "file". If this was successful you will receive a Status Code of 201 (Created) and a structure containing a reference code.

{ "pendingFile": { "ref" : "tf_xxxxxxxxxxxxxxxx" } }<br> 
The ref bit is the important part and is the Pending File Handle

Step 2 - Create an actual file object using the Pending File Handle

The next step is to create the actual file object in a project on your Teamwork account.

To do this you make an API Call to POST /projects/{id}/files.json where {id} is the ID of the project you want to create the file in.

{ "file": { "description" : "Optional string describing the file", "category-id" : "ID of the category you to create the file in. Pass 0 if no category", "category-name" : "String if you want to create a new category - Pass category-id=0 also", "pendingFileRef" : "tf_xxxxxxxxxxxx" } }<br> 
In the JSON packet above you substitute the Pending File Ref you received back from the POST /pendingFiles.json API Call in Step 1.

If everything went OK, you'll receive a Status Code of 201 (Created) and a structure containing the ID of the newly created file