# Create a New Object

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

<table><thead><tr><th width="529">Relative URL</th><th>HTTP Request Method</th></tr></thead><tbody><tr><td><code>/api/v4/</code><em><code>backend-deployment-id</code></em><code>/objects/</code><em><code>model</code></em><code>.json</code></td><td>POST</td></tr></tbody></table>

{% hint style="info" %}
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`.
{% endhint %}

### Parameters

A [hash](http://en.wikipedia.org/wiki/Associative_array) needs to be supplied containing the following:

* `Fields`**:** Fields as defined in your app's [Data Model](https://docs.journeyapps.com/reference/build/data-model-configuration/model).
* `Relationships`**:** IDs of related objects that the object [*belongs-to*](https://docs.journeyapps.com/reference/build/data-model-configuration) specified by using the relationship name and appending it with `_id`.

For the format of all the different field types, see the [Field Representation](https://docs.journeyapps.com/reference/backend-api/api-reference/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*.

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

{% hint style="info" %}
For creating more than one object in a request, see [Batch Operations](https://docs.journeyapps.com/reference/backend-api/api-reference/batch-operations-v4-api).
{% endhint %}

### Response

The response includes the single newly created object. The format of the object is the same as for [Retrieving all Objects](https://docs.journeyapps.com/reference/backend-api/api-reference/retrieve-all-objects).

### Example

{% hint style="info" %}
**BASE-URL**

The below examples contain a `BASE-URL` placeholder. Please refer to the [HTTP Endpoints](https://docs.journeyapps.com/reference/introduction#http-endpoints) section to get the base URL relevant to your deployment.
{% endhint %}

Parameters as URL-encoded key-value pairs: (refer to [Request Parameter Formats](https://docs.journeyapps.com/reference/backend-api/introduction))

{% tabs %}
{% tab title="http" %}

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

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

{% endtab %}

{% tab title="curl" %}

```shell
curl "BASE-URL/api/v4/533bda53027894f69b001055/objects/task.json" \
    -u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V" \
    -d "task[name]=My%20First%20Task" \
    -d "task[status]=1"
```

{% endtab %}

{% tab title="ruby" %}

```ruby
require 'rest-client'
journey = RestClient::Resource.new "BASE-URL/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/task.json"].post :task=>{:name=>"My First Task", :status=>1}
```

{% endtab %}
{% endtabs %}

Response:

```json
{
  "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:

{% tabs %}
{% tab title="HTTP" %}

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

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

{% endtab %}

{% tab title="curl" %}
{% hint style="info" %}
The `-H` parameter to curl allows you to specify a custom HTTP header.
{% endhint %}

```shell
curl "BASE-URL/api/v4/533bda53027894f69b001055/objects/task.json" \
    -u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V" \
    -H "Content-Type: application/json" \
    -d '{"task":{"name":"My First Task","status":1}}'
```

{% endtab %}

{% tab title="ruby" %}

```ruby
require 'rest-client'
require 'json'
journey = RestClient::Resource.new "BASE-URL/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/task.json"].post({:task=>{:name=>"My First Task", :status=>1}}.to_json, :content_type => :json)
```

{% endtab %}
{% endtabs %}
