Create a New Object

This function creates a single new object of the given type.

Relative URLHTTP Request Method

/api/v4/backend-deployment-id/objects/model.json

POST

Replace model with the type of object that you wish to create (as defined in your app's Data Model), for example person, job or asset.

Parameters

A hash needs to be supplied containing the following:

  • Fields: Fields as defined in your app's Data Model.

  • Relationships: IDs of related objects that the object belongs-to specified by using the relationship name and appending it with _id.

For the format of all the different field types, see the Field Representation section.

The key of this hash has to be the name of the object type (see example below). In the following example of parameters in JSON format, the object type name is car and it has three fields: make, model and license_plate and one relationship: it belongs to a warehouse.

{
  "car": {
    "make": "Toyota",
    "model": "Land Cruiser 100",
    "license_plate": "ABC123",
    "warehouse_id": "55c1a6a0-f1b8-11e1-a7df-001cc01904e3"
  }
}

For creating more than one object in a request, see Batch Operations.

Response

The response includes the single newly created object. The format of the object is the same as for Retrieving all Objects.

Example

BASE-URL

The below examples contain a BASE-URL placeholder. Please refer to the HTTP Endpoints section to get the base URL relevant to your deployment.

Parameters as URL-encoded key-value pairs: (refer to Request Parameter Formats)

POST BASE-URL/api/v4/533bda53027894f69b001055/objects/task.json

task[name]=My%20First%20Task&task[status]=1

Response:

{
  "id": "3c18fdc0-b02e-11e4-827d-001e6733fe3c",
  "type": "task",
  "updated_at": "2015-02-09T07:35:35Z",
  "display": "My First Task",
  "name": "My First Task",
  "instructions": null,
  "status": {
    "key": 1,
    "display": "Closed"
  },
  "category_id": null
}

Sending parameters as JSON:

POST BASE-URL/api/v4/533bda53027894f69b001055/objects/task.json

{"task":{"name":"My First Task","status":1}}

Last updated