Updating to the V4 API

1. API URL Path Changes

Base path now includes App Instance ID The 'base path' for API v4 now includes the App Instance ID (the same as the API username used in authentication).
Base path in API v1:
Base path in API v4:
/api/v1/
/api/v4/app-instance-id/
Use '/objects' to access objects Accessing objects is now namespaced under '/objects' in the URL:
Accessing objects in API v1:
Accessing objects in API v4:
/api/v1/object-name.json
/api/v4/app-instance-id/objects/object-name.json
Changes to 'datamodel' and 'oplog' The 'datamodel' and 'oplog' API functions no longer have underscores in their names:
Getting the Data Model in API v1:
Getting the Data Model in API v4:
/api/v1/_datamodel.json
/api/v4/app-instance-id/datamodel.json
Accessing the Oplog in API v1:
Accessing the Oplog in API v4:
/api/v1/_oplog.json
/api/v4/app-instance-id/oplog.json

2. Response Data Format for Retrieving Multiple Objects

When retrieving multiple objects, the structure of the JSON data returned now namespaces objects underneath an 'objects' key, and metadata such as 'count' of the number of objects in the response, as well as the total number of objects in the collection is also returned:
{
"objects": [
{
"updated_at": "2012-08-29T06:46:10Z",
"name": "Lena Deberon",
"id": "9a700bdc-f115-11e1-bac8-001cc01904e3",
"display": "Lena Deberon"
},
{
"updated_at": "2012-08-29T06:46:17Z",
"name": "Sara Heandy",
"id": "3c2db07a-f1a5-11e1-a7df-001cc01904e3",
"display": "Sara Heandy"
}
],
"count": 2,
"total": 2,
"more": false
}
[
{
"_updated_at": "2012-08-29T06:46:10Z",
"name": "Lena Deberon",
"id": "9a700bdc-f115-11e1-bac8-001cc01904e3",
"display_name": "Lena Deberon",
"display_attachments": {
}
},
{
"_updated_at": "2012-08-29T06:46:17Z",
"name": "Sara Heandy",
"id": "3c2db07a-f1a5-11e1-a7df-001cc01904e3",
"display_name": "Sara Heandy",
"display_attachments": {
}
}
]

3. Partial Updates to Objects Should Now Use PATCH Method

In API v1, using the PUT HTTP request method would perform a partial update on an object (e.g. only updating a selected set of the object's fields). In API v4, PATCH must now be used for partial updates.
Failure to change the HTTP request method for partial updates to PATCH will result in data loss!

Partial update to an object in API v1:

PUT https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json
task[status]=1
curl "https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json" \
-u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V" \
-X PUT \
-d "task[status]=1"
require 'rest-client'
journey = RestClient::Resource.new "https://run-testing-us.journeyapps.com/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json"].put :task=>{:status=>1}

Partial update to an object in API v4:

PATCH https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json
task[status]=1
curl "https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json" \
-u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V" \
-X PATCH \
-d "task[status]=1"
require 'rest-client'
journey = RestClient::Resource.new "https://run-testing-us.journeyapps.com/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json"].patch :task=>{:status=>1}

4. PUT Method Will Replace Object Completely

Whereas in API v1, using the PUT HTTP request method will perform a partial update on an object, in API v4, the PUT method will replace the object completely. In other words, fields that are not present (in the object payload provided) will be cleared.

Replace object in API v1:

Not supported in API v1.

Replace object in API v4:

PUT https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json
task[status]=1
curl "https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json" \
-u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V" \
-X PUT \
-d "task[status]=1"
require 'rest-client'
journey = RestClient::Resource.new "https://run-testing-us.journeyapps.com/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/tasks/198c990e-f1bf-11e1-8d7d-001cc01904e3.json"].put :task=>{:status=>1}

5. Updated Field Representation for Choice Data Types

"Choice" data types, i.e. single-choice, single-choice-integer, multiple-choice and multiple-choice-integer now return now the value/key and the display name of the selected option(s):
'single-choice-integer' representation in API v1:
'single-choice-integer' representation in API v4:
"status": 1
"status": {"key": 1,"display": "Closed"}
Refer to Field Representation for more details.

6. Changes to Photos and Signatures Response Data Format

