Intervals API Examples

Resource Operations

As mentioned in the intro, resources follow RESTful principles. Each resource has two parts: a collection (e.g. a task list) and a member (e.g. an individual task). How you interact with these resources depends on which HTTP method you use and whether you are addressing a member or a collection.

The Intervals API URL: https://api.myintervals.com/

Here are some examples of accessing resources:

Accessing information about a task
GET https://api.myintervals.com/task/13/

Getting a full task list
GET https://api.myintervals.com/task/

Getting a filtered task list
GET https://api.myintervals.com/task/?clientid=5443&personid=2344

Creating a task
POST https://api.myintervals.com/task/

Editing a task
PUT https://api.myintervals.com/task/13/

Deleting a task
DELETE https://api.myintervals.com/task/13/

PUT/POST Interchangeability
Though RESTful principles describe separate HTTP methods for creating and updating resources, we understand that there is limited support for PUT in certain development platforms. Consequently, you may use PUT and POST interchangeably; the system will determine whether a member is being created or updated based on whether or not a resource id is passed in the parameters.

Sample Requests

A simple example of how to request a task list using a formed HTTP request:

GET https://api.myintervals.com/task/
Accept: application/xml
Authorization: Basic MTIzNDU6QUJDREU=

The Content-type Header
The Intervals API supports both XML and JSON as forms of input for PUT and POST requests, but you must specify which type you are using by including either application/xml or application/json in a Content-Type HTTP header sent with your request.

An example of updating the description on a timer using XML.

PUT https://api.myintervals.com/timer/9282/
Accept: application/xml
Content-type: application/xml
Authorization: Basic MTIzNDU6QUJDREU=
<?xml version="1.0" encoding="UTF-8"?>
<timer>
    <name>Client X homepage redesign</name>
</timer>

An example of creating a new timer using JSON.

POST https://api.myintervals.com/timer/
Accept: application/json
Content-type: application/json
Authorization: Basic MTIzNDU6QUJDREU=
{
    "personid":2051,
    "starttime":"2026-05-19 10:30:03",
    "name":"Meeting with Client Y"
}

A note on PUT/POSTs
Any HTTP library should be able to generate and issue the above request with a minimum of difficulty. However, the above request is considered invalid, since there is no way of knowing the Content-Length. If you are including a message in the body of the request the Content-Length header is required.

A more detailed description of each type of request, including required fields and the expected response, can be found in each individual resource page.

Sample Response

An example of a XML response. Please note that values containing reserved XML characters are embedded with CDATA tags to allow for proper XML parsing.

<?xml version="1.0" encoding="UTF-8"?>
<intervals status="OK" code="200">
    <client>
        <id>4561</id>
        <name>ACME Industries</name>
        <datecreated>2007-09-04</datecreated>
        <description/>
        <firstname>John</firstname>
        <lastname>Watson</lastname>
        <email>john.watson@acmeindustries.com</email>
        <website/>
        <phone>+1 (555) 555-5555</phone>
        <cell>+1 (555) 555-5555</cell>
        <fax>+1 (555) 555-5555</fax>
        <address>123 Main Street</address>
        <aptsuite></aptsuite>
        <city>San Francisco</city>
        <state>CA</state>
        <zip>94101</zip>
        <country>US</country>
        <active>t</active>
    </client>
</intervals>

An example of a JSON response:

{
    "status":"OK",
    "code":200,
    "client":{
        "id":"4561",
        "name":"ACME Industries",
        "datecreated":"2007-09-04",
        "description":null,
        "firstname":"John",
        "lastname":"Watson",
        "email":"john.watson@acmeindustries.com",
        "website":null,
        "phone":"+1 (555) 555-5555",
        "cell":"+1 (555) 555-5555",
        "fax":"+1 (555) 555-5555",
        "address":"123 Main Street",
        "aptsuite":"",
        "city":"San Francisco",
        "state":"CA",
        "zip":"94101",
        "country":"US",
        "active":"t"
    }
}

Note: These example responses have been formatted for easy viewing. The actual response returns with whitespace stripped.

Common multi-step workflows

Individual resources are documented one at a time on each resource page. The sequences below show how calls are usually chained together for everyday automation. Resource parameters and response fields are spelled out on the linked resource pages.

1. Log time on a task

  1. Resolve the person who will own the time entry. The usual shortcut is GET https://api.myintervals.com/me/, which returns your personid in one call (see Me). If you are logging time for someone else and your role allows it, use Person instead.
  2. Resolve the project the task lives under, if you do not already have projectid. For example GET https://api.myintervals.com/project/?clientid={id} or GET https://api.myintervals.com/project/{projectid}/ (Project).
  3. Resolve the task with GET https://api.myintervals.com/task/?projectid={projectid} (add filters such as title search if the list is long). Read the id of the task you need (Task).
  4. Obtain a worktypeid that is valid for that task’s project (for example via Project work type filtered by projectid).
  5. Create the time entry with POST https://api.myintervals.com/time/. For task time, send taskid, personid, worktypeid, date, time, billable, and optional description. With taskid set, projectid and moduleid are not required on the request body (Time).

2. Create a project with tasks

  1. Create the project with POST https://api.myintervals.com/project/. Required fields include name, datestart, billable, and active; include clientid when the project belongs to a client (Project). Note the new id from the response.
  2. Gather IDs for the task you are about to create: statusid from Task status, priorityid from Priority, a moduleid that belongs to this project from GET https://api.myintervals.com/projectmodule/?projectid={id} (Project module), and an ownerid (often the same person as GET /me/).
  3. Create each task with POST https://api.myintervals.com/task/, sending projectid, moduleid, statusid, title, dateopen, ownerid, priorityid, and any optional fields you need (Task).

3. Pull a person's time report for a date range

  1. Choose the person the report should cover. Use GET https://api.myintervals.com/me/ for yourself, or another person’s id if your permissions allow (Me, Person).
  2. Fetch the entries with GET https://api.myintervals.com/time/?personid={personid}&datebegin={YYYY-MM-DD}&dateend={YYYY-MM-DD}. Use limit and offset to walk the full result set if there are many rows (Time; pagination is summarized on the API introduction).

4. List non-closed tasks for a client

  1. If you do not already have the client’s id, list clients with GET https://api.myintervals.com/client/ and pick the right record (Client).
  2. List tasks for that client: GET https://api.myintervals.com/task/?clientid={clientid}&excludeclosed=t. The excludeclosed filter limits results to tasks that are not in a closed status (Task). To narrow to a specific status by numeric id, add statusid as documented on the same page.

Start tracking time today

Join 5,000+ companies spending their time wisely with Intervals.

Try Intervals free