Updating to the V4 API
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/ backend-deployment-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/ backend-deployment-id /objects/ object-name .json |
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/ backend-deployment-id /datamodel.json |
Accessing the Oplog in API v1: | Accessing the Oplog in API v4: |
---|---|
/api/v1/_oplog.json | /api/v4/ backend-deployment-id /oplog.json |
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:
V4
V1
{
"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": {
}
}
]
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!
HTTP
curl
ruby
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}
HTTP
curl
ruby
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 \
shell -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}
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.
Not supported in API v1.
HTTP
curl
ruby
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}
"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"} |
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
oruploaded
.
V4
V1
{
"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"
}
}
}
Take note that the Changes in Naming in JourneyApps v4 are reflected when retrieving an app's Data Model.
V4
V1
{
"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}"
}
}
}
Whereas API v1 supports XML and JSON response formats, API v4 only supports JSON.
V4
V1
{
"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'"
]
}
Last modified 10mo ago