Torch POST/JSON WebHook

Torch Project Management supports a universal JSON, POST or GET (not recommended) request to the webhook url (available under the help section) that creates a message. In both cases the variables are named “title” and “body”. In the case of the JSON, the entire payload should be placed in the POST variable “json”. Most programming languages have built in functions for creating JSON payloads (e.g. PHP, Ruby, Java).

A typical JSON payload might look like this:

Code:

{
    "title": "Talked to the Client",
    "body": "Spent time with client \n\n[time:Time with client:2.5]",
    "files": ["http://example.com/file.pdf", "http://example.com/file2.pdf"]
}

The body variable will be parsed for task/event, pin, time, expense, category and complete entries as described in this document (and you can have as many of these as you want). Additionly, when using a non-project webhook url, the command [project:name of project] will also be detected. The optional “files” array containing urls, you can also simply POST files as part of the webhook url request.

If you want to run a series of advanced e-mail commands without actually creating a message, you can do that as well. Just send the variable “simulate” with a value of “true”.

You can also post a JSON payload that creates a time or expense entry directly (optionally, post a file for an expense receipt):

Code:

{
    "hours": "2:15",
    "note": "Work with client",
    "category": "Meetings",
    "timestamp": "2010-07-04"
}

Or:

Code:

{
    "price": "200",
    "note": "New Widget",
    "category": "Toys",
    "timestamp": "2010-07-04",
    "files": ["http://example.com/receipt.pdf"]
}

You can also retrieve time and expense data in JSON format by adding the GET or POST variable “list” with a value of either “time”, “expenses”,“invoices”, “payments”, “messages” or “events”. If you are connected to the all active projects webhook, you can also filter the list based on project name by specifying the list followed by the project name (e.g. list=events%20WebSite). A typical JSON response might look like this:

Code:

[{
    "key": "876",
    "timestamp": "2009-11-23 00:00:00",
    "hours": "5.000000",
    "note": "Graphics",
    "category": "Newsletter One",
    "invoicename": "",
    "user": "Ben Smith",
    "billrate": "100.000000",
    "cost": "500.000000000000",
    "projectbudget": "200.00",
    "categorybudget": "100.00"
},
{
    "key": "877",
    "timestamp": "2009-11-23 00:00:00",
    "hours": "1.000000",
    "note": "Logo",
    "category": "Newsletter One",
    "invoicename": "",
    "user": "Ben Smith",
    "billrate": "100.000000",
    "cost": "100.000000000000",
    "projectbudget": "200.00",
    "categorybudget": "100.00"
}]

There is some Google Apps Scripts sample code retrieving data in this method available here.