Skip to content

Developers

How can we help you?

← Go back

Event

In order to track changes in any resource job, asset, task, etc. you can use the Sequence events feed.

Each entry in the feed represents a relevant event that happened on a specified resource at specified time.

Currently, entries in the feed are generated for three types of events per resource:

  • The creation of the resource.
  • The modification of any attribute or link of the resource.
  • The deletion of the resource.

This is an example of the XML/JSON representation of the event feed:

<events type="array">
  <event>
    <id type="integer">40393</id>
    <event-type>job_created</event-type>
    <timestamp type="datetime">2012-12-03T09:35:37+00:00</timestamp>
    <link rel="self" href="https://sequence.bebanjo.net/api/events/40393"/>
    <link rel="subject" href="https://sequence.bebanjo.net/api/work_areas/85/jobs/97185"/>
  </event>
  <event>
    <id type="integer">40397</id>
    <event-type>asset_updated</event-type>
    <changes>status,name</changes>
    <timestamp type="datetime">2012-12-03T09:35:39+00:00</timestamp>
    <link rel="self" href="https://sequence.bebanjo.net/api/events/40397"/>
    <link rel="subject" href="https://sequence.bebanjo.net/api/work_areas/85/jobs/97185/assets/467237"/>
  </event>
  <event>
    <id type="integer">40401</id>
    <event-type>task_deleted</event-type>
    <timestamp type="datetime">2012-12-04T14:46:55+00:00</timestamp>
    <link rel="self" href="https://sequence.bebanjo.net/api/events/40401"/>
    <link rel="subject" href="https://sequence.bebanjo.net/api/work_areas/85/jobs/97144/tasks/3030"/>
  </event>
  <!-- ... -->
</events>
{
  "entries": [
    {
      "resource_type": "event",
      "id": 40393,
      "event_type": "job_created",
      "timestamp": "2012-12-03T09:35:37+00:00",
      "self_link": "https://sequence.bebanjo.net/api/events/40393",
      "subject_link": "https://sequence.bebanjo.net/api/work_areas/85/jobs/97185"
    },
    {
      "resource_type": "event",
      "id": 40397,
      "event_type": "asset_updated",
      "timestamp": "2014-07-27T11:04:10.000-07:00",
      "changes": "status,name",
      "self_link": "https://sequence.bebanjo.net/api/events/40397",
      "subject_link": "https://sequence.bebanjo.net/api/work_areas/85/jobs/97185/assets/467237"
    },
    {
      "resource_type": "event",
      "id": 40401,
      "event_type": "task_deleted",
      "timestamp": "2012-12-04T14:46:55+00:00",
      "self_link": "https://sequence.bebanjo.net/api/events/40401",
      "subject_link": "https://sequence.bebanjo.net/api/work_areas/85/jobs/97144/tasks/3030"
    },
    ...
  ]
}

Valid attributes

  • id (integer, read only): The identifier of the event. Events are presented ordered by id and they can be filtered with the newer_than parameter (see below). You may want to store the id of the last processed event so that they don’t process twice the same event.

  • event-type (string, read only): The type of the event. The list of supported events is specified in a section below. The format of the event-type is as follows: (resource_type)_(operation). Currently, there are three possible operations:

    • created: For the creation of the resource.

    • updated: For the modification of any attribute or link of the resource.

    • deleted: For the deletion of the resource.

  • changes (string, comma-separated, read only): The list of attributes and links that changed. This attribute is only present if the event-type is *_update. This list refers to the names of the attributes and to the “rels” of the links of the resource that have changed. To know what the new values are for those attributes or links, you’ll have to follow the subject link. The attribute status from a job is an exception to this and, at the moment, is not tracked in the list of changed attributes listed for the events job_updated.

    The changes attribute can contain multiple changes. Here’s an example:

  <?xml version="1.0" encoding="UTF-8"?>
    <events type="array">
      <event>
        <id type="integer">71804580</id>
        <event-type>job_updated</event-type>
        <timestamp type="datetime">2018-04-20T16:45:46+02:00</timestamp>
        <changes>name,licensor-name</changes>
        <link rel="self" href="https://sequence.bebanjo.net/api/events/71804580"/>
        <link rel="subject" href="https://sequence.bebanjo.net/api/work_areas/216/jobs/983053"/>
      </event>
      <!-- ... -->
    </events>
  {
    "entries": [
      {
        "resource_type": "event",
        "id": 71804580,
        "event_type": "job_updated",
        "timestamp": "2018-04-20T16:45:46+02:00",
        "changes": "name,licensor-name",
        "self_link": "https://sequence.bebanjo.net/api/events/71804580",
        "subject_link": "https://sequence.bebanjo.net/api/work_areas/216/jobs/983053"
      },
      ...
    ]
  }