In API v4, the response data format for photos and signatures include various changes:
  • Photos and signatures are no longer included in a separate display_attachments field — they are now directly part of the object's fields in the response data.
  • URLs for photos and attachments are now absolute URLs, no longer relative URLs
  • A state field now indicates the availability of the image — pending or uploaded.
{
"id": "c3d59ff0-ba4a-11e3-a567-001e6733fe3c",
"type": "task",
"updated_at": "2015-02-05T08:17:58Z",
"display": "Buy Groceries",
"name": "Buy Groceries",
"photo": {
"id": "eacb4836-f1b9-11e1-9750-001cc01904e3",
"state": "uploaded",
"thumbnail": "https://run.journeyapps.com/media/AwNDkyOSJdLFsicCIsI?sha1=12345",
"fullscreen": "https://run.journeyapps.com/media/3JlZW4iXV0W1siZiIs?sha1=12345",
"original": "https://run.journeyapps.com/media/SJdLFsicCIsW1siZiIs?sha1=12345"
}
}
{
"id": "c3d59ff0-ba4a-11e3-a567-001e6733fe3c",
"type": "task",
"updated_at": "2015-02-05T08:17:58Z",
"display": "Buy Groceries",
"name": "Buy Groceries",
"display_attachments": {
"photo": {
"thumbnail": "/media/AwNDkyOSJdLFsicCIsI?sha1=12345",
"fullscreen": "/media/3JlZW4iXV0W1siZiIs?sha1=12345",
"original": "/media/SJdLFsicCIsW1siZiIs?sha1=12345"
}
}
}

7. New Data Model Naming Conventions

Take note that the Changes in Naming in JourneyApps v4 are reflected when retrieving an app's Data Model.
{
"models": {
"user": {
"name": "user",
"label": "User",
"display": "{name}",
"fields": {
"name": {
"name": "name",
"label": "Name",
"type": "text",
"subtype": "name"
}
},
"belongs_to": {
},
"has_many": {
}
},
"category": {
"name": "category",
"label": "Category",
"display": "{name}",
"fields": {
"name": {
"name": "name",
"label": "Name",
"type": "text"
}
},
"belongs_to": {
},
"has_many": {
"tasks": {
"model": "task",
"name": "tasks",
"inverse_of": "category"
}
}
},
"task": {
"name": "task",
"label": "Task",
"display": "{name}",
"fields": {
"name": {
"name": "name",
"label": "Name",
"type": "text"
},
"instructions": {
"name": "instructions",
"label": "Instructions",
"type": "text"
},
"status": {
"name": "status",
"label": "Status",
"type": "single-choice-integer",
"options": [
{
"key": 0,
"display": "Open"
},
{
"key": 1,
"display": "Closed"
}
]
}
},
"belongs_to": {
"category": {
"model": "category",
"name": "category",
"inverse_of": "tasks"
}
},
"has_many": {
}
}
}
}
{
"objects":{
"user":{
"has_many":{
},
"belongs_to":{
},
"name":"user",
"label":"User",
"attributes":{
"name":{
"name":"name",
"label":"Name",
"type":"string",
"spec":"text.name"
}
},
"display_format":"{name}"
},
"category":{
"has_many":{
"tasks":{
"type":"task",
"inverse_of":"category",
"name":"tasks"
}
},
"belongs_to":{
},
"name":"category",
"label":"Category",
"attributes":{
"name":{
"name":"name",
"label":"Name",
"type":"string"
}
},
"display_format":"{name}"
},
"task":{
"has_many":{
},
"belongs_to":{
"category":{
"type":"category"
}
},
"name":"task",
"label":"Task",
"attributes":{
"name":{
"name":"name",
"label":"Name",
"type":"string"
},
"instructions":{
"name":"instructions",
"label":"Instructions",
"type":"string"
},
"status":{
"name":"status",
"label":"Status",
"type":"enum",
"options":[
"Open",
"Closed"
]
}
},
"display_format":"{name}"
}
}
}

8. JSON Response Format Supported Only

Whereas API v1 supports XML and JSON response formats, API v4 only supports JSON.

9. Structured Error Responses

API error responses in API v4 are now more structured, with specific error types:
{
"type": "INVALID_VALUE",
"title": "Invalid value specified.",
"detail": "Invalid option \"test\" for field 'status'.",
"see": "https://resources.journeyapps.com/v4/api/errors/INVALID_VALUE"
}
{
"errors": [
"Invalid object type: 'car'"
]
}
Copy link
On this page
1. API URL Path Changes
2. Response Data Format for Retrieving Multiple Objects
3. Partial Updates to Objects Should Now Use PATCH Method
4. PUT Method Will Replace Object Completely
5. Updated Field Representation for Choice Data Types
6. Changes to Photos and Signatures Response Data Format
7. New Data Model Naming Conventions
8. JSON Response Format Supported Only
9. Structured Error Responses