# Retrieve a Single Object

## Retrieving a Single Object

This function allows you to retrieve a single object of the given type and with the given ID.

<table><thead><tr><th width="530">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>/</code><em><code>object-id</code></em><code>.json</code></td><td>GET</td></tr></tbody></table>

{% hint style="info" %}

* Replace *`model`* with the type of object that you wish to retrieve (as defined in your app's Data Model) for example `person`, `job` or `asset`.
* Replace *`object-id`* with the ID of the specific object.
* Replace *`format`* with the [response data format](https://docs.journeyapps.com/reference/backend-api/create-a-new-object#response) (`json` or `xml`), or leave it out.
  {% endhint %}

### Parameters

This function does not take any parameters.

### Response

The response includes the single object requested. 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 %}

Sample request:

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

```http
GET BASE-URL/api/v4/533bda53027894f69b001055/objects/task/c3d59ff0-ba4a-11e3-a567-001e6733fe3c.json
```

{% endtab %}

{% tab title="curl" %}

<pre class="language-shell"><code class="lang-shell"><strong>curl "BASE-URL/api/v4/533bda53027894f69b001055/objects/task/c3d59ff0-ba4a-11e3-a567-001e6733fe3c.json" \
</strong>    -u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V"
</code></pre>

{% endtab %}

{% tab title="ruby" %}

```ruby
require 'rest-client'
journey = RestClient::Resource.new "BASE-URL/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/task/c3d59ff0-ba4a-11e3-a567-001e6733fe3c.json"].get
```

{% endtab %}
{% endtabs %}

Sample response:

{% code title="json" %}

```json
{
    "id": "c3d59ff0-ba4a-11e3-a567-001e6733fe3c",
    "type": "task",
    "updated_at": "2015-02-05T08:17:58Z",
    "display": "Buy Groceries",
    "name": "Buy Groceries",
    "instructions": "Not too much",
    "status": {
      "key": 1,
      "display": "rubyClosed"
    },
    "category_id": "71fafc16-ba4f-11e3-8de0-001e6733fe3c"
}
```

{% endcode %}

## Retrieving Related Objects

You can optionally retrieve related objects that the object **belongs-to** in one operation.

### Parameters

Specify the relationship names for the related objects you want to retrieve as a comma-separated list in a parameter named `embed`.

### 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 %}

Let's say our Data Model allows for `task` objects that *belong to* `category` objects, so that each category *has many* tasks. When we're retrieving a task, we can embed the related category that it belongs to as follows:

Sample request:

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

```http
GET BASE-URL/api/v4/533bda53027894f69b001055/objects/task/c3d59ff0-ba4a-11e3-a567-001e6733fe3c.json?embed=category
```

{% endtab %}

{% tab title="curl" %}

```shell
curl "BASE-URL/api/v4/533bda53027894f69b001055/objects/task/c3d59ff0-ba4a-11e3-a567-001e6733fe3c.json?embed=category" \
    -u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V"
```

{% endtab %}

{% tab title="ruby" %}

```ruby
require 'rest-client'
journey = RestClient::Resource.new "BASE-URL/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/task/c3d59ff0-ba4a-11e3-a567-001e6733fe3c.json"].get :params => {:embed=>"category"}
```

{% endtab %}
{% endtabs %}

The response features the `task` object with the `category` object that it belongs to embedded inside it:

{% code title="json" %}

```json
{
    "id": "c3d59ff0-ba4a-11e3-a567-001e6733fe3c",
    "type": "task",
    "updated_at": "2015-02-05T08:17:58Z",
    "display": "Buy Groceries",
    "name": "Buy Groceries",
    "instructions": "Not too much",
    "status": {
         "key": 1,
         "display": "Closed"
    },
    "category_id": "71fafc16-ba4f-11e3-8de0-001e6733fe3c",
    "category": {
        "id": "71fafc16-ba4f-11e3-8de0-001e6733fe3c",
        "type": "category",
        "updated_at": "2015-02-05T08:18:09Z",
        "display": "Household",
        "name": "Household"
    }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.journeyapps.com/reference/backend-api/api-reference/retrieve-a-single-object.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