Here are the possible values for the changes attribute:

  • Assets
    • type-name
    • status
  • Jobs
    • name
    • due-date
    • ends-at
    • licensor-name
    • tasks-status
    • assets-status
    • title-external-id
    • tag-list
  • Tasks
    • name
    • status
    • duration
  • timestamp (datetime, read only): The date and time when the event occurred.
  • self: The event itself.

  • subject: The resource that was created, updated or deleted.

Note: When trying to access the subject link of the events a HTTP response code of 404 (Not Found) might be returned. It means just that the requested resource cannot be found (because it has been deleted). Probably there will be a newer event of the type *_deleted (i.e. job_deleted) in the feed pending to be processed.

Getting the event feed

The event feed is linked from the root of the Sequence API:

$ curl --digest -u robot_user:password https://sequence.bebanjo.net/api
$ curl --digest -u robot_user:password -H "Accept: application/json" https://sequence.bebanjo.net/api
<?xml version='1.0' encoding='utf-8' ?>
<sequence>
  <!-- ... -->
  <link rel="events" href="https://sequence.bebanjo.net/api/events"/>
</sequence>
{
  "resource_type": "sequence",
  // ...
  "events_link": "https://sequence.bebanjo.net/api/events"
}

Following the events link you’ll get the event feed:

$ curl --digest -u robot_user:password https://sequence.bebanjo.net/api/events
$ curl --digest -u robot_user:password -H "Accept: application/json" https://sequence.bebanjo.net/api/events
<?xml version='1.0' encoding='utf-8' ?>
<events type="array">
  <!-- ... -->
</events>
{
  "entries": [
    ...
  ]
}

The event feed is limited to show no more than 50 events in ascending order of their timestamps (i.e. older events will appear first). You can navigate and filter the event feed using the attributes described in the following section.

You can also pass the following attributes in order to filter the event feed:

  • newer_than (integer, it can be used with any other parameter): This parameter filter the feed to include only events that are newer than another one. The value of this parameter will be the id of the event taken as a reference.

    For example: /api/events?newer_than=234 will return events more recent than the event 234. Typically, you may want to store locally the id of the last event you have processed so that in the next processing you only request the events newer than the last one you processed. Also, given that the event feed is limited to 50 entries, you should use the newer_than parameter to navigate the feed until reaching the last event.

  • event_type (string, comma-separated, it can be used with any other parameter): This parameter will allow clients to filter the feed to include only entries for certain event types. The value of this parameter will be a list of event types separated by commas. For example: /api/events?event_type=job_created,task_updated will return only events whose event_type is job_created or task_updated.

    You are encouraged to use the event_type filter to fetch only those event types which are relevant to you, avoiding unnecessary processing. Currently the supported event types are:

    • asset_created
    • asset_deleted
    • asset_updated
    • job_created
    • job_deleted
    • job_updated
    • task_created
    • task_deleted
    • task_updated

Getting one specific event

Following the self link in any of the events in the event feed you’ll get the event itself:

$ curl --digest -u robot_user:password https://sequence.bebanjo.net/api/events/40393
$ curl --digest -u robot_user:password -H "Accept: application/json" https://sequence.bebanjo.net/api/events/40393
<?xml version='1.0' encoding='utf-8' ?>
<event>
  <id type="integer">40393</id>
  <event-type>job_created</event-type>
  <timestamp type="datetime">2012-12-03T09:35:37+00:00</timestamp>
  <link rel="self" href="https://sequence.bebanjo.net/api/events/40393"/>
  <link rel="subject" href="https://sequence.bebanjo.net/api/work_areas/85/jobs/97185"/>
</event>
{
  "resource_type": "event",
  "id": 40393,
  "event_type": "job_created",
  "timestamp": "2012-12-03T09:35:37+00:00",
  "self_link": "https://sequence.bebanjo.net/api/events/40393",
  "subject_link": "https://sequence.bebanjo.net/api/work_areas/85/jobs/97185"
}