---
schema_version: "1"
id: e132ac47f30ffd57b23df648e642dca95f641c9025e09b71a85969b671eed3b8
title: Get Records Using sObject Relationships
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/api-rest/guides/resources/resources-sobject-relationships-get.md
canonical_url: https://developer.salesforce.com/docs/platform/api-rest/guide/resources-sobject-relationships-get.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: fa4b8372050ab63c71c7dc13d8d6a1f35f20e129245b333039a84ed666640da2
products:
  - REST API Developer Guide
  - Platform Developer Content
---

# Get Records Using sObject Relationships

Gets a record based on the specified object, record ID, and relationship field. The fields and field values of the record are returned in the response body. If there are multiple related records, you can retrieve the complete set of associated records.

If there’s no record associated with a relationship field, a 404 error response is returned. If the relationship field normally resolves to multiple records and no relationship set exists, a 200 response is returned. If the `fields` parameter is used with fields that don’t exist or aren’t visible to the consumer by field-level security, a 400 error response is returned. For other error messages, see [Status Codes and Error Responses](https://developer.salesforce.com/docs/platform/api-rest/guide/errorcodes.md).

## Syntax

**URI:** `/services/data/vXX.X/sobjects/sObject/id/relationshipFieldName`

**Formats:** JSON, XML

**HTTP Method:** GET

**Authentication:** `Authorization: Bearer token`

**Parameters**

|Parameter|Description|
|---------|-----------|
|`sObject`|The name of the object. For example, `Account`.|
|`id`|The identifier of the record. For example, `001R0000005hDFYIA2`.|
|`relationshipFieldName`|The name of the field that contains the relationship. For example, `Opportunities`.|
|`fields`|Optional for GET. A comma-delimited list of fields in the associated relationship record returned in the response body.|

Example `fields`:

```nolang
/services/data/v68.0/sobjects/sObject/id/relationship field?fields=field1,field2
```

## Example

For examples of using sObject Relationships to access relationship fields, see [Traverse Relationships with Friendly URLs](https://developer.salesforce.com/docs/platform/api-rest/do-me/dome-relationship-traversal.md#traverse-relationships-with-friendly-urls).

**Example Request**

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/v68.0/sobjects/Merchandise__c/a01D000000INjVe/Distributor__r -H “Authorization: Bearer token”
```

**Example Response Body**

The response body is the contents of the record associated with the relationship field. Here’s an example of a request and JSON response body for a simple relationship traversal that returns the Distributor__c record associated with a relationship field on custom object Merchandise__c.

```nolang
{
    "attributes" : 
    { 
        "type" : "Distributor__c",
        "url" : "/services/data/v68.0/sobjects/Distributor__c/a03D0000003DUhcIAG"
    },
    "Id" : "a03D0000003DUhcIAG",
    "OwnerId" : "005D0000001KyEIIA0",
    "IsDeleted" : false,
    "Name" : "Distributor1",
    "CreatedDate" : "2011-12-16T17:43:01.000+0000",
    "CreatedById" : "005D0000001KyEIIA0",
    "LastModifiedDate" : "2011-12-16T17:43:01.000+0000",
    "LastModifiedById" : "005D0000001KyEIIA0",
    "SystemModstamp" : "2011-12-16T17:43:01.000+0000",
    "Location__c" : "San Francisco"
}
```

**See Also**  


-   [Object Reference for the Salesforce Platform](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/)

