---
schema_version: "1"
id: 7218d56b7b81bf53fce65b1518addd8111e76004c13dd8fa5b101a918ace3e18
title: REST API Examples
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/caf-dev/guides/caf/caf-dev-examples-api-rest.md
canonical_url: https://developer.salesforce.com/docs/platform/caf-dev/guide/caf-dev-examples-api-rest.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 695f7086557542a8d791a25823f6716bb48cb28633d60738005aeee5e929397f
products:
  - Custom Address Fields Developer Guide
  - Platform Developer Content
---

# REST API Examples

Use REST API to create, update, or delete a record with Custom Address Fields data.

**note:** Before you create a custom address field, review the [Custom Address Fields Requirements and Limitations](https://developer.salesforce.com/docs/platform/caf-dev/guide/caf-dev-limitations.md). To discuss the feature and ask questions, join the [Custom Address Fields Discussion](https://trailhead.salesforce.com/trailblazer-community/groups/0F94S000000H3KISA0) group on the Trailblazer Community.

## Create a New Account with Data in a Custom Address Field

To create a new record, use the [sObject](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_basic_info.htm) resource. You supply the required field values in the request data, and send the request using the POST HTTP method. The response body contains the ID of the new record if the call is successful.

This example creates an Account record which includes address data stored in the Mailing Address custom address field.

**Example HTTP POST method to create a new Account**

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/68.0/sobjects/Account -H "Authorization: Bearer token" -H "Content-Type: application/json" -d "@newaccount.json"
```

**Example request body newaccount.json file to create a new Account**

```nolang
{
"Name" : "Acme Incorporated",
"Mailing_Address__City__s" : "Ahmedabad",
"Mailing_Address__CountryCode__s" : "IN",
"Mailing_Address__Street__s" : "102 Suryakoti",
"Mailing_Address__PostalCode__s" : "380022",
"Mailing_Address__StateCode__s": "GJ",
"Mailing_Address__Latitude__s" : "37.775",
"Mailing_Address__Longitude__s" : "-122.418",
"Mailing_Address__GeocodeAccuracy__s" : "Address"
}

```

**Example response body after successfully creating a new Account**

```nolang
{
  "id" : "001XXXXXXXXXXXXXXX",
  "errors" : [ ],
  "success" : true
}
```

## Update Data Within a Custom Address Field on a Record

To update a record, use the [sObject Rows](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_retrieve.htm) resource. Provide the updated record information in your request data and use the PATCH method of the resource with a specific record ID to update that record. Records in a single file must be of the same object type.

This example updates the data stored in the Mailing Address custom address field for record ID `001XXXXXXXXXXXXXXX`.

**HTTP PATCH example for updating an Account**

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/68.0/sobjects/Account/001XXXXXXXXXXXXXXX -H "Authorization: Bearer token" -H "Content-Type: application/json" -d @patchaccount.json -X PATCH
```

**Example request body patchaccount.json file for updating the custom field, Mailing Address, on an Account**

```nolang
{
"Mailing_Address__City__s" : "Surendranagar",
"Mailing_Address__CountryCode__s" : "IN",
"Mailing_Address__Street__s" : "20 Udhyog Nagar",
"Mailing_Address__PostalCode__s" : "363001",
"Mailing_Address__StateCode__s":  "GJ",
"Mailing_Address__Latitude__s" : "22.757580",
"Mailing_Address__Longitude__s" : "71.619350",
"Mailing_Address__GeocodeAccuracy__s" : "Address"
}
```

**Example response body after successfully updating an Account:** None returned

## Delete Data Within a Custom Address Field on a Record

To delete address data stored within a custom address field on a record, update the record with the [sObject Rows](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_retrieve.htm) resource. Provide the updated record information in your request data and use the PATCH method of the resource with a specific record ID to update that record. Records in a single file must be of the same object type.

This example deletes the data stored in the Mailing Address custom address field for record ID `001XXXXXXXXXXXXXXX`.

**HTTP PATCH example for updating an Account**

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/68.0/sobjects/Account/001XXXXXXXXXXXXXXX -H "Authorization: Bearer token" -H "Content-Type: application/json" -d @patchaccount.json -X PATCH
```

**Example request body patchaccount.json file for updating the custom field, Mailing Address, on an Account**

```nolang
{
"Mailing_Address__City__s" : null,
"Mailing_Address__CountryCode__s" : null,
"Mailing_Address__Street__s" : null,
"Mailing_Address__PostalCode__s" : null,
"Mailing_Address__StateCode__s":  null,
"Mailing_Address__Latitude__s" : null,
"Mailing_Address__Longitude__s" : null,
"Mailing_Address__GeocodeAccuracy__s" : null
}
```

**Example response body after successfully updating an Account:** None returned

## Delete a Record That Contains Data in a Custom Address Field

To delete records, use the [sObject Rows](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_retrieve.htm) resource. Specify the record ID and use the DELETE method of the resource to delete a record. When a record is deleted, all data for that record is deleted, including the custom address field information.

This example deletes the Account record with ID `001XXXXXXXXXXXXXXX`.

**HTTP DELETE example for updating an Account**

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/68.0/sobjects/Account/001XXXXXXXXXXXXXXX  -H "Authorization: Bearer token" -X DELETE
```

**Example request body:** None needed

**Example response body after successfully updating an Account:** `200 OK`

