Api Rest
Api Rest
Api Rest
@salesforcedocs
Last updated: February 23, 2021
© Copyright 2000–2020 salesforce.com, inc. All rights reserved. Salesforce is a registered trademark of salesforce.com, inc.,
as are other names and marks. Other marks appearing herein may be trademarks of their respective owners.
CONTENTS
Chapter 3: Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Getting Information About My Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
List Available REST API Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
List Organization Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
List Available REST Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Get a List of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Get an Image from a Rich Text Area Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Get a List of Objects If Metadata Has Changed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Working with Object Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Retrieve Metadata for an Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Get Field and Other Metadata for an Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Get Object Metadata Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Working with Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Create a Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Update a Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Delete a Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Get Field Values from a Standard Object Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Get Field Values from an External Object Record by Using the Salesforce ID . . . . . . . . . . 34
Get Field Values from an External Object Record by Using the External ID Standard
Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Retrieve a Record Using an External ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Insert or Update (Upsert) a Record Using an External ID . . . . . . . . . . . . . . . . . . . . . . . 35
Contents
Chapter 4: Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Resources by Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Describe Global . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
sObject Basic Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
sObject Describe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
sObject Get Deleted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
sObject Get Updated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
sObject Named Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
sObject Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
sObject Rows by External ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
sObject Blob Retrieve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
sObject ApprovalLayouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
sObject CompactLayouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Describe Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
sObject PlatformAction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
sObject Quick Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
sObject Rich Text Image Retrieve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
sObject Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
sObject Suggested Articles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
sObject User Password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Platform Event Schema by Event Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Platform Event Schema by Schema ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
AppMenu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Compact Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Consent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Use the Consent API with Customer 360 Audiences . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Consent Write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Embedded Service Configuration Describe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Invocable Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Standard Invocable Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Custom Invocable Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
List View Describe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
List View Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
List Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Support Knowledge with REST API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Data Category Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Data Category Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Articles List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Articles Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Parameterized Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Portability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Process Approvals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Contents
In this chapter ... REST API provides a powerful, convenient, and simple Web services API for interacting with Lightning
Platform. Its advantages include ease of integration and development, and it’s an excellent choice of
• Lightning Platform technology for use with mobile applications and Web 2.0 projects. If you have many records to process,
REST Resources consider using Bulk API, which is based on REST principles and optimized for large sets of data.
• Using Compression
REST API uses the same underlying data model and standard objects as those in SOAP API. See the SOAP
• Using Conditional API Developer Guide for details. REST API also follows the same limits as SOAP API. See the Limits section
Requests in the SOAP API Developer Guide.
• Using cURL in the
To use the API requires basic familiarity with software development, web services, and the Salesforce
REST Examples
user interface.
• Authorization
Through Connected Use this introduction to understand:
Apps and OAuth 2.0 • The key characteristics and architecture of REST API. This will help you understand how your
• Perform Cross-Origin applications can best use the Lightning Platform REST resources.
Requests from Web • How to set up your development environment so you can begin working with REST API immediately.
Browsers
• How to use REST API by following a quick start that leads you step by step through a typical use case.
• API End-of-Life
1
Introducing Lightning Platform REST API Lightning Platform REST Resources
curl https://yourInstance.salesforce.com/services/data/
Note: Salesforce runs on multiple server instances. The examples in this guide use yourInstance in place of a specific
instance. Replace that text with the instance for your org.
Important characteristics of the Lightning Platform REST API resources and architecture:
Stateless
Each request from client to server must contain all the information necessary to understand the request, and not use any stored
context on the server. However, the representations of the resources are interconnected using URLs, which allow the client to progress
between states.
Caching behavior
Responses are labeled as cacheable or non-cacheable.
Uniform interface
All resources are accessed with a generic interface over HTTP.
Named resources
All resources are named using a base URI that follows your Lightning Platform URI.
Layered components
The Lightning Platform REST API architecture allows for the existence of such intermediaries as proxy servers and gateways to exist
between the client and the resources.
Authentication
The Lightning Platform REST API supports OAuth 2.0 (an open protocol to allow secure API authorization). See Authorize Apps with
OAuth in the Salesforce Help for more details.
2
Introducing Lightning Platform REST API Using Compression
Using Compression
The REST API allows the use of compression on the request and the response, using the standards defined by the HTTP 1.1 specification.
Compression is automatically supported by some clients, and can be manually added to others. Visit Salesforce for more information on
particular clients.
Tip: For better performance, we suggest that clients accept and support compression as defined by the HTTP 1.1 specification.
To use compression, include the HTTP header Accept-Encoding: gzip or Accept-Encoding: deflate in a request.
The REST API compresses the response if the client properly specifies this header. The response includes the header
Content-Encoding: gzip or Accept-Encoding: deflate. You can also compress any request by including a
Content-Encoding: gzip or Content-Encoding: deflate header.
Response Compression
The REST API can optionally compress responses. Responses are compressed only if the client sends an Accept-Encoding header.
The REST API is not required to compress the response even if you have specified Accept-Encoding, but it normally does. If the
REST API compresses the response, it also specifies a Content-Encoding header.
Request Compression
Clients can also compress requests. The REST API decompresses any requests before processing. The client must send a
Content-Encoding HTTP header in the request with the name of the appropriate compression algorithm. For more information,
see:
• Content-Encoding at: www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11
• Accept-Encoding at: www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
• Content Codings at: www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5
3
Introducing Lightning Platform REST API Using Conditional Requests
4
Introducing Lightning Platform REST API Using cURL in the REST Examples
If-Unmodified-Since
HTTP 1.1 specification: www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.28
The If-Unmodified-Since header is a request header that’s the inverse of If-Modified-Since. If you make a request
and include the If-Unmodified-Since header, the request is processed only if the data hasn’t changed since the specified
date. Otherwise, a 412 Precondition Failed status code is returned, and the request isn’t processed.
Supported resources: sObject Rows, sObject Describe, Describe Global, and Invocable Actions
Example: If-Unmodified-Since: Tue, 10 Aug 2015 00:00:00 GMT
Escaping the Session ID or Using Single Quotes on Mac and Linux Systems
When running the cURL examples for the REST resources, you may get an error on Mac and Linux systems due to the presence of
the exclamation mark special character in the session ID argument. To avoid getting this error, do one of the following:
• Escape the exclamation mark (!) special character in the session ID by inserting a backslash before it (\!) when the session ID is
enclosed within double quotes. For example, the session ID string in this cURL command has the exclamation mark (!) escaped:
curl https://instance_name.salesforce.com/services/data/v51.0/
-H "Authorization: Bearer
00D50000000IehZ\!AQcAQH0dMHZfz972Szmpkb58urFRkgeBGsxL_QJWwYMfAbUeeG7c1E6
LYUfiDUkWe6H34r1AAwOR8B8fLEz6n04NPGRrq0FM"
curl https://instance_name.salesforce.com/services/data/v51.0/
-H 'Authorization: Bearer sessionID'
5
Introducing Lightning Platform REST API Perform Cross-Origin Requests from Web Browsers
More Resources
Salesforce offers the following resources to help you navigate connected apps and OAuth:
• Salesforce Help: Connected Apps
• Salesforce Help: Authorize Apps with OAuth
• Salesforce Help: OpenID Connect Token Introspection
• Trailhead: Build Integrations Using Connected Apps
6
Introducing Lightning Platform REST API API End-of-Life
The origin URL pattern must include the HTTPS protocol (unless you’re using your localhost) and a domain name. It can also include
a port. The wildcard character (*) is supported and must be in front of a second-level domain name. For example,
https://*.example.com adds all subdomains of example.com to the allowlist.
The origin URL pattern can be an IP address. However, an IP address and a domain that resolve to the same address are not the same
origin, and you must add them to the CORS allowlist as separate entries.
The origin URL pattern might not match the URL that appears in your browser's address bar. Make sure that you’re allowing the
origin in the request header.
Note: To access certain OAuth endpoints with CORS, other requirements apply. See Enable CORS for OAuth Endpoints.
API End-of-Life
Salesforce is committed to supporting each API version for a minimum of three years from the date of first release. In order to mature
and improve the quality and performance of the API, versions that are more than three years old might cease to be supported.
When an API version is to be deprecated, advance notice is given at least one year before support ends. Salesforce will directly notify
customers using API versions planned for deprecation.
Note: Version v20.0 of REST API will be retired in the Summer ’21 release. For more information, see Knowledge Article: Lightning
Platform API legacy versions retirement.
7
CHAPTER 2 Quick Start
In this chapter ... Create a sample REST application in your development environment to see the power and flexibility of
the REST API.
• Prerequisites
• Step One: Obtain a
Salesforce Developer
Edition Organization
• Step Two: Set Up
Authorization
• Step Three: Send
HTTP Requests with
cURL
• Step Four: Walk
Through the Sample
Code
• Using Workbench
8
Quick Start Prerequisites
Prerequisites
Completing the prerequisites makes it easier to build and use the quick-start sample.
If you’re unfamiliar with cURL and JavaScript Object Notation (JSON), you can also use Workbench to obtain data.
• Install your development platform according to its product documentation.
• Become familiar with cURL, the tool used to execute REST requests in this quick start. If you use another tool, you should be familiar
enough with it to translate the example code.
• Become familiar with JSON which is used in this quick start, or be able to translate samples from JSON to the standard you use.
• Enable an SSL endpoint in your application server.
• Become familiar with OAuth 2.0, which requires some setup. We provide the steps, but it will help if you are familiar with the basic
concepts and workflow.
• Read through all the steps before beginning this quick start. You may also wish to review the rest of this document to familiarize
yourself with terms and concepts.
Important: If you’re handling someone else’s password, don’t use session ID.
Note: The OAuth 2.0 specification uses “client” instead of “consumer.” Salesforce supports OAuth 2.0.
The values here correspond to the following values in the sample code in the rest of this procedure:
9
Quick Start Step Two: Set Up Authorization
2. From your Java or other client application, make a request to the appropriate Salesforce token request endpoint that passes in
grant_type, client_id, client_secret, and redirect_uri. The redirect_uri is the URI that Salesforce
sends a callback to.
initParams = {
@WebInitParam(name = "clientId", value =
"3MVG9lKcPoNINVBJSoQsNCD.HHDdbugPsNXwwyFbgb47KWa_PTv"),
@WebInitParam(name = "clientSecret", value = "5678471853609579508"),
@WebInitParam(name = "redirectUri", value =
"https://localhost:8443/RestTest/oauth/_callback"),
@WebInitParam(name = "environment", value =
"https://login.salesforce.com/services/oauth2/token") }
/** For session ID instead of OAuth 2.0, use "grant_type", "password" **/
post.addParameter("client_id",clientId);
post.addParameter("client_secret",clientSecret);
post.addParameter("redirect_uri",redirectUri);
If the value of client_id (or consumer key) and client_secret (or consumer secret) are valid, Salesforce
sends a callback to the URI specified in redirect_uri that contains a value for access_token.
3. Store the access token value as a cookie to use in all subsequent requests. For example:
//exception handling removed for brevity...
//this is the post from step 2
httpclient.executeMethod(post);
String responseBody = post.getResponseBodyAsString();
} catch (JSONException e) {
e.printStackTrace();
}
10
Quick Start Step Two: Set Up Authorization
4. Once authorized, every request must pass in the access_token value in the header. It cannot be passed as a request parameter.
HttpClient httpclient = new HttpClient();
GetMethod gm = new GetMethod(serviceUrl);
/**
* other option instead of query string, pass just the fields you want back:
* https://instance_name.salesforce.com/services/data/v51.0/sobjects/Account/
* 001D000000INjVe?fields=AccountNumber,BillingPostalCode
*/
params[0] = new NameValuePair("q","SELECT name, title FROM Contact LIMIT 100");
gm.setQueryString(params);
httpclient.executeMethod(gm);
String responseBody = gm.getResponseBodyAsString();
//exception handling removed for brevity
JSONObject json = new JSONObject(responseBody);
For example:
Session ID Authorization
You can use a session ID instead of an OAuth 2.0 access token if you aren’t handling someone else’s password:
11
Quick Start Step Three: Send HTTP Requests with cURL
1. Obtain a session ID, for example, a SOAP API login() call returns the session ID. You can also have the session ID, for example
as part of the Apex current context. If you need a session ID just for testing purposes during development, use the username-password
OAuth flow in a cURL command similar to the following:
curl https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d
"client_id=myclientid" -d "client_secret=myclientsecret"
-d "username=mylogin@salesforce.com" -d "password=mypassword123456"
You must provide your client id, client secret, username, and password with user security token appended.
2. Use the session ID when you send a request to the resource. Substitute the ID for the token value. The syntax is the same:
For example:
12
Quick Start Step Four: Walk Through the Sample Code
curl https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/ -H
"Authorization: Bearer token -H "Content-Type: application/json" -d "@newaccount.json"
The response:
Date: Thu, 21 Oct 2010 22:16:22 GMT
Content-Length: 71
Location: /services/data/v51.0/sobjects/Account/001T000000NU96UIAT
Content-Type: application/json; charset=UTF-8 Server:
{ "id" : "001T000000NU96UIAT",
"errors" : [ ],
"success" : true }
For a list of the resources and their corresponding URIs, see Reference on page 95.
SEE ALSO:
Using cURL in the REST Examples
13
Quick Start Step Four: Walk Through the Sample Code
curl https://yourInstance.salesforce.com/services/data/
The output specifies the resources available for all valid versions (your result may include more than one value). Next, use one of these
versions to discover the resources it contains.
From this output you can see that sobjects is one of the available resources in Salesforce version 20.0. You will be able to use this
resource in the next request to retrieve the available objects.
14
Quick Start Step Four: Walk Through the Sample Code
From this output you can see that the Account object is available. You will be able to get more information about the Account object
in the next steps.
curl https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/ -H
"Authorization: Bearer access_token" -H "X-PrettyPrint:1"
15
Quick Start Step Four: Walk Through the Sample Code
...
"replicateable" : true,
"retrieveable" : true,
"undeletable" : true,
"triggerable" : true
},
"recentItems" :
[
{
"attributes" :
{
"type" : "Account",
"url" : "/services/data/v51.0/sobjects/Account/001D000000INjVeIAL"
},
"Id" : "001D000000INjVeIAL",
"Name" : "asdasdasd"
},
...
]
}
From this output you can see some basic attributes of the Account object, such as its name and label, as well as a list of the most recently
used Accounts. Since you may need more information about its fields, such as length and default values, in the next step you will retrieve
more detailed information about the Account object.
curl https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/describe/
-H "Authorization: Bearer access_token" -H "X-PrettyPrint:1"
16
Quick Start Step Four: Walk Through the Sample Code
"type" : "id",
"defaultValue" : { "value" : null },
"updateable" : false,
"label" : "Account ID",
...
},
...
],
"updateable" : true,
"label" : "Account",
...
"urls" :
{
"uiEditTemplate" : "https://yourInstance.salesforce.com/{ID}/e",
"sobject" : "/services/data/v51.0/sobjects/Account",
"uiDetailTemplate" : "https://yourInstance.salesforce.com/{ID}",
"describe" : "/services/data/v51.0/sobjects/Account/describe",
"rowTemplate" : "/services/data/v51.0/sobjects/Account/{ID}",
"uiNewRecord" : "https://yourInstance.salesforce.com/001/e"
},
"childRelationships" :
[
{
"field" : "ParentId",
"deprecatedAndHidden" : false,
...
},
...
],
"createable" : true,
"customSetting" : false,
...
}
From this output you can see much more detailed information about the Account object, such as its field attributes and child relationships.
Now you have enough information to construct useful queries and updates for the Account objects in your organization, which you will
do in the next steps.
17
Quick Start Step Four: Walk Through the Sample Code
[
{
"attributes" :
{
"type" : "Account",
"url" : "/services/data/v51.0/sobjects/Account/001D000000IRFmaIAH"
},
"Name" : "Test 1"
},
{
"attributes" :
{
"type" : "Account",
"url" : "/services/data/v51.0/sobjects/Account/001D000000IomazIAB"
},
"Name" : "Test 2"
},
...
]
}
From this output you have a listing of the available Account names, and each name's preceding attributes include the Account IDs. In
the next step you will use this information to update one of the accounts.
Note: You can find more information about SOQL in the Salesforce SOQL and SOSL Reference Guide.
{
"BillingCity" : "Fremont"
}
Specify this JSON file in the REST request. The cURL notation requires the —d option when specifying data. For more information, see
http://curl.haxx.se/docs/manpage.html.
Also, specify the PATCH method, which is used for updating a REST resource. The following cURL command retrieves the specified
Account object using its ID field, and updates its Billing City.
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/001D000000IroHJ
-H "Authorization: Bearer access_token" -H "X-PrettyPrint:1" -H "Content-Type:
application/json" --data-binary @patchaccount.json -X PATCH
Refresh the page on the account and you will see that the Billing Address has changed to Fremont.
18
Quick Start Using Workbench
Other Resources
• Search for Ruby on developer.salesforce.com
• Lightning Platform Cookbook recipe for getting started in Ruby
• Lightning Platform REST API Board
Using Workbench
Use the Workbench tool to obtain data about your organization.
If you don’t want to use CURL, you can use the Workbench REST explorer to obtain response data.
1. Log in to your organization.
2. Open a new browser tab and navigate to https://workbench.developerforce.com/login.php .
3. Log in to Workbench and allow access to your organization. Workbench is a public site and won’t retain your data.
4. Click Utilities > REST Explorer.
5. Ensure that Get is selected. The Execute text box is prepopulated with a portion of a resource path. Add the remaining information
for your resource. For example, if your cURL syntax is
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/EventLogFile/describe
-H "Authorization: Bearer token"
type
/services/data/v51.0/sobjects/EventLogFile/describe.
6. Click Execute.
7. Click Expand All or Show Raw Response to view your data.
Tip: If you receive a “Service not found” message, verify your resource path.
19
CHAPTER 3 Examples
In this chapter ... This section provides examples of using REST API resources to do a variety of different tasks, including
working with objects, organization information, and queries.
• Getting Information
About My
For complete reference information on REST API resources, see Reference on page 95.
Organization
• Working with Object
Metadata
• Working with
Records
• Delete Lightning
Experience Event
Series
• Working with
Searches and
Queries
• Insert or Update Blob
Data
• Working with
Recently Viewed
Information
• Managing User
Passwords
• Working with
Approval Processes
and Process Rules
• Using Event
Monitoring
• Using Composite
Resources
20
Examples Getting Information About My Organization
IN THIS SECTION:
List Available REST API Versions
Use the Versions resource to list summary information about each REST API version currently available, including the version, label,
and a link to each version's root. You do not need authentication to retrieve the list of versions.
List Organization Limits
Use the Limits resource to list your org limits.
List Available REST Resources
Use the Resources by Version resource to list the resources available for the specified API version. This provides the name and URI
of each additional resource.
Get a List of Objects
Use the Describe Global resource to list the objects available in your org and available to the logged-in user. This resource also returns
the org encoding, as well as maximum batch size permitted in queries.
Get an Image from a Rich Text Area Field
Use the sObject Rich Text Image Retrieve to retrieve an image that has been uploaded to a rich text area field.
Get a List of Objects If Metadata Has Changed
Use the Describe Global resource and the If-Modified-Since HTTP header to determine if an object’s metadata has changed.
curl https://yourInstance.salesforce.com/services/data/
21
Examples List Organization Limits
"version" : "26.0",
"label" : "Winter '13",
"url" : "/services/data/v26.0"
}
]
22
Examples List Organization Limits
"Max" : 15000,
"Remaining" : 14998
},
"DailyAsyncApexExecutions" : {
"Max" : 250000,
"Remaining" : 250000
},
"DailyBulkApiBatches : {
"Max" : 15000,
"Remaining" : 15000
},
"DailyBulkV2QueryFileStorageMB": {
"Max": 976562,
"Remaining": 976562
},
"DailyBulkV2QueryJobs": {
"Max": 10000,
"Remaining": 10000
},
"DailyDurableGenericStreamingApiEvents" : {
"Max" : 10000,
"Remaining" : 10000
},
"DailyDurableStreamingApiEvents" : {
"Max" : 10000,
"Remaining" : 10000
},
"DailyGenericStreamingApiEvents" : {
"Max" : 10000,
"Remaining" : 10000
},
"DailyStandardVolumePlatformEvents" : {
"Max" : 10000,
"Remaining" : 10000
},
"DailyStreamingApiEvents" : {
"Max" : 10000,
"Remaining" : 10000
},
"DailyWorkflowEmails" : {
"Max" : 390,
"Remaining" : 390
},
"DataStorageMB" : {
"Max" : 5,
"Remaining" : 5
},
"DurableStreamingApiConcurrentClients" : {
"Max" : 20,
"Remaining" : 20
},
"FileStorageMB" : {
"Max" : 20,
"Remaining" : 20
23
Examples List Organization Limits
},
"HourlyAsyncReportRuns" : {
"Max" : 1200,
"Remaining" : 1200
},
"HourlyDashboardRefreshes" : {
"Max" : 200,
"Remaining" : 200
},
"HourlyDashboardResults" : {
"Max" : 5000,
"Remaining" : 5000
},
"HourlyDashboardStatuses" : {
"Max" : 999999999,
"Remaining" : 999999999
},
"HourlyLongTermIdMapping" : {
"Max" : 100000,
"Remaining" : 100000
},
"HourlyODataCallout" : {
"Remaining" : 9999,
"Max" : 10000
},
"HourlyPublishedPlatformEvents" : {
"Max" : 50000,
"Remaining" : 50000
},
"HourlyPublishedStandardVolumePlatformEvents" : {
"Max" : 1000,
"Remaining" : 1000
},
"HourlyShortTermIdMapping" : {
"Max" : 100000,
"Remaining" : 100000
},
"HourlySyncReportRuns" : {
"Max" : 500,
"Remaining" : 500
},
"HourlyTimeBasedWorkflow" : {
"Max" : 50,
"Remaining" : 50
},
"MassEmail" : {
"Max" : 10,
"Remaining" : 10
},
"MonthlyPlatformEventsUsageEntitlement" : {
"Max" : 300000,
"Remaining" : 300000
},
"SingleEmail" : {
24
Examples List Available REST Resources
"Max" : 15,
"Remaining" : 15
}}
25
Examples Get an Image from a Rich Text Area Field
26
Examples Get a List of Objects If Metadata Has Changed
If changes to an object were made after March 23, 2015, the response body contains metadata for all available objects. For an example,
see Get a List of Objects.
IN THIS SECTION:
Retrieve Metadata for an Object
Use the sObject Basic Information resource to retrieve metadata for an object.
Get Field and Other Metadata for an Object
Use the sObject Describe resource to retrieve all the metadata for an object, including information about each field, URLs, and child
relationships.
Get Object Metadata Changes
Use the sObject Describe resource and the If-Modified-Since HTTP header to determine if object metadata has changed.
27
Examples Get Field and Other Metadata for an Object
curl https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/ -H
"Authorization: Bearer token"
...
"replicateable" : true,
"retrieveable" : true,
"undeletable" : true,
"triggerable" : true
},
"recentItems" :
[
{
"attributes" :
{
"type" : "Account",
"url" : "/services/data/v51.0/sobjects/Account/001D000000INjVeIAL"
},
"Id" : "001D000000INjVeIAL",
"Name" : "asdasdasd"
},
...
]
}
To get a complete description of an object, including field names and their metadata, see Get a List of Objects.
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/describe/ -H
"Authorization: Bearer token"
28
Examples Get Field and Other Metadata for an Object
...
],
"updateable" : true,
"label" : "Account",
"keyPrefix" : "001",
"custom" : false,
...
"urls" :
{
"uiEditTemplate" : "https://yourInstance.salesforce.com/{ID}/e",
"sobject" : "/services/data/v51.0/sobjects/Account",
"uiDetailTemplate" : "https://yourInstance.salesforce.com/{ID}",
...
},
"childRelationships" :
[
{
"field" : "ParentId",
"deprecatedAndHidden" : false,
...
},
....
],
"createable" : true,
"customSetting" : false,
...
}
For more information about the items in the request body, see DescribesObjectResult in the SOAP API Developers Guide.
29
Examples Get Object Metadata Changes
If there were changes to Merchandise__c made after July 3rd, 2013, the response body would contain the metadata for Merchandise__c.
See Get Field and Other Metadata for an Object for an example.
IN THIS SECTION:
Create a Record
Use the sObject Basic Information resource to create new records. You supply the required field values in the request data, and then
use the POST method of the resource. The response body will contain the ID of the created record if the call is successful.
Update a Record
You use the sObject Rows resource to update records. 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.
Delete a Record
Use the sObject Rows resource to delete records. Specify the record ID and use the DELETE method of the resource to delete a record.
Get Field Values from a Standard Object Record
You use the GET method of the sObject Rows resource to retrieve field values from a record.
Get Field Values from an External Object Record by Using the Salesforce ID
You use the sObject Rows resource to retrieve field values from a record. Specify the fields you want to retrieve in the fields
parameter and use the GET method of the resource.
30
Examples Create a Record
Get Field Values from an External Object Record by Using the External ID Standard Field
You use the sObject Rows resource to retrieve field values from a record. Specify the fields you want to retrieve in the fields
parameter and use the GET method of the resource.
Retrieve a Record Using an External ID
You can use the GET method of the sObject Rows by External ID resource to retrieve records with a specific external ID.
Insert or Update (Upsert) a Record Using an External ID
You can use the sObject Rows by External ID resource to create records or update existing records (upsert) based on the value of a
specified external ID field.
Traverse Relationships with Friendly URLs
You can traverse relationship fields in objects by constructing friendly URLs via the sObject Relationship resource. This approach
allows you to directly access records associated with relationships. Using friendly URLs is easier than accessing records by obtaining
object IDs from relationship fields and then inspecting the associated object ID record.
Get Attachment Content from a Record
Use the sObject Blob Retrieve resource to retrieve blob data for a given record.
Get a List of Deleted Records Within a Given Timeframe
Use the sObject Get Deleted resource to get a list of deleted records for the specified object. Specify the date and time range within
which the records for the given object were deleted. Deleted records are written to a delete log (that is periodically purged), and
will be filtered out of most operations, such as sObject Rows or Query (although QueryAll will include deleted records in results).
Get a List of Updated Records Within a Given Timeframe
Use the sObject Get Updated resource to get a list of updated (modified or added) records for the specified object. Specify the date
and time range within which the records for the given object were updated.
Create a Record
Use the sObject Basic Information resource to create new records. You supply the required field values in the request data, and then use
the POST method of the resource. The response body will contain the ID of the created record if the call is successful.
The following example creates a new Account record, with the field values provided in newaccount.json.
Example for creating a new Account
curl https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/ -H
"Authorization: Bearer token -H "Content-Type: application/json" -d "@newaccount.json"
31
Examples Update a Record
Update a Record
You use the sObject Rows resource to update records. 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.
In the following example, the Billing City within an Account is updated. The updated record information is provided in
patchaccount.json.
Example for updating an Account object
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/001D000000INjVe
-H "Authorization: Bearer token" -H "Content-Type: application/json" -d
@patchaccount.json -X PATCH
Example request body patchaccount.json file for updating fields in an Account object
{
"BillingCity" : "San Francisco"
}
32
Examples Delete a Record
If you use an HTTP library that doesn't allow overriding or setting an arbitrary HTTP method name, you can send a POST request and
provide an override to the HTTP method via the query string parameter _HttpMethod. In the PATCH example, you can replace the
PostMethod line with one that doesn't use override:
PostMethod m = new PostMethod(url + "?_HttpMethod=PATCH");
Delete a Record
Use the sObject Rows resource to delete records. Specify the record ID and use the DELETE method of the resource to delete a record.
Example for deleting an Account record
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/001D000000INjVe
-H "Authorization: Bearer token" -X DELETE
33
Examples Get Field Values from an External Object Record by Using the
Salesforce ID
Get Field Values from an External Object Record by Using the Salesforce
ID
You use the sObject Rows resource to retrieve field values from a record. Specify the fields you want to retrieve in the fields parameter
and use the GET method of the resource.
In the following example, the Country__c custom field is retrieved from an external object that’s associated with a
non-high-data-volume external data source.
Example for retrieving values from fields on the Customer external object
/services/data/v51.0/sobjects/Customer__x/x01D0000000002RIAQ?fields=Country__c
Get Field Values from an External Object Record by Using the External ID
Standard Field
You use the sObject Rows resource to retrieve field values from a record. Specify the fields you want to retrieve in the fields parameter
and use the GET method of the resource.
In the following example, the Country__c custom field is retrieved from an external object. Notice that the id (CACTU) isn’t a
Salesforce ID. Instead, it’s the External ID standard field of the external object.
Example for retrieving values from fields on the Customer external object
/services/data/v51.0/sobjects/Customer__x/CACTU?fields=Country__c
34
Examples Retrieve a Record Using an External ID
35
Examples Insert or Update (Upsert) a Record Using an External ID
Note: The created parameter is present in the response in API version 46.0 and later. It doesn't appear in earlier versions.
Error responses
Incorrect external ID field:
{
"message" : "The requested resource does not exist",
"errorCode" : "NOT_FOUND"
}
For more information, see Status Codes and Error Responses on page 313.
curl https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/Id -H
"Authorization: Bearer token" -H "Content-Type: application/json" -d @newrecord.json
-X POST
36
Examples Insert or Update (Upsert) a Record Using an External ID
Note: The created parameter is present in the response in API version 46.0 and later. It doesn't appear in earlier versions.
In API version 45.0 and earlier, the HTTP status code is 204 (No Content) and there is no response body.
Error responses
If the external ID value isn't unique, an HTTP status code 300 is returned, plus a list of the records that matched the query. For more
information about errors, see Status Codes and Error Responses on page 313.
If the external ID field doesn't exist, an error message and code is returned:
{
"message" : "The requested resource does not exist",
"errorCode" : "NOT_FOUND"
}
37
Examples Insert or Update (Upsert) a Record Using an External ID
Note: The created parameter is present in the response in API version 46.0 and later. It doesn't appear in earlier versions.
Error responses
If the external ID value isn't unique, an HTTP status code 300 is returned, plus a list of the records that matched the query. For more
information about errors, see Status Codes and Error Responses on page 313.
If the external ID field doesn't exist, an error message and code is returned:
{
"message" : "The requested resource does not exist",
"errorCode" : "NOT_FOUND"
}
38
Examples Traverse Relationships with Friendly URLs
You can also use this approach to update existing records. For example, if you created the Line_Item__c shown in the example above,
you can try to update the related Merchandise__c using another request.
Example for updating a record
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Line_Item__c/LineItemExtID__c/456
-H "Authorization: Bearer token" -H "Content-Type: application/json" -d @updates.json
-X PATCH
In API version 45.0 and earlier, the HTTP status code is 204 (No Content) and there is no response body.
If the relationship type is master-detail and the relationship is set to not allow reparenting, and you try to update the parent external ID,
you get an HTTP status code 400 error with an error code of INVALID_FIELD_FOR_INSERT_UPDATE.
https://instance name.salesforce.com/services/data/v51.0/sobjects/ChildOfChild__c/record
id/Child__r/ParentOfChild__r
39
Examples Traverse Relationships with Friendly URLs
• When specifying parent-to-child relationships, no more than one level can be traversed. The following traverses one parent-to-child
relationship.
https://instance name.salesforce.com/services/data/v51.0/sobjects/ParentOfChild__c/record
id/Child__r
If no related record is associated with the relationship name, the REST API call fails, because the relationship can’t be traversed. Using
the previous example, if the Distributor__c field in the Merchandise__c record was set to null, the GET call would return a 404 error
response.
You can traverse multiple relationships within the same relationship hierarchy in a single REST API call as long as you don’t exceed the
relationship query limits. If a Line_Item__c custom object is the child in a relationship to a Merchandise__c custom object, and
Merchandise__c also has a child Distributor__c custom object, you can access the Distributor__c record starting from the Line_Item__c
record using something like the following.
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Line_Item__c/a02D0000006YL7XIAW/Merchandise__r/Distributor__r
-H "Authorization: Bearer token"
Relationship traversal also supports PATCH and DELETE methods for relationships that resolve to a single record. Using the PATCH
method, you can update the related record.
40
Examples Traverse Relationships with Friendly URLs
Example JSON request body for updating a relationship record contained in update_info.json
{
"Location__c" : "New York"
}
41
Examples Traverse Relationships with Friendly URLs
"url" : "/services/data/v51.0/sobjects/Line_Item__c/a02D0000006YL7XIAW"
},
"Id" : "a02D0000006YL7XIAW",
"IsDeleted" : false,
"Name" : "LineItem1",
"CreatedDate" : "2011-12-16T17:44:07.000+0000",
"CreatedById" : "005D0000001KyEIIA0",
"LastModifiedDate" : "2011-12-16T17:44:07.000+0000",
"LastModifiedById" : "005D0000001KyEIIA0",
"SystemModstamp" : "2011-12-16T17:44:07.000+0000",
"Unit_Price__c" : 9.75,
"Units_Sold__c" : 10.0,
"Merchandise__c" : "a00D0000008oLnXIAU",
"Invoice_Statement__c" : "a01D000000D85hkIAB"
},
{
"attributes" :
{
"type" : "Line_Item__c",
"url" : "/services/data/v51.0/sobjects/Line_Item__c/a02D0000006YL7YIAW"
},
"Id" : "a02D0000006YL7YIAW",
"IsDeleted" : false,
"Name" : "LineItem2",
"CreatedDate" : "2011-12-16T18:53:59.000+0000",
"CreatedById" : "005D0000001KyEIIA0",
"LastModifiedDate" : "2011-12-16T18:53:59.000+0000",
"LastModifiedById" : "005D0000001KyEIIA0",
"SystemModstamp" : "2011-12-16T18:54:00.000+0000",
"Unit_Price__c" : 8.5,
"Units_Sold__c" : 8.0,
"Merchandise__c" : "a00D0000008oLnXIAU",
"Invoice_Statement__c" : "a01D000000D85hkIAB"
}
]
}
The serialized structure for the result data is the same format as result data from executing a SOQL query via REST API. See Query on
page 208 for more details on executing SOQL queries via REST API
If no related records are associated with the relationship name, the REST API call returns a 200 response with no record data in the
response body. This result is in contrast to the results when traversing an empty relationship to a single record, which returns a 404 error
response. This behavior is because the single record case resolves to a REST resource that can be used with PATCH or DELETE methods.
In contrast, the multiple record case can only be queried.
If an initial GET request for a relationship with multiple records returns only part of the results, the end of the response contains the field
nextRecordsUrl. For example, you could get a field like the following at the end of your response.
"nextRecordsUrl" : "/services/data/v51.0/query/01gD0000002HU6KIAW-2000"
You can request the next batch of records using the provided URL with your instance and session information, and repeat until all records
have been retrieved. These requests use nextRecordsUrl and don’t include any parameters. The final batch of records doesn’t
have a nextRecordsUrl field.
42
Examples Traverse Relationships with Friendly URLs
Similarly, for requests that result in multiple records, you can use a list of fields to specify the fields returned in the record set. For example,
assume you have a relationship that was associated with two Line_Item__c records. You want just the Name and Units_Sold__c fields
from those records. You could use the following call.
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Merchandise__c/a01D000000INjVe/Distributor__r?fields=Name,Units_Sold__c
-H "Authorization: Bearer token"
43
Examples Get Attachment Content from a Record
"type" : "Line_Item__c",
"url" : "/services/data/v51.0/sobjects/Line_Item__c/a02D0000006YL7XIAW"
},
"Name" : "LineItem1",
"Units_Sold__c" : 10.0
},
{
"attributes" :
{
"type" : "Line_Item__c",
"url" : "/services/data/v51.0/sobjects/Line_Item__c/a02D0000006YL7YIAW"
},
"Name" : "LineItem2",
"Units_Sold__c" : 8.0
}
]
}
If any field listed in the fields parameter set isn’t visible to the active user, the REST API call fails. In the previous example, if the Units_Sold_c
field was hidden from the active user by field-level security, the call would return a 400 error response.
44
Examples Get a List of Deleted Records Within a Given Timeframe
45
Examples Delete Lightning Experience Event Series
[
"a00D0000008pQR5IAM",
"a00D0000008pQRGIA2",
"a00D0000008pQRFIA2"
],
"latestDateCovered" : "2013-05-08T21:20:00.000+0000"
}
curlhttps://yourInstance.salesforce.com/services/data/v51.0/sobjects/Event/00Uxx0000000000/fromThisEventOnwards
-H
Example response body after successfully deleting events from the series
{
success: We’re deleting the selected events from the series. Wait for all events to be
removed.
}
46
Examples Working with Searches and Queries
curlhttps://yourInstance.salesforce.com/services/data/v51.0/sobjects/Event/00Uxx0000000000/fromThisEventOnwards
-H "Authorization: Bearer token -X DELETE
Example response body after successfully deleting events from the series
{
success: We’re deleting the selected events from the series. Wait for all events to be
removed.
}
Considerations
Delete from an Event Onwards does not support calls from events that:
• Occurred before the original value of Recurrence2PatternStartDate.
• Are defined as child events.
If the event series originated outside of Salesforce and the event ID of the first occurrence is unavailable, you can’t delete all events in a
series. Instead, delete events from a specific occurrence onwards.
IN THIS SECTION:
Execute a SOQL Query
Use the Query resource to execute a SOQL query that returns all the results in a single response, or if needed, returns part of the
results and an identifier used to retrieve the remaining results.
Execute a SOQL Query that Includes Deleted Items
Use the QueryAll resource to execute a SOQL query that includes information about records that have been deleted because of a
merge or delete. Use QueryAll rather than Query, because the Query resource will automatically filter out items that have been
deleted.
47
Examples Execute a SOQL Query
48
Examples Execute a SOQL Query that Includes Deleted Items
"url" : "/services/data/v51.0/sobjects/Account/001D000000IomazIAB"
},
"Name" : "Test 2"
},
...
]
}
In such cases, request the next batch of records and repeat until all records have been retrieved. These requests use nextRecordsUrl,
and do not include any parameters.
Example usage for retrieving the remaining query results
curl
https://yourInstance.salesforce.com/services/data/v51.0/query/01gD0000002HU6KIAW-2000
-H "Authorization: Bearer token"
49
Examples Get Feedback on Query Performance
},
"Name" : "Merchandise 1"
},
]
}
In such cases, request the next batch of records and repeat until all records have been retrieved. These requests use nextRecordsUrl,
and do not include any parameters.
Though the nextRecordsUrl has query in the URL, it still provides remaining results from the initial QueryAll request. The
remaining results include deleted records that matched the initial query.
Example usage for retrieving the remaining results
/services/data/v51.0/query/01gD0000002HU6KIAW-2000
50
Examples Get Feedback on Query Performance
Note: Using explain with the Query resource is a beta feature. There’s no support for this beta feature. For more information,
contact Salesforce.
The response contains one or more query execution plans, sorted from most optimal to least optimal. The most optimal plan is the plan
that’s used when the query, report, or list view is executed.
For more details on the fields returned when using explain, see the explain parameter in Query Options Headers. For more
information on making queries more selective, see Working with Very Large SOQL Queries in the Apex Developer Guide.
The response body for a performance feedback query looks like this:
{
"plans" : [ {
"cardinality" : 1,
"fields" : [ "CreatedDate" ],
"leadingOperationType" : "Index",
"notes" : [ {
"description" : "Not considering filter for optimization because unindexed",
"fields" : [ "IsDeleted" ],
"tableEnumOrId" : "Merchandise__c"
} ],
"relativeCost" : 0.0,
"sobjectCardinality" : 3,
"sobjectType" : "Merchandise__c"
}, {
"cardinality" : 1,
"fields" : [ ],
"leadingOperationType" : "TableScan",
"notes" : [ {
"description" : "Not considering filter for optimization because unindexed",
"fields" : [ "IsDeleted" ],
"tableEnumOrId" : "Merchandise__c"
} ],
"relativeCost" : 0.65,
"sobjectCardinality" : 3,
"sobjectType" : "Merchandise__c"
} ]
}
This response indicates that Salesforce found two possible execution plans for this query. The first plan uses the CreatedDate index field
to improve the performance of this query. The second plan scans all records without using an index. If the query is executed, the first
plan is used. Both plans note that there’s no secondary optimization for filtering out records marked as deleted because the IsDeleted
field isn’t indexed.
51
Examples Search for a String
curl https://yourInstance.salesforce.com/services/data/v51.0/search/?q=FIND+%7BAcme%7D
-H "Authorization: Bearer token"
curl https://yourInstance.salesforce.com/services/data/v51.0/parameterizedSearch/?q=Acme
Account search for results containing Acme, returning the id and name fields
curl
https://yourInstance.salesforce.com/services/data/v51.0/parameterizedSearch/?q=Acme&sobject=Account&Account.fields=id,name&Account.limit=10
52
Examples Search for a String
"attributes" : {
"type" : "Account",
"url" : "/services/data/v51.0/sobjects/Account/001D000000IqhSLIAZ"
},
"Id" : "001D000000IqhSLIAZ"
}, {
"attributes" : {
"type" : "Account",
"url" : "/services/data/v51.0/sobjects/Account/001D000000IomazIAB"
},
"Id" : "001D000000IomazIAB"
} ]
}
Note: The metadata parameter is only returned if the request specified metadata=LABELS.
{
"searchRecords" : [ {
"attributes" : {
"type" : "Account",
"url" : "/services/data/v51.0/sobjects/Account/001D000000IqhSLIAZ"
},
"Id" : "001D000000IqhSLIAZ",
}, {
"attributes" : {
"type" : "Account",
"url" : "/services/data/v51.0/sobjects/Account/001D000000IomazIAB"
},
"Id" : "001D000000IomazIAB",
} ],
"metadata" : {
"entityetadata" : [ {
"entityName" : "Account",
"fieldMetadata" : [ {
"name" : "Name",
"label" : "Account Name"
} ]
} ]
}
}
curl https://yourInstance.salesforce.com/services/data/v51.0/parameterizedSearch
"Authorization: Bearer token-H "Content-Type: application/json” -d "@search.json”
53
Examples Get the Default Search Scope and Order
{
"q":"Smith",
"fields" : ["id", "firstName", "lastName"],
"sobjects":[{"fields":["id", "NumberOfEmployees"],
"name": "Account",
"limit":20},
{"name": "Contact"}],
"in":"ALL",
"overallLimit":100,
"defaultLimit":10
}
curl https://yourInstance.salesforce.com/services/data/v51.0/search/scopeOrder -H
"Authorization: Bearer token"
54
Examples Get Search Result Layouts for Objects
"type":"Site",
"url":"/services/data/v51.0/sobjects/Site/describe"
},
{
"type":"Idea",
"url":"/services/data/v51.0/sobjects/Idea/describe"
},
{
"type":"Case",
"url":"/services/data/v51.0/sobjects/Case/describe"
},
{
"type":"Opportunity",
"url":"/services/data/v51.0/sobjects/Opportunity/describe"
},
{
"type":"Account",
"url":"/services/data/v51.0/sobjects/Account/describe"
},
{
"type":"User",
"url":"/services/data/v51.0/sobjects/User/describe"
}
]
55
Examples Get Search Result Layouts for Objects
"name" : "Phone"
},
{ "field" : "User.Alias",
"format" : null,
"label" : "Account Owner Alias",
"name" : "Owner.Alias"
}
]
},
{ "label" : "Search Results",
"limitRows" : 25,
"searchColumns" : [ { "field" : "Contact.Name",
"format" : null,
"label" : "Name",
"name" : "Name"
},
{ "field" : "Account.Name",
"format" : null,
"label" : "Account Name",
"name" : "Account.Name"
},
{ "field" : "Account.Site",
"format" : null,
"label" : "Account Site",
"name" : "Account.Site"
},
{ "field" : "Contact.Phone",
"format" : null,
"label" : "Phone",
"name" : "Phone"
},
{ "field" : "Contact.Email",
"format" : null,
"label" : "Email",
"name" : "Email"
},
{ "field" : "User.Alias",
"format" : null,
"label" : "Contact Owner Alias",
"name" : "Owner.Alias"
}
]
},
{ "label" : "Search Results",
"limitRows" : 25,
"searchColumns" : [ { "field" : "Lead.Name",
"format" : null,
"label" : "Name",
"name" : "Name"
},
{ "field" : "Lead.Title",
"format" : null,
"label" : "Title",
"name" : "Title"
56
Examples View Relevant Items
},
{ "field" : "Lead.Phone",
"format" : null,
"label" : "Phone",
"name" : "Phone"
},
{ "field" : "Lead.Company",
"format" : null,
"label" : "Company",
"name" : "Company"
},
{ "field" : "Lead.Email",
"format" : null,
"label" : "Email",
"name" : "Email"
},
{ "field" : "Lead.Status",
"format" : null,
"label" : "Lead Status",
"name" : "toLabel(Status)"
},
{ "field" : "Name.Alias",
"format" : null,
"label" : "Owner Alias",
"name" : "Owner.Alias"
}
]
},
]
57
Examples View Relevant Items
"key" : "005",
"label" : "Users",
"lastUpdatedId" : "-199920321",
"recordIds" : [ "005xx000001Svqw", "005xx000001SvwK", "005xx000001SvwA" ]
}, { "apiName" : "Case",
"key" : "069",
"label" : "Cases",
"lastUpdatedId" : "1033471693",
"recordIds" : [ "069xx0000000006", "069xx0000000001", "069xx0000000002" ]
} ]
Example usage for comparing the user’s current list of relevant records to a previous version
/v51.0/sobjects/relevantItems?lastUpdatedId=102959935
Example request body
None required
Example response header
lastUpdatedId: 102959935
newResultSetSinceLastQuery: true
58
Examples Insert or Update Blob Data
"recordIds" : [ "001xx000003DWsT" ]
}, {
"apiName" : "Case",
"key" : "005",
"label" : "Cases",
"lastUpdatedId" : "1740766611",
"recordIds" : [ "005xx000001Svqw", "005xx000001SvwA" ]
} ]
Example usage for comparing the user’s current list of relevant records to a previous version for a particular object
/v51.0/sobjects/relevantItems?mode=MRU&sobjects=Account,Contact&Account.lastUpdatedId=102959935
Example request body
None required
Example response body
[ {
"apiName" : "Account",
"key" : "001",
"label" : "Accounts",
"lastUpdatedId" : "193640553",
"recordIds" : [ "001xx000003DWsT" ]
} ]
Note: You can insert or update blob data using a non-multipart message, but you are limited to 50 MB of text data or 37.5 MB
of base64–encoded data.
The first part of the request message body contains non-binary field data, such as the Description or Name. The second part of the
message contains the binary data of the file that you’re uploading.
The following sections provide JSON examples of how to insert or update blob data using a multipart content-type.
• Inserting a New Document
• Updating a Document
• Inserting a ContentVersion
• Using sObject Collections to Insert a Collection of Blob Records
• Multipart Message Considerations
59
Examples Insert or Update Blob Data
Tip: After you add a new Document, you can view the results of your changes on the Documents tab.
curl https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Document/ -H
"Authorization: Bearer token" -H "Content-Type: multipart/form-data;
boundary=\"boundary_string\"" --data-binary @newdocument.json
{
"Description" : "Marketing brochure for Q1 2011",
"Keywords" : "marketing,sales,update",
"FolderId" : "005D0000001GiU7",
"Name" : "Marketing Brochure Q1",
"Type" : "pdf"
}
--boundary_string
Content-Type: application/pdf
Content-Disposition: form-data; name="Body"; filename="2011Q1MktgBrochure.pdf"
--boundary_string--
Updating a Document
This syntax and code updates an existing Document. In addition to the binary data of the file itself, this code also updates other field
data, such as the Name and Keywords.
60
Examples Insert or Update Blob Data
curl https://yourInstance.salesforce.com/services/data/v51.0/Document/015D0000000N3ZZIA0
-H "Authorization: Bearer token" -H "Content-Type: multipart/form-data;
boundary=\"boundary_string\"" --data-binary @UpdateDocument.json -X PATCH
{
"Name" : "Marketing Brochure Q1 - Sales",
"Keywords" : "sales, marketing, first quarter"
}
--boundary_string
Content-Type: application/pdf
Content-Disposition: form-data; name="Body"; filename="2011Q1MktgBrochure.pdf"
--boundary_string--
Inserting a ContentVersion
This syntax and code inserts a new ContentVersion. In addition to the binary data of the file itself, this code also updates other fields,
such as the ReasonForChange and PathOnClient. This message contains the ContentDocumentId because a ContentVersion is always
associated with a ContentDocument.
Tip: The ContentVersion object doesn’t support updates. Therefore, you cannot update a ContentVersion. You can only insert a
new ContentVersion. You can see the results of your changes on the Content tab.
Example usage for inserting a ContentVersion
curl https://yourInstance.salesforce.com/services/data/v51.0/sobjects/ContentVersion
-H "Authorization: Bearer token" -H "Content-Type: multipart/form-data;
boundary=\"boundary_string\"" --data-binary @NewContentVersion.json
61
Examples Insert or Update Blob Data
Content-Type: application/json
{
"ContentDocumentId" : "069D00000000so2",
"ReasonForChange" : "Marketing materials updated",
"PathOnClient" : "Q1 Sales Brochure.pdf"
}
--boundary_string
Content-Type: application/octet-stream
Content-Disposition: form-data; name="VersionData"; filename="Q1 Sales Brochure.pdf"
--boundary_string--
Tip: After you add new Documents, you can view the results of your changes on the Documents tab.
Attributes
If you’re using sObject Collections with blob data, you must specify certain attribute values in addition to type in the request
body’s attributes map.
Parameter Description
binaryPartName Required for blob data. A unique identifier for the binary part.
binaryPartNameAlias Required for blob data. The name of the field in which the binary data is inserted or
updated.
curl https://yourInstance.salesforce.com/services/data/v51.0/composite/sobjects/ -H
"Authorization: Bearer token" -H "Content-Type: multipart/form-data;
boundary=\"boundary_string\"" --data-binary @newdocuments.json
62
Examples Insert or Update Blob Data
{
"allOrNone" : false,
"records" :
[
{
"attributes" :
{
"type" : "Document",
"binaryPartName": "binaryPart1",
"binaryPartNameAlias": "Body"
},
"Description" : "Marketing Brochure",
"FolderId" : "005xx000001Svs4AAC",
"Name" : "Brochure",
"Type" : "pdf"
},
{
"attributes" :
{
"type" : "Document",
"binaryPartName": "binaryPart2",
"binaryPartNameAlias": "Body"
},
"Description" : "Pricing Overview",
"FolderId" : "005xx000001Svs4AAC",
"Name" : "Pricing",
"Type" : "pdf"
}
]
}
--boundary_string
Content-Disposition: form-data; name="binaryPart1"; filename="Brochure.pdf"
Content-Type: application/pdf
--boundary_string
Content-Disposition: form-data; name="binaryPart2"; filename="Pricing.pdf"
Content-Type: application/pdf
--boundary_string--
63
Examples Insert or Update Blob Data
• The binary part of the message must have a filename attribute that represents the name of the local file.
Content-Type Header
• Required in each message part.
• The content types supported by the non-binary message part are application/json and application/xml.
• The Content-Type header for the binary part of the message can be any value.
64
Examples Working with Recently Viewed Information
New Line
A new line must be between the message part header and the data of the part. As shown in the code examples, a new line must
be between the Content-Type and Content-Disposition headers and the JSON or XML. In the binary part, a new line
must be between the Content-Type and Content-Disposition headers and the binary data.
IN THIS SECTION:
View Recently Viewed Records
Use the Recently Viewed Items resource to get a list of recently viewed records.
Mark Records as Recently Viewed
To mark a record as recently viewed using REST API, use the Query resource with a FOR VIEW or FOR REFERENCE clause. Use
SOQL to mark records as recently viewed to ensure that information such as the date and time the record was viewed is correctly
set.
65
Examples Mark Records as Recently Viewed
]
}
IN THIS SECTION:
Manage User Passwords
Use the sObject User Password resource to set, reset, or get information about a user password. Use the HTTP GET method to get
password expiration status, the HTTP POST method to set the password, and the HTTP DELETE method to reset the password.
66
Examples Manage User Passwords
These methods are available for both users and self-service users. For managing self-service user passwords, use SelfServiceUser
instead of User in the REST API URL.
Here is an example of retrieving the current password expiration status for a user:
Example usage for getting current password expiration status
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/User/005D0000001KyEIIA0/password
-H "Authorization: Bearer token"
XML example response body for getting current password expiration status
<Password>
<isExpired>false</isExpired>
</Password>
67
Examples Working with Approval Processes and Process Rules
IN THIS SECTION:
Get a List of All Approval Processes
Use the Process Approvals resource to get information about approvals.
Submit a Record for Approval
Use the Process Approvals resource to submit a record or a collection of records for approval. Each call takes an array of requests.
Approve a Record
Use the Process Approvals resource to approve a record or a collection of records. Each call takes an array of requests. The current
user must be an assigned approver.
Reject a Record
Use the Process Approvals resource to reject a record or a collection of records. Each call takes an array of requests. The current user
must be an assigned approver.
Bulk Approvals
Use the Process Approvals resource to do bulk approvals. You can specify a collection of different Process Approvals requests to have
them all executed in bulk.
Get a List of Process Rules
Use the Process Rules resource to get information about process rules.
Get a Particular Process Rule
Use the Process Rules resource and specify thesObjectName and workflowRuleId of the rule you want to get the metadata
for.
Trigger Process Rules
Use the Process Rules resource to trigger process rules. All rules associated with the specified ID will be evaluated, regardless of the
evaluation criteria. All IDs must be for records on the same object.
68
Examples Get a List of All Approval Processes
curl https://yourInstance.salesforce.com/services/data/v51.0/process/approvals/ -H
"Authorization: Bearer token"
curl https://yourInstance.salesforce.com/services/data/v51.0/process/approvals/ -H
"Authorization: Bearer token" -H "Content-Type: application/json" -d @submit.json"
[ {
"actorIds" : [ "005D00000015rY9IAI" ],
"entityId" : "001D000000I8mImIAJ",
69
Examples Approve a Record
"errors" : null,
"instanceId" : "04gD0000000Cvm5IAC",
"instanceStatus" : "Pending",
"newWorkitemIds" : [ "04iD0000000Cw6SIAS" ],
"success" : true } ]
Approve a Record
Use the Process Approvals resource to approve a record or a collection of records. Each call takes an array of requests. The current user
must be an assigned approver.
Example usage
curl https://yourInstance.salesforce.com/services/data/v51.0process/approvals/ -H
"Authorization: Bearer token" -H "Content-Type: application/json" -d @approve.json"
[ {
"actorIds" : null,
"entityId" : "001D000000I8mImIAJ",
"errors" : null,
"instanceId" : "04gD0000000CvmAIAS",
"instanceStatus" : "Approved",
"newWorkitemIds" : [ ],
"success" : true
} ]
Reject a Record
Use the Process Approvals resource to reject a record or a collection of records. Each call takes an array of requests. The current user
must be an assigned approver.
Example usage
curl https://yourInstance.salesforce.com/services/data/v51.0/process/approvals/ -H
"Authorization: Bearer token" -H "Content-Type: application/json" -d @reject.json"
70
Examples Bulk Approvals
[ {
"actorIds" : null,
"entityId" : "001D000000I8mImIAJ",
"errors" : null,
"instanceId" : "04gD0000000CvmFIAS",
"instanceStatus" : "Rejected",
"newWorkitemIds" : [ ],
"success" : true
} ]
Bulk Approvals
Use the Process Approvals resource to do bulk approvals. You can specify a collection of different Process Approvals requests to have
them all executed in bulk.
Example usage
curl https://yourInstance.salesforce.com/services/data/v51.0/process/approvals/ -H
"Authorization: Bearer token" -H "Content-Type: application/json" -d @bulk.json"
[ {
"actorIds" : null,
"entityId" : "001D000000I8mImIAJ",
"errors" : null,
"instanceId" : "04gD0000000CvmZIAS",
"instanceStatus" : "Approved",
71
Examples Get a List of Process Rules
"newWorkitemIds" : [ ],
"success" : true
}, {
"actorIds" : null,
"entityId" : "003D000000QBZ08IAH",
"errors" : null,
"instanceId" : "04gD0000000CvmeIAC",
"instanceStatus" : "Approved",
"newWorkitemIds" : [ ],
"success" : true
}, {
"actorIds" : [ "005D00000015rY9IAI" ],
"entityId" : "001D000000JRWBdIAP",
"errors" : null,
"instanceId" : "04gD0000000CvmfIAC",
"instanceStatus" : "Pending",
"newWorkitemIds" : [ "04iD0000000Cw6wIAC" ],
"success" : true
} ]
curl https://yourInstance.salesforce.com/services/data/v51.0/process/rules/ -H
"Authorization: Bearer token"
{
"rules" : {
"Account" : [ {
"actions" : [ {
"id" : "01VD0000000D2w7",
"name" : "ApprovalProcessTask",
"type" : "Task"
} ],
"description" : null,
"id" : "01QD0000000APli",
"name" : "My Rule",
"namespacePrefix" : null,
"object" : "Account"
} ]
}
}
72
Examples Get a Particular Process Rule
{
"actions" : [ {
"id" : "01VD0000000D2w7",
"name" : "ApprovalProcessTask",
"type" : "Task"
} ],
"description" : null,
"id" : "01QD0000000APli",
"name" : "My Rule",
"namespacePrefix" : null,
"object" : "Account"
}
curl https://yourInstance.salesforce.com/services/data/v51.0/process/rules/ -H
"Authorization: Bearer token" -H "Content-Type: application/json" -d @rules.json"
{
"errors" : null,
"success" : true
}
73
Examples Using Event Monitoring
Note: For the supported event types that you can use with event monitoring, see Object Reference for Salesforce and Lightning
Platform: EventLogFile Object.
When using event monitoring, keep the following in mind.
• In the unlikely case in which no log files are generated for 24 hours, contact Salesforce Customer Support.
• Log data is read only. You can’t insert, update, or delete log data.
• Use the EventType field to determine which files were generated for your org.
• An event generates log data in real time. However, daily log files are generated during nonpeak hours the day after an event takes
place. Therefore, daily log file data is unavailable for at least one day after an event. For hourly log files, depending on event delivery
and final processing time, an event is expected to take three to six hours from the time of the event to be available in the log file.
However, it can take longer.
• Log files are generated only when at least one event of a type (represented by the EventType field) occurs for the day or hour.
If no events took place, the file isn’t generated.
• Log files are available for 30 days after their CreatedDatein orgs with Event Monitoring licenses, after which they are automatically
deleted. In all Developer Edition orgs, log files are available for one day.
• All event monitoring logs are exposed to the API through the EventLogFile object. However, there is no access through the user
interface, except through the Event Monitoring Analytics app.
• Log files don’t count towards your org’s data or file storage allocations.
• Event Monitoring log files aren’t a system of record for user activity. They are a source of truth, but aren’t durable. During Salesforce
site switches, instance refreshes, or unplanned system outages, data loss can occur. For example, if Salesforce moves your production
org instance, your event log files might have a gap in data. Salesforce makes commercially reasonable efforts to preserve event log
file data integrity and avoid data loss. When Salesforce performs a site switch or instance refresh, it uses an automated process to
replicate event logs.
• Hourly event log files are provided for you to review events in your orgs on an accelerated basis. However, it’s possible that you don’t
get all event log data in hourly event log files, especially during site switches, instance refreshes, or unplanned system outages. For
complete data, use the daily log files.
• If event transmission failures take too long to recover from, log files are retransmitted to ensure that they are delivered at least once.
As a result, latent log files can sometimes contain duplicate event data. When your application consumes latent log files, make sure
that your application handles duplicate event delivery.
• We recommend that you always query the EventLogFile object for new log files to ensure that you also include latent ones. Use the
EventLogFile CreatedDate field to identify newly created log files. Hourly and daily incremental logs are delivered differently.
See Differences Between Hourly and 24-Hour Event Logs for details.
All queries and examples in this section require the View Event Log Files and API Enabled user permissions. Users with the View All Data
permission can also view event monitoring data.
IN THIS SECTION:
Describe Event Monitoring Using REST
Use the sObject Describe resource to retrieve all metadata for an object, including information about fields, URLs, and child relationships.
74
Examples Describe Event Monitoring Using REST
75
Examples Query Event Monitoring Data with REST
"LogDate" : "2014-03-14T00:00:00.000+0000",
"LogFileLength" : 2692.0
}, {
"attributes" : {
"type" : "EventLogFile",
"url" : "/services/data/v51.0/sobjects/EventLogFile/0ATD000000001SdOAI" },
"Id" : "0ATD000000001SdOAI",
"EventType" : "API",
"LogFile" :
"/services/data/v51.0/sobjects/EventLogFile/0ATD000000001SdOAI/LogFile",
"LogDate" : "2014-03-13T00:00:00.000+0000",
"LogFileLength" : 1345.0
}, {
"attributes" : {
"type" : "EventLogFile",
"url" : "/services/data/v51.0/sobjects/EventLogFile/0ATD000000003p1OAA" },
"Id" : "0ATD000000003p1OAA",
"EventType" : "API",
"LogFile" :
"/services/data/v51.0/sobjects/EventLogFile/0ATD000000003p1OAA/LogFile",
"LogDate" : "2014-06-21T00:00:00.000+0000",
"LogFileLength" : 605.0 },
{ "attributes" : {
"type" : "EventLogFile",
"url" : "/services/data/v51.0/sobjects/EventLogFile/0ATD0000000055eOAA" },
"Id" : "0ATD0000000055eOAA",
"EventType" : "API",
"LogFile" :
"/services/data/v51.0/sobjects/EventLogFile/0ATD0000000055eOAA/LogFile",
"LogDate" : "2014-07-03T00:00:00.000+0000",
76
Examples Get Event Monitoring Content from a Record
"LogFileLength" : 605.0
} ]
}
We recommend using compression when downloading large event log files. See Using Compression.
77
Examples Delete Event Monitoring Data
Note: You can’t delete individual rows from event logs. Because event logs are stored in blob format in the database, you must
delete the entire log file that contains the user activity.
1. In Setup, in the Quick Find box, enter Event, and then select Event Monitoring Settings.
2. Enable deletion of event monitoring data. This action is recorded in Setup Audit Trail.
The Delete Event Monitoring Records user permission is now available to assign to a permission set. (Alternatively, you can assign
the user permission to a custom profile.)
3. In Setup, in the Quick Find box, enter Permission, and then select Permission Sets.
4. Create a permission set that includes the Delete Event Monitoring Records user permission, and save the permission set.
5. In Setup, in the Quick Find box, enter users, and then select Users.
6. Select the user you want to grant permission to delete event monitoring data.
7. In the Permission Set Assignment section for this user, assign the permission set, and click Save. This action is recorded in Setup
Audit Trail.
Users assigned this permission set (or any custom profile that includes the Delete Event Monitoring Records user permission) can
now delete event monitoring data. The next steps show you how to use the API to delete the data.
8. To locate the logs containing the user activity that you want to delete, query the EventLogFile object. For details, see Query Event
Monitoring Data with REST on page 76.
9. Note the IDs of the returned logs.
10. Use the sObject Rows resource to delete records. Specify the record ID, and use the DELETE method. For more information, see
Delete a Record on page 33. Or, you can use Workbench to delete blob format data for event monitoring. In the Execute text box,
use a DELETE request similar to /services/data/v51.0/sobjects/EventLogFile/0ATD000000000pyOAA.
78
Examples Query or View Hourly Event Log Files
• Depending on event delivery and final processing time, an event is expected to take three to
six hours from the time of the event to be available in the log file. However, it can take longer.
• When delays in processing occur and event logs for a particular hour arrive later, a new log file is created for the event/date/hour
and lists only the new events. Use the creation date and an incremental sequence number to identify a new log file. Always use the
most recently processed event log file for a particular date. However, if event log files have already been pulled into a third-party
application, they could require deduplication in that application.
If both hourly and daily logs are enabled, daily logs always have a sequence number of 0 because there is only one file per daily
interval. CreatedDate indicates when the file was generated. If CreatedDate is after the last event log file download, there are new
events to be processed.
For best practices, use CreatedDate in the WHERE clause to select logs created after the last downloaded event log file. For example,
if the last downloaded file was at 12PM 2/1/2018, to find the next log file, use +CreatedDate+>+"2018-02-01T12:00:00Z" in the
WHERE clause.
• Your event log files may show a gap in data during site switches, instance refreshes, or unplanned system outages. However, during
site switches and instance refreshes, Salesforce makes a commercially reasonable effort to avoid such data loss by using an automated
process to replicate event logs.
• In the unlikely case in which no log files are generated for 24 hours, contact Salesforce Support.
IN THIS SECTION:
Query Hourly Event Log Files
You query hourly event log files in the same way you query 24-hour log files.
Differences Between Hourly and 24-Hour Event Logs
You receive event log files approximately every hour in addition to 24-hour log files. Review the differences between the two logs
so that you can filter your files to analyze the event data you want.
79
Examples Query or View Hourly Event Log Files
Suppose you’re an administrator. Your Chief Security Officer asks you to identify who modified specific accounts and opportunities in
the past two hours. You query the hourly URI event log files using the EventLogFile object to review the page requests and request
status. Because EventLogFile also returns 24-hour log files, use this SOQL syntax to filter out the 24-hour log files.
1. In Workbench, select utilities > REST Explorer.
2. Replace the existing text with:/services/data/v API_version
.0/query?q=SELECT+Id+,+EventType+,+Interval+,+LogDate+,+LogFile+
3. Append the following to the query to make it complete:
FROM+EventLogFile+WHERE+EventType+=+'URI'+AND+Interval+=+'Hourly'
In the query, Interval=Hourly makes sure that only hourly event log file data is returned. Alternatively, you can use Sequence
to filter out 24-hour event log files (Sequence!=0). To get both hourly and 24-hour files, use Sequence>=0.
4. Click Execute.
If your sandbox org has URI events, you see log file records in your query results. You can also download the event log files to review the
data in a CSV file. For more information, see Trailhead: Download and Visualize Event Log Files.
Available in the API. You can manually import data into third-party Available in the API and integrated with the Event Monitoring
visualization apps. Analytics app and third-party visualization apps.
Key values in the EventLogFile object are: Key values in the EventLogFile object are:
• Interval—Hourly • Interval—Daily
• CreatedDate—Timestamp of when the log file was • CreatedDate—Timestamp of when the log file was
created. Use this field to identify new files. created. Use this field to identify new files.
• LogDate—Timestamp that marks the beginning of the • LogDate—Timestamp that marks the beginning of the
interval when the events occurred. For example, for events interval when the events occurred. For example, for events
that occurred between 11:00 AM and 12:00 PM on 3/7/2016, that occurred on 3/7/2016, this field’s value is
this field’s value is 2016-03-07T11:00:00.000Z. 2016-03-07T00:00:00.000+0000.
• Sequence—1+. This value increases by 1 when events are • Sequence—0
added in the same hour after the latest event log file is created.
The value resets to 1 in the subsequent hour.
See also these Considerations regarding hourly event logs.
When an hourly incremental log file is delivered, a file with new When a daily incremental log file is delivered, a new file replaces
logs for that hour is created. The Sequence field is incremented the original file with the full set of available logs for that date. The
for each new file. CreatedDate field is updated.
Note: Like with 24-hour event monitoring, hourly event log data is available for the past 30 days.
80
Examples Using Composite Resources
IN THIS SECTION:
Execute Dependent Requests in a Single API Call
The following example uses the Composite resource to execute several dependent requests all in a single call. First, it creates an
account and retrieves its information. Next it uses the account data and the Composite resource’s reference ID functionality to create
a contact and populate its fields based on the account data. Then it retrieves specific information about the account’s owner by
using query parameters in the request string. Finally, if the metadata has been modified since a certain date, it retrieves account
metadata. The composite.json file contains the composite request and subrequest data.
Update an Account, Create a Contact, and Link Them with a Junction Object
The following example uses the Composite resource to update some fields on an account, create a contact, and link the two records
with a junction object called AccountContactJunction. All these requests are executed in a single call. The
composite.json file contains the composite request and subrequest data.
Update a Record and Get Its Field Values in a Single Request
Use the Batch resource to execute multiple requests in a single API call.
Upsert an Account and Create a Contact
The following example uses the Composite resource to upsert an account and create a contact that is linked to the account. All these
requests are executed in a single call. The composite.json file contains the composite request and subrequest data.
Create Nested Records
Use the sObject Tree resource to create nested records that share a root record type. For example, in a single request, you can create
an account along with its child contacts, and a second account along with its child accounts and contacts. Once the request is
processed, the records are created and parents and children are automatically linked by ID. In the request data, you supply the record
hierarchies, required and optional field values, each record’s type, and a reference ID for each record, and then use the POST method
of the resource. The response body will contain the IDs of the created records if the request is successful. Otherwise, the response
contains only the reference ID of the record that caused the error and the error information.
Create Multiple Records
While the sObject Tree resource can be used to create nested records, you can also create multiple, unrelated records of the same
type. In a single request, you can create up to two hundred records. In the request data, you supply the required and optional field
values for each record, each record’s type, and a reference ID for each record, and then use the POST method of the resource. The
response body will contain the IDs of the created records if the request is successful. Otherwise, the response contains only the
reference ID of the record that caused the error and the error information.
Using a Composite Graph
This example shows how to use a composite graph. It also demonstrates how one request can use more than one composite graph.
81
Examples Execute Dependent Requests in a Single API Call
curl https://yourInstance.salesforce.com/services/data/v51.0/composite/ -H
"Authorization: Bearer token -H "Content-Type: application/json" -d "@composite.json"
},{
"method" : "GET",
"referenceId" : "AccountMetadata",
"url" : "/services/data/v51.0/sobjects/Account/describe",
"httpHeaders" : {
"If-Modified-Since" : "Tue, 31 May 2016 18:13:37 GMT"
}
}]
}
82
Examples Execute Dependent Requests in a Single API Call
83
Examples Update an Account, Create a Contact, and Link Them with
a Junction Object
"ETag" : "\"f2293620\"",
"Last-Modified" : "Fri, 22 Jul 2016 18:45:56 GMT"
},
"httpStatusCode" : 304,
"referenceId" : "AccountMetadata"
}]
}
Update an Account, Create a Contact, and Link Them with a Junction Object
The following example uses the Composite resource to update some fields on an account, create a contact, and link the two records
with a junction object called AccountContactJunction. All these requests are executed in a single call. The composite.json
file contains the composite request and subrequest data.
Update an account, create a contact, and link them with a junction object
curl https://yourInstance.salesforce.com/services/data/v51.0/composite/ -H
"Authorization: Bearer token -H "Content-Type: application/json" -d "@composite.json"
84
Examples Update a Record and Get Its Field Values in a Single Request
curl https://yourInstance.salesforce.com/services/data/v51.0/composite/batch/ -H
"Authorization: Bearer token -H "Content-Type: application/json" -d "@batch.json"
85
Examples Upsert an Account and Create a Contact
"method" : "GET",
"url" : "v51.0/sobjects/account/001D000000K0fXOIAZ?fields=Name,BillingPostalCode"
}]
}
SEE ALSO:
Batch
curl https://yourInstance.salesforce.com/services/data/v51.0/composite/ -H
"Authorization: Bearer token -H "Content-Type: application/json" -d "@composite.json"
86
Examples Create Nested Records
"body" : {
"LastName" : "Harrison",
"AccountId" : "@{NewAccount.id}"
}
}]
}
SEE ALSO:
sObject Rows by External ID
87
Examples Create Nested Records
Example for creating two new accounts and their child records
curl https://yourInstance.salesforce.com/services/data/v51.0/composite/tree/Account/
-H "Authorization: Bearer token -H "Content-Type: application/json" -d "@newrecords.json"
Example request body newrecords.json file for creating two new Accounts and their child records
{
"records" :[{
"attributes" : {"type" : "Account", "referenceId" : "ref1"},
"name" : "SampleAccount1",
"phone" : "1234567890",
"website" : "www.salesforce.com",
"numberOfEmployees" : "100",
"industry" : "Banking",
"Contacts" : {
"records" : [{
"attributes" : {"type" : "Contact", "referenceId" : "ref2"},
"lastname" : "Smith",
"Title" : "President",
"email" : "sample@salesforce.com"
},{
"attributes" : {"type" : "Contact", "referenceId" : "ref3"},
"lastname" : "Evans",
"title" : "Vice President",
"email" : "sample@salesforce.com"
}]
}
},{
"attributes" : {"type" : "Account", "referenceId" : "ref4"},
"name" : "SampleAccount2",
"phone" : "1234567890",
"website" : "www.salesforce.com",
"numberOfEmployees" : "52000",
"industry" : "Banking",
"childAccounts" : {
"records" : [{
"attributes" : {"type" : "Account", "referenceId" : "ref5"},
"name" : "SampleChildAccount1",
"phone" : "1234567890",
"website" : "www.salesforce.com",
"numberOfEmployees" : "100",
"industry" : "Banking"
}]
},
"Contacts" : {
"records" : [{
"attributes" : {"type" : "Contact", "referenceId" : "ref6"},
"lastname" : "Jones",
"title" : "President",
"email" : "sample@salesforce.com"
}]
}
}]
}
88
Examples Create Multiple Records
Once the request is processed, all six records are created with the parent-child relationships specified in the request.
SEE ALSO:
sObject Tree
curl https://yourInstance.salesforce.com/services/data/v51.0/composite/tree/Account/
-H "Authorization: Bearer token -H "Content-Type: application/json" -d "@newrecords.json"
Example request body newrecords.json file for creating four new accounts
{
"records" :[{
"attributes" : {"type" : "Account", "referenceId" : "ref1"},
"name" : "SampleAccount1",
"phone" : "1111111111",
"website" : "www.salesforce.com",
"numberOfEmployees" : "100",
89
Examples Using a Composite Graph
"industry" : "Banking"
},{
"attributes" : {"type" : "Account", "referenceId" : "ref2"},
"name" : "SampleAccount2",
"phone" : "2222222222",
"website" : "www.salesforce2.com",
"numberOfEmployees" : "250",
"industry" : "Banking"
},{
"attributes" : {"type" : "Account", "referenceId" : "ref3"},
"name" : "SampleAccount3",
"phone" : "3333333333",
"website" : "www.salesforce3.com",
"numberOfEmployees" : "52000",
"industry" : "Banking"
},{
"attributes" : {"type" : "Account", "referenceId" : "ref4"},
"name" : "SampleAccount4",
"phone" : "4444444444",
"website" : "www.salesforce4.com",
"numberOfEmployees" : "2500",
"industry" : "Banking"
}]
}
SEE ALSO:
sObject Tree
90
Examples Using a Composite Graph
• Composite graphs extend this by allowing you to assemble a more complicated and complete series of related objects and records.
• Composite graphs also enable you to ensure that the steps in a given set of operations are either all completed or all not completed.
This avoids requiring you to check for a mix of successful and unsuccessful results.
• Regular composite requests have a limit of 25 subrequests. Composite graphs increase this limit to 500. This gives a single API call
much greater power.
Create a request:
curl --request POST \
--header "Authorization: Bearer token" \
--header "Content-Type: application/json" \
--data @data.json \
instance.salesforce.com/services/data/vXX.X/composite/graph
where the file data.json contains the JSON definition of the graphs. The general format for the JSON is:
{
"graphs": [
{
"graphId": "graphId",
"compositeRequest": [
compositeSubrequest,
compositeSubrequest,
...
]
},
{
"graphId": "graphId",
"compositeRequest": [
compositeSubrequest,
compositeSubrequest,
...
]
},
...
]
}
91
Examples Using a Composite Graph
{
"url" : "/services/data/v50.0/sobjects/Contact/",
"body" : {
"FirstName" : "Nellie",
"LastName" : "Cashman",
"AccountId" : "@{reference_id_account_1.id}"
},
"method" : "POST",
"referenceId" : "reference_id_contact_1"
},
{
"url" : "/services/data/v50.0/sobjects/Opportunity/",
"body" : {
"CloseDate" : "2024-05-22",
"StageName" : "Prospecting",
"Name" : "Opportunity 1",
"AccountId" : "@{reference_id_account_1.id}"
},
"method" : "POST",
"referenceId" : "reference_id_opportunity_1"
}
]
},
{
"graphId" : "2",
"compositeRequest" : [
{
"url" : "/services/data/v50.0/sobjects/Account/",
"body" : {
"name" : "Easy Spaces"
},
"method" : "POST",
"referenceId" : "reference_id_account_2"
},
{
"url" : "/services/data/v50.0/sobjects/Contact/",
"body" : {
"FirstName" : "Charlie",
"LastName" : "Dawson",
"AccountId" : "@{reference_id_account_2.id}"
},
"method" : "POST",
"referenceId" : "reference_id_contact_2"
}
]
}
]
}
92
Examples Using a Composite Graph
"graphResponse" : {
"compositeResponse" : [
{
"body" : {
"id" : "001R00000064wc7IAA",
"success" : true,
"errors" : [ ]
},
"httpHeaders" : {
"Location" : "/services/data/v50.0/sobjects/Account/001R00000064wc7IAA"
},
"httpStatusCode" : 201,
"referenceId" : "reference_id_account_1"
},
{
"body" : {
"id" : "003R000000DDMlTIAX",
"success" : true,
"errors" : [ ]
},
"httpHeaders" : {
"Location" : "/services/data/v50.0/sobjects/Contact/003R000000DDMlTIAX"
},
"httpStatusCode" : 201,
"referenceId" : "reference_id_contact_1"
},
{
"body" : {
"id" : "006R0000003FPYxIAO",
"success" : true,
"errors" : [ ]
},
"httpHeaders" : {
"Location" :
"/services/data/v50.0/sobjects/Opportunity/006R0000003FPYxIAO"
},
"httpStatusCode" : 201,
"referenceId" : "reference_id_opportunity_1"
}
]
},
"isSuccessful" : true
},
{
"graphId" : "2",
"graphResponse" : {
"compositeResponse" : [
{
"body" : {
"id" : "001R00000064wc8IAA",
"success" : true,
"errors" : [ ]
93
Examples Using a Composite Graph
},
"httpHeaders" : {
"Location" : "/services/data/v50.0/sobjects/Account/001R00000064wc8IAA"
},
"httpStatusCode" : 201,
"referenceId" : "reference_id_account_2"
},
{
"body" : {
"id" : "003R000000DDMlUIAX",
"success" : true,
"errors" : [ ]
},
"httpHeaders" : {
"Location" : "/services/data/v50.0/sobjects/Contact/003R000000DDMlUIAX"
},
"httpStatusCode" : 201,
"referenceId" : "reference_id_contact_2"
}
]
},
"isSuccessful" : true
}
]
}
94
CHAPTER 4 Reference
The following table lists supported REST resources in the API and provides a brief description for each. In each case, the URI for the
resource follows the base URI, which you retrieve from the authentication service: http://domain/services/data. domain
might be the Salesforce instance you are using, or a custom domain. For example, to retrieve basic information about an Account object
in version 51.0: https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/.
Click a call name to see syntax, usage, and more information for that call.
Limits /vXX.X/limits/
Lists information about limits in your org. For each limit, this resource returns the maximum allocation
and the remaining allocation based on usage.
95
Reference
96
Reference
AppMenu /services/data/vXX.X/appMenu/AppSwitcher/
/services/data/vXX.X/appMenu/Salesforce1/
Returns a list of items in either the Salesforce app drop-down menu or the Salesforce for Android,
iOS, and mobile web navigation menu.
97
Reference
Query /vXX.X/query/?q=soql
This API resource executes the specified SOQL query.
QueryAll /vXX.X/queryAll/?q=soql
Executes the specified SOQL query. Results can include deleted, merged and archived records.
98
Reference
Tabs /vXX.X/tabs
Returns a list of all tabs—including Lightning page tabs—available to the current user, regardless
of whether the user has chosen to hide tabs via the All Tabs (+) tab customization feature.
Themes /vXX.X/theme
Gets the list of icons and colors used by themes in the Salesforce application.
Composite Resources
Resource Name URI
Composite /vXX.X/composite
Executes a series of REST API requests in a single call. You can use the output of one request as the
input to a subsequent request. The response bodies and HTTP statuses of the requests are returned
in a single response body. The entire series of requests counts as a single call toward your API limits.
Batch /vXX.X/composite/batch
Executes up to 25 subrequests in a single request.
99
Reference Versions
Versions
Lists summary information about each Salesforce version currently available, including the version, label, and a link to each version's
root.
URI
/services/data/
Formats
JSON, XML
HTTP Method
GET
Authentication
none
Parameters
none
Example
See List Available REST API Versions on page 21.
Resources by Version
Lists available resources for the specified API version, including resource name and URI.
100
Reference Limits
URI
/services/data/vXX.X/
Formats
JSON, XML
HTTP Method
GET
Authentication
Authorization: Bearer token
Parameters
none
Example
See List Available REST Resources. on page 25
Limits
Lists information about limits in your org. For each limit, this resource returns the maximum allocation and the remaining allocation
based on usage. This resource is available in REST API version 29.0 and later for API users with the View Setup and Configuration permission.
The resource returns these limits:
ConcurrentAsyncGetReportInstances Concurrent REST API requests for results of asynchronous report runs
MassEmail Daily number of mass emails that are sent to external email addresses via Apex
or APIs
SingleEmail Daily number of single emails that are sent to external email addresses
Note: For orgs created before Spring ’19, the daily limit is enforced
only for emails sent via Apex and Salesforce APIs except for the REST
API. For orgs created in Spring ’19 and later, the daily limit is also
enforced for email alerts, simple email actions, Send Email actions in
flows, and REST API. If one of the newly counted emails can’t be sent
because your org has reached the limit, we notify you by email and
add an entry to the debug logs.
101
Reference Limits
DailyBulkApiBatches (API version 49.0 and Daily Bulk API and Bulk API 2.0 batches.
later) or DailyBulkApiRequests (API version
48.0 and earlier) In Bulk API, batches are used by both ingest and query operations. In Bulk API
2.0, batches are used only by ingest operations.
DailyBulkV2QueryFileStorageMB Daily storage for queries in Bulk API 2.0 (measured in MB). This limit is available
in API version 47.0 and later.
DailyBulkV2QueryJobs Daily number of query jobs in Bulk API 2.0. This limit is available in API version
47.0 and later.
Platform Events
The following values apply only to platform events. They don’t apply to Change Data Capture events.
102
Reference Limits
MonthlyPlatformEvents (API version 47.0 and Org Without Add-On License: Daily Default Allocation
earlier)
If your org doesn’t have the high-volume platform event or Change Data
Capture add-on, use MonthlyPlatformEvents. This value contains
the default allocation and usage for event delivery to CometD clients and is
incremented for each client. This value doesn’t apply to non-CometD
subscribers, such as Apex triggers, flows, and processes. To get the limit that
is enforced daily, divide the monthly value returned by 30.
MonthlyPlatformEvents includes usage for both high-volume
platform events and Change Data Capture events.
Usage tracking frequency: MonthlyPlatformEvents is updated within
a few minutes after event delivery.
Private Connect
PrivateConnectOutboundCalloutHourlyLimitMB Maximum amount of data in bytes that can be transferred per hour via
outbound private connections.
Salesforce Connect
Storage
DailyDurableGenericStreamingApiEvents Generic events notifications delivered in the past 24 hours to all CometD
clients
DailyDurableStreamingApiEvents PushTopic event notifications delivered in the past 24 hours to all CometD
clients
103
Reference Describe Global
DailyGenericStreamingApiEvents Generic events notifications delivered in the past 24 hours to all CometD
clients
DailyStreamingApiEvents PushTopic event notifications delivered in the past 24 hours to all CometD
clients
StreamingApiConcurrentClients Concurrent CometD clients (subscribers) across all channels and for all event
types
Workflows
URI
/services/data/vXX.X/limits/
Formats
JSON, XML
HTTP Method
GET
Authentication
Authorization: Bearer token
Example
See List Organization Limits.
Describe Global
Lists the available objects and their metadata for your organization’s data. In addition, it provides the organization encoding, as well as
the maximum batch size permitted in queries. For more information on encoding, see Internationalization and Character Sets.
You can use the If-Modified-Since or If-Unmodified-Since header with this resource. When using the
If-Modified-Since header, if no available object’s metadata has changed since the provided date, a 304 Not Modified
status code is returned with no response body.
Note: The If-Modified-Since and If-Unmodified-Since headers check for more than object-specific metadata
changes. They also check for org-wide events, such as changes to permissions, profiles, or field labels.
URI
/vXX.X/sobjects/
Formats
JSON, XML
104
Reference sObject Basic Information
HTTP Method
GET
Authentication
Authorization: Bearer token
Parameters
Parameter Description
If-Modified-Since An optional header specifying a date and time. The request returns records that have
been modified after that date and time.
The format is EEE, dd MMM yyyy HH:mm:ss z. For example:
If-Modified-Since: Mon, 30 Nov 2020 08:34:54 MST.
If-Unmodified-Since An optional header specifying a date and time. The request returns records that have
not been modified after that date and time.
The format is EEE, dd MMM yyyy HH:mm:ss z. For example:
If-Unmodified-Since: Mon, 30 Nov 2020 08:34:54 MST.
Example
See Get a List of Objects on page 25.
Error responses
See Status Codes and Error Responses on page 313.
105
Reference sObject Describe
Parameters
Parameter Description
Content-Type An optional header, which can only be used with POST, specifying the format for the
request and response. Possible choices are:
• Content-Type: application/json
• Content-Type: application/xml
Examples
• For an example of retrieving metadata for an object, see Retrieve Metadata for an Object on page 27.
• For an example of creating a new record using POST, see Create a Record on page 31.
• For an example of create a new record along with providing blob data for the record, see Insert or Update Blob Data on page
59.
sObject Describe
Completely describes the individual metadata at all levels for the specified object. For example, this can be used to retrieve the fields,
URLs, and child relationships for the Account object.
For more information about the metadata that is retrieved, see DescribesObjectResult in the SOAP API Developers Guide.
You can use the If-Modified-Since or If-Unmodified-Since header with this resource. When using the
If-Modified-Since header, if no available object’s metadata has changed since the provided date, a 304 Not Modified
status code is returned with no response body.
URI
/vXX.X/sobjects/sObject/describe/
Formats
JSON, XML
HTTP Method
GET
Authentication
Authorization: Bearer token
Parameters
Parameter Description
sObject The name of the object. For example, Account.
A required path parameter.
106
Reference sObject Get Deleted
Parameter Description
If-Modified-Since An optional header specifying a date and time. The request returns records that have
been modified after that date and time.
The format is EEE, dd MMM yyyy HH:mm:ss z. For example:
If-Modified-Since: Mon, 30 Nov 2020 08:34:54 MST.
If-Unmodified-Since An optional header specifying a date and time. The request returns records that have
not been modified after that date and time.
The format is EEE, dd MMM yyyy HH:mm:ss z. For example:
If-Unmodified-Since: Mon, 30 Nov 2020 08:34:54 MST.
Example
See Get Field and Other Metadata for an Object. For an example that uses the If-Modified-Since HTTP header, see Get
Object Metadata Changes.
Parameter Description
start Starting date/time (Coordinated Universal Time (UTC)—not local— timezone) of the
timespan for which to retrieve the data. The API ignores the seconds portion of the
107
Reference sObject Get Updated
Parameter Description
specified dateTime value (for example, 12:30:15 is interpreted as 12:30:00 UTC). The
date and time should be provided in ISO 8601 format:
YYYY-MM-DDThh:mm:ss+hh:mm. The date/time value for start must
chronologically precede end. This parameter should be URL-encoded.
end Ending date/time (Coordinated Universal Time (UTC)—not local— timezone) of the
timespan for which to retrieve the data. The API ignores the seconds portion of the
specified dateTime value (for example, 12:35:15 is interpreted as 12:35:00 UTC). The
date and time should be provided in ISO 8601 format:
YYYY-MM-DDThh:mm:ss+hh:mm. This parameter should be URL-encoded
Response format
earliestDateAvailable String ISO 8601 format timestamp (Coordinated Universal Time (UTC)—not local—
timezone) of the last physically deleted object.
latestDateCovered String ISO 8601 format timestamp (Coordinated Universal Time (UTC)—not local—
time zone) of the last date covered in the request.
Example
For an example of getting a list of deleted items, see Get a List of Deleted Records Within a Given Timeframe on page 45.
108
Reference sObject Named Layouts
Formats
JSON, XML
HTTP Method
GET
Authentication
Authorization: Bearer token
Parameters
Parameter Description
start Starting date/time (Coordinated Universal Time (UTC) time zone—not local— timezone)
of the timespan for which to retrieve the data. The API ignores the seconds portion of
the specified dateTime value (for example, 12:30:15 is interpreted as 12:30:00 UTC).
The date and time should be provided in ISO 8601 format:
YYYY-MM-DDThh:mm:ss+hh:mm. The date/time value for start must
chronologically precede end. This parameter should be URL-encoded
end Ending date/time (Coordinated Universal Time (UTC) time zone—not local— timezone)
of the timespan for which to retrieve the data. The API ignores the seconds portion of
the specified dateTime value (for example, 12:35:15 is interpreted as 12:35:00 UTC).
The date and time should be provided in ISO 8601 format:
YYYY-MM-DDThh:mm:ss+hh:mm. This parameter should be URL-encoded
Response format
latestDateCovered String ISO 8601 format timestamp (Coordinated Universal Time (UTC)—not local—
time zone) of the last date covered in the request.
Example
For an example of getting a list of updated deleted items, see Get a List of Updated Records Within a Given Timeframe on page 45.
Syntax
URI
/services/data/vXX.X/sobjects/Object/describe/namedLayouts/layoutName
Available since release
31.0
109
Reference sObject Rows
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
None
Example
/services/data/v51.0/sobjects/User/describe/namedLayouts/UserAlt
This example retrieves information on the “UserAlt” named layout for User.
Usage
Use this resource to get information on a named layout for a given object. You must provide a valid named layout name as part of the
resource URI.
To get a list of named layouts for a given object, use the sObject Describe resource and look for the “namedLayoutInfos” field in the
response body.
sObject Rows
Accesses records based on the specified object ID. Retrieves, updates, or deletes records. This resource can also be used to retrieve field
values. Use the GET method to retrieve records or fields, the DELETE method to delete records, and the PATCH method to update records.
To create new records, use the sObject Basic Information resource.
URI
/services/data/vXX.X/sobjects/sObject/id/
Formats
JSON, XML
HTTP Method
GET, PATCH, DELETE
Authentication
Authorization: Bearer token
Parameters
Parameter Description
Content-Type An optional header, which can only be used with PATCH, specifying the format for the
request and response. Possible choices are:
• Content-Type: application/json
• Content-Type: application/xml
110
Reference sObject Rows
Parameter Description
sObject The name of the object. For example, Account.
A required path parameter for all methods (GET, PATCH, and DELETE).
If-Match An optional header specifying a comma-delimited list of one or more ETags. This only
has an effect when used with Account objects. The request is only processed if the
Account’s ETag matches one of the ETags in the list.
For example: If-Match:
"94C83JSreaVMGpL+lUzv8Dr3inI0kCvuKATVJcTuApA=--gzip",
"ddpAdaTHz+GcV35e7NLJ9iKD3XXVqAzXT1Sl2ykkP7g=--gzip".
If-None-Match An optional header specifying a comma-delimited list of one or more ETags. This only
has an effect when used with Account objects. The request is only processed if the
Account’s ETag does not match one of the ETags in the list.
For example: If-None-Match:
"94C83JSreaVMGpL+lUzv8Dr3inI0kCvuKATVJcTuApA=--gzip",
"ddpAdaTHz+GcV35e7NLJ9iKD3XXVqAzXT1Sl2ykkP7g=--gzip".
If-Modified-Since An optional header specifying a date and time. The request returns records that have
been modified after that date and time.
The format is EEE, dd MMM yyyy HH:mm:ss z
For example: If-Modified-Since: Mon, 30 Nov 2020 08:34:54
MST.
If-Unmodified-Since An optional header specifying a date and time. The request returns records that have
not been modified after that date and time.
The format is EEE, dd MMM yyyy HH:mm:ss z
For example: If-Unmodified-Since: Mon, 30 Nov 2020 08:34:54
MST.
Usage
This resource can be used with external objects in API version 32.0 and later.
External objects that are associated with non-high-data-volume external data sources use the 18-character Salesforce ID for the id.
Otherwise, external objects use the External ID standard field of the external object for the id.
For information about the items in the response body, see DescribeSObjectResult in the SOAP API Developer’s Guide.
111
Reference sObject Rows by External ID
If the object is an Account object, the response also contains an ETag header. For example: ETag:
"ddpAdaTHz+GcV35e7NLJ9iKD3XXVqAzXT1Sl2ykkP7g=--gzip" This ETag can be used with the If-Match
and If-None-Match headers. For more information, see Using Conditional Requests.
Examples
• For examples of retrieving field values using GET, see:
– Get Field Values from a Standard Object Record
– Get Field Values from an External Object Record by Using the External ID Standard Field
– Get Field Values from an External Object Record by Using the Salesforce ID
Note: Do not specify Id or an external ID field in the request body or an error is generated.
Note: For security reasons, some Top Level Domains (TLD) may conflict with certain file format extensions. Adjust your
implementation to work around such cases. For example, when an email address is used as the External ID in the request URL, and
the TLD ".inc" is used as part of the field value, the request returns a “404 not found” error.
For example,
GET /services/data/v51.0/sobjects/Lead/Email/example@email.inc
URI
/services/data/vXX.X/sobjects/sObject/fieldName/fieldValue
Formats
JSON, XML
112
Reference sObject Blob Retrieve
HTTP Method
HEAD, GET, PATCH, DELETE, POST (see Usage section)
Authentication
Authorization: Bearer token
Parameters
None
Usage
If you are upserting a record for an object that has a custom field with both the External ID and Unique attributes selected
(a unique index), you do not need any special permissions. The Unique attribute prevents the creation of duplicates. If you are
upserting a record for an object that has the External ID attribute selected but not the Unique attribute selected, (a
non-unique index) your client application must have the permission “View All Data” to execute this call.
As a special case, in API version 37.0 and later, you can create a record with a POST request to
/vXX.X/sobjects/sObjectName/Id. Because Id has a null value, it is omitted from the request, and the record is
created according to the request body. Upserting records with this method is useful because you can use the same resource in each
POST request for each new record. In this case, you are not required to specify an external ID to create a record.
Examples
• For an example of retrieving a record based on an external ID, see Retrieve a Record Using an External ID on page 35.
• For examples of creating and updating records based on external IDs, see Insert or Update (Upsert) a Record Using an External
ID on page 35.
113
Reference sObject ApprovalLayouts
sObject ApprovalLayouts
Returns a list of approval layouts for a specified object. Specify a particular approval process name to limit the return value to one specific
approval layout. This resource is available in REST API version 30.0 and later.
Syntax
URI
To get an approval layout description for a specified object, use
/services/data/vXX.X/sobjects/sObject/describe/approvalLayouts/
To get an approval layout description for a particular approval process, use
/services/data/vXX.X/sobjects/sObject/describe/approvalLayouts/approvalProcessName
Formats
JSON, XML
HTTP methods
HEAD, GET
Authentication
Authorization: Bearer token
Request parameters
None required
Example
Getting all approval layouts for an sObject
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/describe/approvalLayouts/
-H "Authorization: Bearer token"
If you haven’t defined any approval layouts for an object, the response is {"approvalLayouts" : [ ]}.
114
Reference sObject CompactLayouts
sObject CompactLayouts
Returns a list of compact layouts for a specific object. This resource is available in REST API version 29.0 and later.
Syntax
URI
For a compact layout description for a specific object, use
/services/data/vXX.X/sobjects/sObject/describe/compactLayouts/
Formats
JSON, XML
HTTP methods
HEAD, GET
Authentication
Authorization: Bearer token
Request parameters
None required
Example
Getting compact layouts
/services/data/v51.0/sobjects/Account/describe/compactLayouts
{
"compactLayouts" : [ {
115
Reference sObject CompactLayouts
"actions" : [ {
"custom" : false,
"icons" : null,
"label" : "Call",
"name" : "CallHighlightAction"
}, {
"custom" : false,
"icons" : null,
"label" : "Send Email",
"name" : "EmailHighlightAction"
}, {
"custom" : false,
"icons" : null,
"label" : "Map",
"name" : "MapHighlightAction"
}, {
"custom" : false,
"icons" : null,
"label" : "Read News",
"name" : "NewsHighlightAction"
}, {
"custom" : false,
"icons" : null,
"label" : "View Website",
"name" : "WebsiteHighlightAction"
} ],
"fieldItems" : [ {
"editable" : false,
"label" : "Account Name",
"layoutComponents" : [ {
"components" : [ ],
"details" : {
"autoNumber" : false,
"byteLength" : 765,
"calculated" : false,
"calculatedFormula" : null,
"cascadeDelete" : false,
"caseSensitive" : false,
"controllerName" : null,
"createable" : true,
"custom" : false,
"defaultValue" : null,
"defaultValueFormula" : null,
"defaultedOnCreate" : false,
"dependentPicklist" : false,
"deprecatedAndHidden" : false,
"digits" : 0,
"displayLocationInDecimal" : false,
"externalId" : false,
"extraTypeInfo" : null,
"filterable" : true,
"groupable" : true,
"htmlFormatted" : false,
"idLookup" : false,
116
Reference sObject CompactLayouts
"inlineHelpText" : null,
"label" : "Account Name",
"length" : 255,
"mask" : null,
"maskType" : null,
"name" : "Name",
"nameField" : true,
"namePointing" : false,
"nillable" : false,
"permissionable" : false,
"picklistValues" : [ ],
"precision" : 0,
"queryByDistance" : false,
"referenceTo" : [ ],
"relationshipName" : null,
"relationshipOrder" : null,
"restrictedDelete" : false,
"restrictedPicklist" : false,
"scale" : 0,
"soapType" : "xsd:string",
"sortable" : true,
"type" : "string",
"unique" : false,
"updateable" : true,
"writeRequiresMasterRead" : false
},
"displayLines" : 1,
"tabOrder" : 2,
"type" : "Field",
"value" : "Name"
} ],
"placeholder" : false,
"required" : false
}, {
"editable" : false,
"label" : "Phone",
"layoutComponents" : [ {
"components" : [ ],
"details" : {
"autoNumber" : false,
"byteLength" : 120,
"calculated" : false,
"calculatedFormula" : null,
"cascadeDelete" : false,
"caseSensitive" : false,
"controllerName" : null,
"createable" : true,
"custom" : false,
"defaultValue" : null,
"defaultValueFormula" : null,
"defaultedOnCreate" : false,
"dependentPicklist" : false,
"deprecatedAndHidden" : false,
"digits" : 0,
117
Reference sObject CompactLayouts
"displayLocationInDecimal" : false,
"externalId" : false,
"extraTypeInfo" : null,
"filterable" : true,
"groupable" : true,
"htmlFormatted" : false,
"idLookup" : false,
"inlineHelpText" : null,
"label" : "Account Phone",
"length" : 40,
"mask" : null,
"maskType" : null,
"name" : "Phone",
"nameField" : false,
"namePointing" : false,
"nillable" : true,
"permissionable" : true,
"picklistValues" : [ ],
"precision" : 0,
"queryByDistance" : false,
"referenceTo" : [ ],
"relationshipName" : null,
"relationshipOrder" : null,
"restrictedDelete" : false,
"restrictedPicklist" : false,
"scale" : 0,
"soapType" : "xsd:string",
"sortable" : true,
"type" : "phone",
"unique" : false,
"updateable" : true,
"writeRequiresMasterRead" : false
},
"displayLines" : 1,
"tabOrder" : 3,
"type" : "Field",
"value" : "Phone"
} ],
"placeholder" : false,
"required" : false
} ],
"id" : "0AHD000000000AbOAI",
"imageItems" : [ {
"editable" : false,
"label" : "Photo URL",
"layoutComponents" : [ {
"components" : [ ],
"details" : {
"autoNumber" : false,
"byteLength" : 765,
"calculated" : false,
"calculatedFormula" : null,
"cascadeDelete" : false,
"caseSensitive" : false,
118
Reference sObject CompactLayouts
"controllerName" : null,
"createable" : false,
"custom" : false,
"defaultValue" : null,
"defaultValueFormula" : null,
"defaultedOnCreate" : false,
"dependentPicklist" : false,
"deprecatedAndHidden" : false,
"digits" : 0,
"displayLocationInDecimal" : false,
"externalId" : false,
"extraTypeInfo" : "imageurl",
"filterable" : true,
"groupable" : true,
"htmlFormatted" : false,
"idLookup" : false,
"inlineHelpText" : null,
"label" : "Photo URL",
"length" : 255,
"mask" : null,
"maskType" : null,
"name" : "PhotoUrl",
"nameField" : false,
"namePointing" : false,
"nillable" : true,
"permissionable" : false,
"picklistValues" : [ ],
"precision" : 0,
"queryByDistance" : false,
"referenceTo" : [ ],
"relationshipName" : null,
"relationshipOrder" : null,
"restrictedDelete" : false,
"restrictedPicklist" : false,
"scale" : 0,
"soapType" :
"xsd:string",
"sortable" : true,
"type" : "url",
"unique" : false,
"updateable" : false,
"writeRequiresMasterRead" : false
},
"displayLines" : 1,
"tabOrder" : 1,
"type" : "Field",
"value" : "PhotoUrl"
} ],
"placeholder" : false,
"required" : false
} ],
"label" : "Custom Account Compact Layout",
"name" : "Custom_Account_Compact_Layout"
} ],
119
Reference Describe Layouts
"defaultCompactLayoutId" : "0AHD000000000AbOAI",
"recordTypeCompactLayoutMappings" : [ {
"available" : true,
"compactLayoutId" : "0AHD000000000AbOAI",
"compactLayoutName" : "Custom_Account_Compact_Layout",
"recordTypeId" : "012000000000000AAA",
"recordTypeName" : "Master",
"urls" : {
"compactLayout" :
"/services/data/v51.0/sobjects/Account/describe/compactLayouts/012000000000000AAA"
}
} ],
"urls" : {
"primary" : "/services/data/v51.0/sobjects/Account/describe/compactLayouts/primary"
}
}
If you haven’t defined any compact layouts for an object, the compactLayoutId returns as Null.
Describe Layouts
Returns a list of layouts and descriptions. The list of fields and the layout name are returned.
URI
To return descriptions of global publisher layouts, the URI is:
/services/data/vXX.X/sobjects/Global/describe/layouts/
For a layout description for a specific object, use /services/data/vXX.X/sobjects/Object/describe/layouts/
For a layout description for objects that have more than one record type defined, use
/services/data/vXX.X/sobjects/Object/describe/layouts/<recordTypeId>. For example, the
following URI requests the layout for a specific Contact record ID:
/services/data/vXX.X/sobjects/Contact/describe/layouts/012xx00000024x5AAA. A GET request
for objects that have more than one record type defined returns null for the layouts section of the response.
Formats
JSON, XML
HTTP Method
HEAD, GET
Authentication
Authorization: Bearer token
Parameters
None required
Example for getting global publisher layouts
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Global/describe/layouts/
-H "Authorization: Bearer token"
120
Reference Describe Layouts
121
Reference sObject PlatformAction
sObject PlatformAction
PlatformAction is a virtual read-only object. It enables you to query for actions displayed in the UI, given a user, a context, device format,
and a record ID. Examples include standard and custom buttons, quick actions, and productivity actions.
Returns the description of the PlatformAction.
122
Reference sObject Quick Actions
Syntax
URI
Use /services/data/vXX.X/sobjects/PlatformAction
Available since release
This resource is available in API version 33.0 and later.
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
None.
Usage
The only thing you can do with this resource is Query it.
123
Reference sObject Rich Text Image Retrieve
Authentication
Authorization: Bearer token
Parameters
None required
Example for getting Account actions
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/quickActions
-H "Authorization: Bearer token"
"contextId" : "001D000000JRSGf",
"record" : { "LastName" : "Smith" }
Considerations
• The resources return all actions—both global and standard—in addition to the ones requested.
Parameter Description
sObjectName Indicates the name of the standard object of the record.
124
Reference sObject Relationships
Parameter Description
contentReferenceId The reference ID that uniquely identifies an image within a rich text area field.
You can obtain the reference by retrieving information for the object. The description
will show the contents of the rich text area field. For example:
{
"attributes" : {
"type" : "Lead",
"url" :
"/services/data/v51.0/sobjects/Lead/00QRM000003ZfDb2AK"
},
"Id" : "00QRM000003ZfDb2AK",
...
"ContactPhoto__c" :
"Sarah Loehr and her two dogs.
<img alt=\"Sarah Loehr.\"
src=\"https://MyDomainName--c.documentforce.com/servlet/rtaImage?
eid=00QRM000003ZfDb&
feoid=00NRM000001E73j&
refid=0EMRM00000002Ip\"></img>"
}
Note: If you’re using enhanced domains, your org’s My Domain URLs are
different. For details, see My Domain URL Formats in Salesforce Help.
Example
For an example of retrieving the blob data from a rich text area field, see Get an Image from a Rich Text Area Field on page 26.
Error responses
See Status Codes and Error Responses on page 313.
sObject Relationships
Accesses records by traversing object relationships via friendly URLs. You can retrieve, update, or delete the record associated with the
traversed relationship field. If there are multiple related records, you can retrieve the complete set of associated records. This resource
is available in REST API version 36.0 and later.
URI
/services/data/vXX.X/sobjects/sObject/id/relationship field name
Formats
JSON, XML
HTTP Methods
GET, PATCH, DELETE
125
Reference sObject Suggested Articles
Authentication
Authorization: Bearer token
Parameters
Parameter Description
fields Optional for GET. A list of fields in the associated relationship record to return. Fields
are separated by commas. For example:
/services/data/v51.0/sobjects/sObject/id/relationship
field?fields=field1,field2
Response Body
For retrievals via GET, the response body is the contents of the record associated with the relationship field. Here is 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.
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Merchandise__c/a01D000000INjVe/Distributor__r
{
"attributes" :
{
"type" : "Distributor__c",
"url" : "/services/data/v51.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"
}
A response body isn’t returned for updates via PATCH and deletions via DELETE.
Error Responses
If no record is 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 on page 313.
Example
For examples of using sObject Relationships to access relationship fields, see Traverse Relationships with Friendly URLs on page 39.
126
Reference sObject Suggested Articles
Syntax
URI
To return suggested articles for a case, work order, or work order line item that is being created, use
/services/data/vXX.X/sobjects/sObject/suggestedArticles
?language=articleLanguage&subject=subject&description=description. The sObject can be
Case, WorkOrder, or WorkOrderLineItem. Suggestions are based on common keywords in the title, description, and
other information that’s entered before the record has been saved and assigned an ID.
For example:
/services/data/vXX.X/sobjects/Case/suggestedArticles?language=articleLanguage&subject=subject&description=description
or
vXX.X/sobjects/WorkOrder/suggestedArticles?language=articleLanguage&subject=subject&description=description.
To return suggested articles for an existing record with an ID, use
/services/data/vXX.X/sobjects/sObject/ID/suggestedArticles?language=articleLanguage
Available since release
30.0
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
None required
Request parameters
Parameter Description
articleTypes Optional. Three-character ID prefixes indicating the desired article types. You can specify
multiple values for this parameter in a single REST call, by repeating the parameter
name for each value. For example, articleTypes=ka0&articleTypes=ka1.
categories Optional. The name of the data category group and the data category API name (not
category title) for desired articles. The syntax is
categories={"Group":"Category"}. Characters in the URL might need
to be encoded. For example:
categories=%7B%22Regions%22%3A%22Asia%22%2C%22
Products%22%3A%22Laptops%22%7D
The same data category group can’t be specified more than once. However, you can
specify multiple data category group and data category pairs. For example,
categories={"Regions":"Asia","Products":"Laptops"}.
description Text of the description. Valid only for new records without an existing ID and required
if subject is null. Article suggestions are based on common keywords in the subject,
description, or both.
127
Reference sObject Suggested Articles
Parameter Description
limit Optional. Specifies the maximum number of suggested articles to return.
subject Text of the subject. Valid only for new records without an existing ID and required if
description is null. Article suggestions are based on common keywords in the
subject, description, or both.
Example for getting suggested articles for a case that’s being created
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Case/suggestedArticles?
language=en_US&subject=orange+banana&articleTypes=ka0&articleTypes=ka1
-H "Authorization: Bearer token"
Usage
Salesforce Knowledge must be enabled in your organization. The user must have the “View Articles” permission enabled. The articles
suggested include only the articles the user can access, based on the data categories and article types the user has permissions to view.
Articles are suggested based on a relevance algorithm. The suggestedArticles resource is designed to get the IDs of articles
relevant to a case, work order, or work order line item. It’s intended to be used with other services that then use the IDs to get article
data for display.
128
Reference sObject User Password
Syntax
URI
/services/data/vXX.X/sobjects/eventName/eventSchema
Available since release
40.0
Formats
JSON
HTTP methods
GET
Authentication
Authorization: Bearer token
129
Reference Platform Event Schema by Event Name
Parameters
Parameter Description
payloadFormat (Optional query parameter. Available in API version 43.0 and later.) The format of the returned event
schema. This parameter can take one of the following values.
• EXPANDED—The JSON representation of the event schema, which is the default format when
payloadFormat is not specified in API version 43.0 and later.
• COMPACT—A format that adheres to the open-source Apache Avro specification for the record
complex type (see Apache Avro Format). Subscribers use the compact schema format to
deserialize compact events received in binary form.
Error Codes
400 Bad Request Description
In API version 43.0 The request was formatted incorrectly—an invalid value was passed for the payloadFormat parameter
and later in the URI.
In API version 42.0 The request was formatted incorrectly—the payloadFormat parameter was passed in the URI but this
and earlier API version doesn’t support this parameter.
Or:
/services/data/v51.0/sobjects/Low_Ink__e/eventSchema?payloadFormat=EXPANDED
The returned response for the expanded format looks like the following in API version 43.0.
{
"name" : "Low_Ink__e",
"namespace" : "com.sforce.eventbus",
"type" : "expanded-record",
"fields" : [ {
"name" : "data",
"type" : {
"type" : "record",
"name" : "Data",
"namespace" : "",
"fields" : [ {
"name" : "schema",
"type" : "string"
}, {
"name" : "payload",
130
Reference Platform Event Schema by Event Name
"type" : {
"type" : "record",
"name" : "Payload",
"doc" : "",
"fields" : [ {
"name" : "CreatedDate",
"type" : "string",
"doc" : "CreatedDate:DateTime"
}, {
"name" : "CreatedById",
"type" : "string",
"doc" : "CreatedBy:EntityId"
}, {
"name" : "Printer_Model__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Serial_Number__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Ink_Percentage__c",
"type" : [ "null", "double" ],
"doc" : "Data:Double",
"default" : null
} ]
}
}, {
"name" : "event",
"type" : {
"type" : "record",
"name" : "Event",
"fields" : [ {
"name" : "replayId",
"type" : "long"
} ]
}
} ]
}
}, {
"name" : "channel",
"type" : "string"
} ]
}
To get the compact (Apache Avro) format, use the following URI.
/services/data/v51.0/sobjects/Low_Ink__e/eventSchema?payloadFormat=COMPACT
The returned response for the compact format looks like the following in API version 51.0.
{
"name" : "Low_Ink__e",
131
Reference Platform Event Schema by Event Name
"namespace" : "com.sforce.eventbus",
"doc" : "51.0",
"type" : "record",
"fields" : [ {
"name" : "CreatedDate",
"type" : "long",
"doc" : "CreatedDate:DateTime"
}, {
"name" : "CreatedById",
"type" : "string",
"doc" : "CreatedBy:EntityId"
}, {
"name" : "Printer_Model__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Serial_Number__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Ink_Percentage__c",
"type" : [ "null", "double" ],
"doc" : "Data:Double",
"default" : null
} ],
"uuid" : "5E5OtZj5_Gm6Vax9XMXH9A"
}
Note: The compact schema doesn’t include the replayId or channel fields because these fields are not necessary for
deserializing the compact event received.
Note: This format is what the API returns in API version 43.0 and later when appending the ?payloadFormat=COMPACT
parameter.
/services/data/v42.0/sobjects/Low_Ink__e/eventSchema
The returned response looks like the following in API version 42.0.
{
"name" : "Low_Ink__e",
"namespace" : "com.sforce.eventbus",
"doc" : "42.0",
"type" : "record",
"fields" : [ {
"name" : "CreatedDate",
"type" : "long",
"doc" : "CreatedDate:DateTime"
}, {
132
Reference Platform Event Schema by Schema ID
"name" : "CreatedById",
"type" : "string",
"doc" : "CreatedBy:EntityId"
}, {
"name" : "Printer_Model__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Serial_Number__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Ink_Percentage__c",
"type" : [ "null", "double" ],
"doc" : "Data:Double",
"default" : null
} ],
"uuid" : "5E5OtZj5_Gm6Vax9XMXH9A"
}
Note: When you change the definition of a platform event, the schema ID for this platform event changes.
The response also includes the uuid field, which contains the schema’s ID. The ID is the MD5 fingerprint of the normalized Avro schema
encoded as a base-64 URL variant. You can append this ID to the /vXX.X/event/eventSchema/ URI to retrieve the schema.
133
Reference Platform Event Schema by Schema ID
Syntax
URI
/services/data/vXX.X/event/eventSchema/schemaId
Available since release
40.0
Formats
JSON
HTTP methods
GET
Authentication
Authorization: Bearer token
Parameters
Parameter Description
payloadFormat (Optional query parameter. Available in API version 43.0 and later.) The format of the returned event
schema. This parameter can take one of the following values.
• EXPANDED—The JSON representation of the event schema, which is the default format when
payloadFormat is not specified in API version 43.0 and later.
• COMPACT—A format that adheres to the open-source Apache Avro specification for the record
complex type (see Apache Avro Format). Subscribers use the compact schema format to
deserialize compact events received in binary form.
Error Codes
400 Bad Request Description
In API version 43.0 The request was formatted incorrectly—an invalid value was passed for the payloadFormat parameter
and later in the URI.
In API version 42.0 The request was formatted incorrectly—the payloadFormat parameter was passed in the URI but this
and earlier API version doesn’t support this parameter.
Or:
/services/data/v51.0/event/eventSchema/5E5OtZj5_Gm6Vax9XMXH9A?payloadFormat=EXPANDED
134
Reference Platform Event Schema by Schema ID
In API version 43.0 and later, the response format is the JSON representation of the event schema by default. The returned response
looks like the following in API version 51.0.
{
"name" : "Low_Ink__e",
"namespace" : "com.sforce.eventbus",
"type" : "expanded-record",
"fields" : [ {
"name" : "data",
"type" : {
"type" : "record",
"name" : "Data",
"namespace" : "",
"fields" : [ {
"name" : "schema",
"type" : "string"
}, {
"name" : "payload",
"type" : {
"type" : "record",
"name" : "Payload",
"doc" : "",
"fields" : [ {
"name" : "CreatedDate",
"type" : "string",
"doc" : "CreatedDate:DateTime"
}, {
"name" : "CreatedById",
"type" : "string",
"doc" : "CreatedBy:EntityId"
}, {
"name" : "Printer_Model__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Serial_Number__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Ink_Percentage__c",
"type" : [ "null", "double" ],
"doc" : "Data:Double",
"default" : null
} ]
}
}, {
"name" : "event",
"type" : {
"type" : "record",
"name" : "Event",
"fields" : [ {
"name" : "replayId",
"type" : "long"
135
Reference Platform Event Schema by Schema ID
} ]
}
} ]
}
}, {
"name" : "channel",
"type" : "string"
} ]
}
To get the compact (Apache Avro) format, use the following URI.
/services/data/v51.0/event/eventSchema/5E5OtZj5_Gm6Vax9XMXH9A?payloadFormat=COMPACT
The returned response for the compact format looks like the following in API version 51.0.
{
"name" : "Low_Ink__e",
"namespace" : "com.sforce.eventbus",
"doc" : "51.0",
"type" : "record",
"fields" : [ {
"name" : "CreatedDate",
"type" : "long",
"doc" : "CreatedDate:DateTime"
}, {
"name" : "CreatedById",
"type" : "string",
"doc" : "CreatedBy:EntityId"
}, {
"name" : "Printer_Model__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Serial_Number__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Ink_Percentage__c",
"type" : [ "null", "double" ],
"doc" : "Data:Double",
"default" : null
} ],
"uuid" : "5E5OtZj5_Gm6Vax9XMXH9A"
}
Note: The compact schema doesn’t include the replayId or channel fields because these fields are not necessary for
deserializing the compact event received.
136
Reference Platform Event Schema by Schema ID
Note: This format is what the API returns in API version 43.0 and later when appending the ?payloadFormat=COMPACT
parameter.
This URI gets the schema of a platform event whose schema ID is 5E5OtZj5_Gm6Vax9XMXH9A. This schema ID is a sample ID.
Replace it with a valid schema ID for your event.
/services/data/v42.0/event/eventSchema/5E5OtZj5_Gm6Vax9XMXH9A
The returned response looks like the following in API version 42.0.
{
"name" : "Low_Ink__e",
"namespace" : "com.sforce.eventbus",
"doc" : "42.0",
"type" : "record",
"fields" : [ {
"name" : "CreatedDate",
"type" : "long",
"doc" : "CreatedDate:DateTime"
}, {
"name" : "CreatedById",
"type" : "string",
"doc" : "CreatedBy:EntityId"
}, {
"name" : "Printer_Model__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Serial_Number__c",
"type" : [ "null", "string" ],
"doc" : "Data:Text",
"default" : null
}, {
"name" : "Ink_Percentage__c",
"type" : [ "null", "double" ],
"doc" : "Data:Double",
"default" : null
} ],
"uuid" : "5E5OtZj5_Gm6Vax9XMXH9A"
}
Note: When you change the definition of a platform event, the schema ID for this platform event changes.
If you don’t have the schema ID, you can get the schema by supplying the platform event name. Make a GET request to
/services/data/vXX.X/sobjects/eventName/eventSchema. See Platform Event Schema by Event Name.
137
Reference AppMenu
The response also includes the uuid field, which contains the schema’s ID. The ID is the MD5 fingerprint of the normalized Avro schema
encoded as a base-64 URL variant. You can append this ID to the /vXX.X/event/eventSchema/ URI to retrieve the schema.
AppMenu
Returns a list of items in either the Salesforce app drop-down menu or the Salesforce for Android, iOS, and mobile web navigation menu.
Syntax
URI
To return a list of the Salesforce app drop-down menu items, the URI is: /services/data/vXX.X/appMenu/AppSwitcher/
To return a list of the Salesforce for Android, iOS, and mobile web navigation menu items, the URI is:
/services/data/vXX.X/appMenu/Salesforce1/
Available since release
29.0
Formats
JSON, XML
HTTP methods
GET, HEAD
Authentication
Authorization: Bearer token
Request body
None
Request parameters
None required
Example
Getting appMenu types
138
Reference AppMenu
"content" : null,
"icons" : null,
"colors" : null,
"label" : "Sales",
"url" : "/home/home.jsp?tsid=02uxx00000056Sq"
}, {
"type" : "Tabset",
"content" : null,
"icons" : null,
"colors" : null,
"label" : "Service",
"url" : "/home/home.jsp?tsid=02uxx00000056Sr"
}, {
"type" : "Tabset",
"content" : null,
"icons" : null,
"colors" : null,
"label" : "Marketing",
"url" : "/home/home.jsp?tsid=02uxx00000056St"
}, {
"type" : "Tabset",
"content" : null,
"icons" : null,
"colors" : null,
"label" : "Salesforce Chatter",
"url" : "/home/home.jsp?tsid=02uxx00000056Su"
}, {
"type" : "Tabset",
"content" : null,
"icons" : null,
"colors" : null,
"label" : "Community",
"url" : "/home/home.jsp?tsid=02uxx00000056Sw"
}, {
"type" : "Tabset",
"content" : null,
"icons" : null,
"colors" : null,
"label" : "App Launcher",
"url" : "/app/mgmt/applauncher/appLauncher.apexp?tsid=02uxx00000056Sx"
} ]
}
139
Reference AppMenu
"content" : null,
"icons" : null,
"colors" : null,
"label" : "Today",
"url" : "/myDay"
}, {
"type" : "Standard.Tasks",
"content" : null,
"icons" : null,
"colors" : null,
"label" : "Tasks",
"url" : "/tasks"
}, {
"type" : "Standard.Dashboards",
"content" : null,
"icons" : null,
"colors" : null,
"label" : "Dashboards",
"url" : "/dashboards"
}, {
"type" : "Tab.flexiPage",
"content" : "MySampleFlexiPage",
"icons" : [ {
"contentType" : "image/png",
"width" : 32,
"height" : 32,
"theme" : "theme3",
"url" : "http://myorg.com/img/icon/custom51_100/bell32.png"
}, {
"contentType" : "image/png",
"width" : 16,
"height" : 16,
"theme" : "theme3",
"url" : "http://myorg.com/img/icon/custom51_100/bell16.png"
}, {
"contentType" : "image/svg+xml",
"width" : 0,
"height" : 0,
"theme" : "theme4",
"url" : "http://myorg.com/img/icon/t4/custom/custom53.svg"
}, {
"contentType" : "image/png",
"width" : 60,
"height" : 60,
"theme" : "theme4",
"url" : "http://myorg.com/img/icon/t4/custom/custom53_60.png"
}, {
"contentType" : "image/png",
"width" : 120,
"height" : 120,
"theme" : "theme4",
"url" : "http://myorg.com/img/icon/t4/custom/custom53_120.png"
} ],
"colors" : [ {
140
Reference AppMenu
"context" : "primary",
"color" : "FC4F59",
"theme" : "theme4"
}, {
"context" : "primary",
"color" : "FC4F59",
"theme" : "theme3"
} ],
"label" : "My App Home Page",
"url" : "/servlet/servlet.Integration?lid=01rxx0000000Vsd&ic=1"
}, {
"type" : "Tab.apexPage",
"content" : "/apex/myapexpage",
"icons" : [ {
"contentType" : "image/png",
"width" : 32,
"height" : 32,
"theme" : "theme3",
"url" : "http://myorg.com/img/icon/cash32.png"
}, {
"contentType" : "image/png",
"width" : 16,
"height" : 16,
"theme" : "theme3",
"url" : "http://myorg.com/img/icon/cash16.png"
}, {
"contentType" : "image/svg+xml",
"width" : 0,
"height" : 0,
"theme" : "theme4",
"url" : "http://myorg.com/img/icon/t4/custom/custom41.svg"
}, {
"contentType" : "image/png",
"width" : 60,
"height" : 60,
"theme" : "theme4",
"url" : "http://myorg.com/img/icon/t4/custom/custom41_60.png"
}, {
"contentType" : "image/png",
"width" : 120,
"height" : 120,
"theme" : "theme4",
"url" : "http://myorg.com/img/icon/t4/custom/custom41_120.png"
} ],
"colors" : [ {
"context" : "primary",
"color" : "3D8D8D",
"theme" : "theme4"
}, {
"context" : "primary",
"color" : "3D8D8D",
"theme" : "theme3"
} ],
"label" : "label",
141
Reference Compact Layouts
"url" : "/servlet/servlet.Integration?lid=01rxx0000000Vyb&ic=1"
} ]
}
Compact Layouts
Returns a list of compact layouts for multiple objects. This resource is available in REST API version 31.0 and later.
This resource returns the primary compact layout for a set of objects. The set of objects is specified using a query parameter. Up to 100
objects can be queried at once.
Note: PersonAccount isn’t supported for bulk queries. If you want to get the primary compact layout for PersonAccount, get it
directly from
/services/data/v51.0/sobjects/Account/describe/compactLayouts/primaryPersonAccount.
Syntax
URI
/services/data/vXX.X/compactLayouts?q=object_list
Available since release
31.0
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request parameters
Parameter Description
q A comma-delimited list of objects. The primary compact layout for each object in this
list will be returned in the response of this resource.
Example
Request for getting compact layouts for multiple objects
/services/data/v51.0/compactLayouts?q=Account,Contact,CustomObj__c
142
Reference Compact Layouts
"custom" : false,
"encoding" : null,
"height" : null,
"icons" : null,
"label" : "Call",
"menubar" : false,
"name" : "CallHighlightAction",
"overridden" : false,
"resizeable" : false,
"scrollbars" : false,
"showsLocation" : false,
"showsStatus" : false,
"toolbar" : false,
"url" : null,
"width" : null,
"windowPosition" : null
},
...
"id" : "0AHD000000000AbOAI",
"label" : "Custom Account Compact Layout",
"name" : "Custom_Account_Compact_Layout"
},
"Contact" : {
"actions" : [ {
"behavior" : null,
"content" : null,
"contentSource" : null,
"custom" : false,
"encoding" : null,
"height" : null,
"icons" : null,
"label" : "Call",
"menubar" : false,
"name" : "CallHighlightAction",
"overridden" : false,
"resizeable" : false,
"scrollbars" : false,
"showsLocation" : false,
"showsStatus" : false,
"toolbar" : false,
"url" : null,
"width" : null,
"windowPosition" : null
},
...
"id" : null,
"label" : "System Default",
"name" : "SYSTEM"
}
"CustomObj__c" : {
"actions" : [ {
"behavior" : null,
"content" : null,
"contentSource" : null,
143
Reference Consent
"custom" : false,
"encoding" : null,
"height" : null,
"icons" : null,
"label" : "Call",
"menubar" : false,
"name" : "CallHighlightAction",
"overridden" : false,
"resizeable" : false,
"scrollbars" : false,
"showsLocation" : false,
"showsStatus" : false,
"toolbar" : false,
"url" : null,
"width" : null,
"windowPosition" : null
},
...
"id" : null,
"imageItems" : null,
"label" : "System Default",
"name" : "SYSTEM"
}
}
Consent
Your users can store consent preferences in different locations and possibly inconsistently. You can locate your customers’ preferences
for consent across multiple records when using API version 44.0 and later. Tracking consent preferences helps you and your users respect
the most restrictive requests. You can use the Consent API with specific Customer 360 Audiences parameters with API version 50.0 and
later. See the syntax and parameters for Customer 360 Audiences in the following section.
Consent API aggregates consent settings across the Contact, Contact Point Type Consent, Data Use Purpose, Individual, Lead, Person
Account, and User objects when the records have a lookup relationship. The Consent API can't locate records in which the email address
field is protected by Platform Encryption.
The API returns consent details based on a single action, like email or track. Starting with API version 45.0, the multiaction endpoint
allows you to request multiple actions in a single API call.
You can use the Consent API with specific Customer 360 Audiences parameters with API version 50.0 and later. Syntax and parameters
for Customer 360 Audiences are at the end of this topic.
144
Reference Consent
Formats
JSON
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
None
Request parameters
Parameter Description
actions Comma-separated list of proposed actions. This required parameter applies only to
the multiaction endpoint.
This parameter is available in API version 45.0 and later.
If this parameter is used, action cannot be used.
datetime Optional. The timestamp for which consent is determined. The value is converted to
the UTC timezone and must be specified in ISO 8601 format. If not specified, defaults
to the current date and time.
ids Required. Comma-separated list of IDs. The ID can be the record ID or the email address
listed on the record.
verbose Optional: true or false. verbose is the same as verbose=true. Verbose responses
are slower than non-verbose responses. See the examples for a verbose response.
Action
Allowed values are:
• email
• fax
• geotrack
• mailing
• phone
145
Reference Consent
• portability
• process
• profile
• shouldForget
• social
• solicit
• storePiiElsewhere
• track
• web
If action is used, actions cannot be used.
Note: When you select email as the action, the API only aggregates consent for records that contain the same email address.
If the record ID specified in the URI is associated with a record that contains a different email address, the consent settings of
the associated record aren’t included in the API response.
Examples
Simple URI structure
/services/data/v51.0/consent/action/track?ids=003xx000004TxyY,00Qxx00000syyO,003zz000004zzZ
Email addresses as IDs, specified purpose and timespan, and a verbose response
/services/data/v51.0/consent/action/email?ids=j0t5t5b2@tkbxp5ia.com,4quxlswo@23wj7pwh.com&datetime=2018-12-12T00:00:00Z&purpose=billing&verbose=true
Response
{
"j0t5t5b2@tkbxp5ia.com" : {
"result" : "Success",
"proceed" : {
"email" : "true"
"emailResult" : "Success"
},
"explanation" : [ {
"objectConsulted" : "ContactTypePointConsent",
"status" : "opt_in",
"purpose" : "billing",
"recordId" : "003xx000004TxyY",
"value" : "true"
},{
"objectConsulted" : "Contact",
"field" : "HasOptedOutOfTracking",
"recordId" : "1",
"value" : "true"
}]
},
"4quxlswo@23wj7pwh.com" : {
146
Reference Consent
"result" : "Success",
"proceed" : {
"email" : "false"
"emailResult" : "Success"
},
"explanation" : [ {
"objectConsulted" : "Contact",
"field" : "HasOptedOutOfEmail",
"recordId" : "00Qxx00000skwO",
"value" : "true"
} ]
}
}
Security
To call Consent API, you must have either the View All Data or the Allow User Access to Privacy Data user permission. Requiring a perm
ensures that the System Administrator gives explicit permission. This API accesses org-wide consent data, such as links between records
and the value of consent flags, not just records to which the user ordinarily has access.
Usage
The following table shows how the API responses are determined. If the consulted fields find conflicting consent preferences, the response
returns the least permissive preference. For example, if Contact.HasOptedOutOfEmail is false, but Lead.HasOptedOutOfEmail is true,
the response indicates that you can’t proceed with emailing the user.
When you select email as the action, the API only aggregates consent for records that contain the same email address. If the record ID
specified in the URI is associated with a record that contains a different email address, the consent settings of the associated record aren’t
included in the API response.
Note: When the API compares consent settings across records, it doesn’t incorporate settings from converted leads.
147
Reference Consent
148
Reference Consent
149
Reference Consent
150
Reference Use the Consent API with Customer 360 Audiences
}
}
Required Permissions
To use the Customer 360 Audiences parameters for the Consent API, you must have either the ModifyAllData or the ConsentApiUpdate
user permission. Requiring a perm ensures that the System Administrator gives explicit permission. These parameters write org-wide
consent data, such as links between records and the value of consent flags, which are not usually accessible to non-Admin users.
Syntax
HTTP method
GET
Available since release:
48.0
URI
/services/data/vXX.X/consent/action/action?ids=list_of_ids&mode=CDP
151
Reference Use the Consent API with Customer 360 Audiences
Request parameters
Parameter Description
action May be used with either mode setting. Include with one of the allowed values, followed
by a ‘?’ like this: action/track? parameters associated with each action. That
allowed values for action are:
• portability
• process
• shouldForget
ids Required. Comma-separated list of IDs. The ID can be the record ID or the email address
listed on the record. When mode is set to cdp, the ids value is a string equal to the
Individual ID attribute. This is the email address used to sync consent.
Syntax
HTTP method
PATCH
Available since release
50.0
URI
/services/data/vxx.0/consent/action/action?ids=list_of_ids&mode=CDP
Request parameters
Parameter Description
action May be used with either mode setting. Include with one of the allowed values, followed
by a ‘?’ like this: action/track? parameters associated with each action. The
allowed values for action are:
• portability
152
Reference Use the Consent API with Customer 360 Audiences
Parameter Description
• process
• shouldForget
ids Required. Comma-separated list of IDs. The ID can be the record ID or the email address
listed on the record. When mode is cdp, the ids value is a string equal to the Individual
ID attribute. This is the email address used to sync consent.
mode Optional. Default is normal. Valid values are normal or cdp. If mode is set to cdp, the
only parameters used are ids, action, and blobParam.
status Required. Status of the consent (OptIn, OptOut). Used with the Write API only.
aws_s3_bucket_id Required only when mode is 'cdp' and the action is 'portability'. This parameter must
be passed in as part of the PATCH request body. This parameter is used to pass the S3
bucket location for portability requests to Customer 360 Audiences.
aws_access_key_id Required only when mode is 'cdp' and the action is 'portability'. This parameter must
be passed in as part of the PATCH request body. This parameter is used to pass the S3
bucket access key for portability requests to Customer 360 Audiences.
aws_secret_access_key Required only when mode is 'cdp' and the action is 'portability'. This parameter must
be passed in as part of the PATCH request body. This parameter is used to pass the S3
bucket secret access key for portability requests to Customer 360 Audiences.
aws_s3_folder Required only when mode is 'cdp' and the action is 'portability'. This parameter must
be passed in as part of the PATCH request body. This parameter is used to pass the S3
bucket folder for portability requests to Customer 360 Audiences.
aws_region Required only when mode is 'cdp' and the action is 'portability'. This parameter must
be passed in as part of the PATCH request body. This parameter is used to pass the S3
bucket's aws region for portability requests to Customer 360 Audiences.
{
"aws_s3_bucket_id": "<the AWS s3 bucket id where your data will be exported>",
"aws_access_key_id": "<your AWS access key id>",
"aws_secret_access_key": "<your AWS secret access key>",
"aws_s3_folder": "<your AWS s3 bucket folder where data will be exported>",
"aws_region": "<your AWS region, such as us-west-2>"
}
153
Reference Consent Write
Consent Write
Your users can store consent preferences in different locations. The Consent Write API can update and write consent across multiple
records through a single API call, helping you sync consent across records or populate the new Consent data model. This API is available
with version 48.0 and later.
Consent API writes consent values across the Contact, Contact Point Type Consent, Data Use Purpose, Individual, Lead, Person Account,
and User objects when the records have a lookup relationship or share an email address. This API can also write to the Customer 360
Audiences (CDP) Individual record. The Consent API can't locate records in which the email address field is protected by Platform
Encryption.
Note: For the Spring ‘21 release, the API only takes in a single email address. Any record with a matching email address is updated
based on the parameters set in the API call.
Parameter Description
blobParam Optional. Use to pass information to CDP, such as portability write location. Use only
for mode=cdp. This parameter must be passed in as part of the PATCH request body.
captureDate Optional. The date and time when consent is captured. The default is the date and
time the API call is made.
captureContactPointType Optional. Describes how consent is captured (web, phone, email). Supported values
are:
• email
• phone
• web (default)
captureSource Optional. The source through which consent is captured. The default capture source
is Consent API. Max length 255 characters.
154
Reference Consent Write
Parameter Description
consentName Optional. Use to set the name for any new consent records. Default is: Individual
Name-Datetime (<Name> 2019-03-31T15:47:57). Max length is
255 characters.
createIndividual Optional. Boolean. If set to true and the API call includes an email address that
matches multiple records without an Individual object, then an Individual object is
created. Any consent records with an email address that match the email in the API
call are linked to the new Individual object. If multiple records are found, then any
records not linked to an Individual object is linked to the Individual object found in the
other records. If more than one Individual object is found on the matching records,
then the call is rejected.
doubleOptIn Optional. The date and time that the double opt-in is completed.
effectiveFrom Optional. The date from which consent is effective. The default is the date the API call
is made.
ids Required. The email address used to sync consent. The ID can be the record ID or the
email address listed on the record. When mode=cdp, the ID value is a string equal
to the Individual ID attribute.
individualName Optional. The name of the person in an Individual record. If a name isn’t provided for
a new Individual record, then the local part of the passed-in email address is used. Max
length is 80 characters.
mode Optional. Default is normal. The allowed modes are: normal or cdp. With
mode=cdp, the request is passed to the Customer 360 Audiences data platform to
get or write consent. The mode=cdp parameter only supports the action,
blobParam, and ids parameters.
purposeName Optional. The data use purpose for which consent is provided. Must use an existing
data use purpose that you previously created. If more than one purpose with the same
name exists, only one purpose is selected.
status Required. Status of the consent (OptIn, OptOut, Seen, NotSeen.) If action exists
on an Individual object (for example, tracking or processing), the only valid values are
OptIn and OptOut.
Action
Allowed values are:
• email
• fax
• geotrack
• mailing
• phone
• portability
155
Reference Embedded Service Configuration Describe
• process
• profile
• shouldForget
• social
• solicit
• storePiiElsewhere
• track
• web
Security
To call the Consent Write API, you must have either the ModifyAllData or the ConsentApiUpdate user permission. This API writes org-wide
consent data, such as links between records and the value of consent flags, and not just records to which the user ordinarily has access.
The ConsentApiUpdate user permission grants full write permission to the user during the Consent Write API call.
Usage
All records with the email address listed are updated. If the Create Individual parameter is selected and no Individual record exists, the
API creates an Individual record. If warranted, the API also creates a Contact Point Type Consent and Contact Point Email record.
Example PATCH
URI
/services/data/v51.0/consent/action/<action>?ids=<email-OR-recordID>&status=<optout/optin/seen/notseen>&createIndividual=<true/false>
Request body
{}
Response
{
"<email-OR-recordID>" : {
"result" : "Success",
"edited" : [{
"objectType" : "<Contact, Lead, User, etc.>",
"field" : "<HasOptedOutofFax, DoNotCall,etc>",
"valueOfField" : "<true/false>",
"id" : "<recordID>"
}],
}
}
156
Reference Embedded Service Configuration Describe
Syntax
URI
/services/data/vXX.X/support/embeddedservice/configuration/EmbeddedServiceConfigDeveloperName
Available since release
45.0
Formats
JSON
HTTP methods
GET, HEAD
Authentication
You must be logged in to the account that owns the EmbeddedServiceConfigDeveloperName you are querying.
Request parameters
None
Example
Retrieving the values for the Embedded Service deployment TestOne
/services/data/v51.0/support/embeddedservice/configuration/TestOne
157
Reference Invocable Actions
"quickActionDefinition" : "Snapins_Case_PrechatQuickAction_08hRM00000000RC",
"quickActionType" : "Prechat"
} ],
"enabled" : true,
"fontSize" : "Medium",
"headerBackgroundImg" : "https://google.com/img/headerBgImgUrl.png",
"isOfflineCaseEnabled" : true,
"isQueuePositionEnabled" : true,
"liveChatButton" : "573RM0000004GGf",
"liveChatDeployment" : "572RM0000004CDV",
"offlineCaseBackgroundImg" : "https://google.com/img/offlineBgImgUrl.png",
"prechatBackgroundImg" : "https://google.com/img/prechatBgImgUrl.png",
"prechatEnabled" : true,
"scenario" : "Service",
"smallCompanyLogoImg" : "https://google.com/img/logoImgUrl.png",
"waitingStateBackgroundImg" : "https://google.com/img/bgImgUrl.png"
},
"shouldHideAuthDialog" : false,
"siteUrl" : "https://snapins-15f082fb956-15fbc261d27.stmfa.stm.force.com/napili2"
}
}
Invocable Actions
Represents a standard or custom invocable action.
Use actions to add more functionality to your applications. Choose from standard actions, such as posting to Chatter or sending email,
or create actions based on your company’s needs.
This resource is available in REST API version 32.0 and later.
Syntax
URI
Get a list of endpoints for each action type:
/services/data/vXX.X/actions
Formats
JSON, XML
HTTP Methods
GET, POST
Authentication
Authorization: Bearer token
Parameters
None
Example
Using GET to retrieve a list of general action types for the current organization:
/services/data/v51.0/actions
158
Reference Standard Invocable Actions
Example
Using POST to send a simple email message:
/services/data/v51.0/actions/standard/emailSimple
Standard actions return their name in actionName. The value of actionName varies for custom actions.
For more information about actions, see the Actions Developer Guide.
159
Reference Standard Invocable Actions
Syntax
URI
Get a list of standard actions:
/services/data/vXX.X/actions/standard
Formats
JSON
HTTP Methods
GET, HEAD, POST
Authentication
Authorization: Bearer token
Parameters
None
Notes
For Salesforce Omnichannel Inventory and Salesforce Order Management, you can also call the corresponding Connect REST API
endpoints or Apex ConnectApi methods. For more information, see Salesforce Omnichannel Inventory Resources and Salesforce
Order Management Resources in the Connect REST API Developer Guide, and ConnectApi Namespace in the Apex Developer Guide.
The Post to Chatter action supports the following features using a special format in the body post.
• @mentions using @[<id>]
• Topic links using #[<topicString>]
For example, the string Hi @[005000000000001], check out #[some_topic] is stored appropriately as Hi
@Joe, check out #some_topic where “@Joe” and “#some_topic” are links to the user and topic, respectively.
Examples
Retrieving a list of standard actions for the current organization
/services/data/v51.0/actions/standard
160
Reference Standard Invocable Actions
"name" : "submit",
"type" : "SUBMITAPPROVAL",
"url" : "/services/data/v51.0/actions/standard/submit"
}, {
"label" : "Deactivate Session-Based Permission Set",
"name" : "deactivateSessionPermSet",
"type" : "DEACTIVATE_SESSION_PERM_SET",
"url" : "/services/data/v51.0/actions/standard/deactivateSessionPermSet"
}, {
"label" : "Activate Session-Based Permission Set",
"name" : "activateSessionPermSet",
"type" : "ACTIVATE_SESSION_PERM_SET",
"url" : "/services/data/v51.0/actions/standard/activateSessionPermSet"
}, {
"label" : "Choose Price Book",
"name" : "choosePricebook",
"type" : "CHOOSE_PRICEBOOK",
"url" : "/services/data/v51.0/actions/standard/choosePricebook"
}, {
"label" : "Routing Address Verification",
"name" : "routingAddressVerification",
"type" : "ROUTING_ADDRESS_VERIFICATION",
"url" : "/services/data/v51.0/actions/standard/routingAddressVerification"
}, {
"label" : "Create Customer Contact Request",
"name" : "contactRequestAction",
"type" : "CONTACT_REQUEST_ACTION",
"url" : "/services/data/v51.0/actions/standard/contactRequestAction"
}, {
"label" : "Publish Managed Content Release",
"name" : "managedContentReleasePublish",
"type" : "MANAGED_CONTENT_RELEASE_PUBLISH",
"url" : "/services/data/v51.0/actions/standard/managedContentReleasePublish"
} ]
}
161
Reference Standard Invocable Actions
"type" : "STRING"
}, {
"apexClass" : null,
"byteLength" : 0,
"description" : "Optional. The email recipients specified as a collection of Strings.",
162
Reference Custom Invocable Actions
"required" : true,
"sobjectType" : null,
"type" : "TEXTAREA"
} ],
"label" : "Send Email",
"name" : "emailSimple",
"outputs" : [ ],
"standard" : true,
"targetEntityName" : null,
"type" : "EMAILSIMPLE"
}
Syntax
URI
Get a list of custom actions:
/services/data/vXX.X/actions/custom
Formats
JSON, XML
HTTP Methods
GET, HEAD, POST
Authentication
Authorization: Bearer token
Parameters
None
Notes
Sending email with the emailAlert action counts against your daily email limit for workflows. For more information, see “Daily
Allocations for Email Alerts” in Salesforce Help.
When invoking an Apex action using the POST method and supplying the inputs in the request, only the following primitive types
are supported as inputs:
• Blob
• Boolean
• Date
• Datetime
• Decimal
• Double
• ID
• Integer
• Long
163
Reference List View Describe
• String
• Time
Describe and invoke for an Apex action respect the profile access for the Apex class. If you don’t have access an error is issued.
If you add an Apex action to a flow, and then remove the Invocable Method annotation from the Apex class, a runtime error in the
flow occurs.
When a flow user invokes an autolaunched flow, the active flow version runs. If there’s no active version, the latest version runs.
When a flow admin invokes a flow, the latest version always runs.
If any of these elements are used in a flow, packageable components that reference the elements aren’t automatically included in
the package.
• Apex action
• Email alerts
• Post to Chatter core action
• Quick Action core action
• Send Email core action
• Submit for Approval core action
For example, if you use an email alert, manually add the email template that’s used by that email alert. To deploy the package
successfully, manually add those referenced components to the package.
Example
Retrieving a list of custom actions for the current organization:
/services/data/v51.0/actions/custom
164
Reference List View Describe
Parameters
None
Example:
Retrieving information about a list view
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcBeMAK/describe
-H "Authorization: Bearer token"
165
Reference List View Describe
"sortIndex" : null,
"sortable" : true,
"type" : "phone"
}, {
"ascendingLabel" : "Low to High",
"descendingLabel" : "High to Low",
"fieldNameOrPath" : "Type",
"hidden" : false,
"label" : "Type",
"selectListItem" : "toLabel(Type)",
"sortDirection" : null,
"sortIndex" : null,
"sortable" : true,
"type" : "picklist"
}, {
"ascendingLabel" : "Z-A",
"descendingLabel" : "A-Z",
"fieldNameOrPath" : "Owner.Alias",
"hidden" : false,
"label" : "Account Owner Alias",
"selectListItem" : "Owner.Alias",
"sortDirection" : null,
"sortIndex" : null,
"sortable" : true,
"type" : "string"
}, {
"ascendingLabel" : null,
"descendingLabel" : null,
"fieldNameOrPath" : "Id",
"hidden" : true,
"label" : "Account ID",
"selectListItem" : "Id",
"sortDirection" : null,
"sortIndex" : null,
"sortable" : false,
"type" : "id"
}, {
"ascendingLabel" : null,
"descendingLabel" : null,
"fieldNameOrPath" : "CreatedDate",
"hidden" : true,
"label" : "Created Date",
"selectListItem" : "CreatedDate",
"sortDirection" : null,
"sortIndex" : null,
"sortable" : false,
"type" : "datetime"
}, {
"ascendingLabel" : null,
"descendingLabel" : null,
"fieldNameOrPath" : "LastModifiedDate",
"hidden" : true,
"label" : "Last Modified Date",
"selectListItem" : "LastModifiedDate",
166
Reference List View Results
"sortDirection" : null,
"sortIndex" : null,
"sortable" : false,
"type" : "datetime"
}, {
"ascendingLabel" : null,
"descendingLabel" : null,
"fieldNameOrPath" : "SystemModstamp",
"hidden" : true,
"label" : "System Modstamp",
"selectListItem" : "SystemModstamp",
"sortDirection" : null,
"sortIndex" : null,
"sortable" : false,
"type" : "datetime"
} ],
"id" : "00BD0000005WcBe",
"orderBy" : [ {
"fieldNameOrPath" : "Name",
"nullsPosition" : "first",
"sortDirection" : "ascending"
}, {
"fieldNameOrPath" : "Id",
"nullsPosition" : "first",
"sortDirection" : "ascending"
} ],
"query" : "SELECT name, site, billingstate, phone, tolabel(type), owner.alias,
id, createddate, lastmodifieddate, systemmodstamp FROM Account WHERE CreatedDate =
THIS_WEEK ORDER BY Name ASC NULLS FIRST, Id ASC NULLS FIRST",
"scope" : null,
"sobjectType" : "Account",
"whereCondition" : {
"field" : "CreatedDate",
"operator" : "equals",
"values" : [ "THIS_WEEK" ]
}
}
167
Reference List View Results
Authentication
Authorization: Bearer token
Parameters
Parameter Description
limit The maximum number of records to return, between 1-2000.
The default value is 25.
offset The first record to return. Use this parameter to paginate the
results. The default value is 1.
Example:
Retrieving results from a specific list view
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCNMA0/results
-H "Authorization: Bearer token"
168
Reference List View Results
"sortIndex" : null,
"sortable" : true,
"type" : "string"
}, {
"ascendingLabel" : "9-0",
"descendingLabel" : "0-9",
"fieldNameOrPath" : "Phone",
"hidden" : false,
"label" : "Phone",
"selectListItem" : "Phone",
"sortDirection" : null,
"sortIndex" : null,
"sortable" : true,
"type" : "phone"
}, {
"ascendingLabel" : "Low to High",
"descendingLabel" : "High to Low",
"fieldNameOrPath" : "Type",
"hidden" : false,
"label" : "Type",
"selectListItem" : "toLabel(Type)",
"sortDirection" : null,
"sortIndex" : null,
"sortable" : true,
"type" : "picklist"
}, {
"ascendingLabel" : "Z-A",
"descendingLabel" : "A-Z",
"fieldNameOrPath" : "Owner.Alias",
"hidden" : false,
"label" : "Account Owner Alias",
"selectListItem" : "Owner.Alias",
"sortDirection" : null,
"sortIndex" : null,
"sortable" : true,
"type" : "string"
}, {
"ascendingLabel" : null,
"descendingLabel" : null,
"fieldNameOrPath" : "Id",
"hidden" : true,
"label" : "Account ID",
"selectListItem" : "Id",
"sortDirection" : null,
"sortIndex" : null,
"sortable" : false,
"type" : "id"
}, {
"ascendingLabel" : null,
"descendingLabel" : null,
"fieldNameOrPath" : "CreatedDate",
"hidden" : true,
"label" : "Created Date",
"selectListItem" : "CreatedDate",
169
Reference List View Results
"sortDirection" : null,
"sortIndex" : null,
"sortable" : false,
"type" : "datetime"
}, {
"ascendingLabel" : null,
"descendingLabel" : null,
"fieldNameOrPath" : "LastModifiedDate",
"hidden" : true,
"label" : "Last Modified Date",
"selectListItem" : "LastModifiedDate",
"sortDirection" : null,
"sortIndex" : null,
"sortable" : false,
"type" : "datetime"
}, {
"ascendingLabel" : null,
"descendingLabel" : null,
"fieldNameOrPath" : "SystemModstamp",
"hidden" : true,
"label" : "System Modstamp",
"selectListItem" : "SystemModstamp",
"sortDirection" : null,
"sortIndex" : null,
"sortable" : false,
"type" : "datetime"
} ],
"developerName" : "MyAccounts",
"done" : true,
"id" : "00BD0000005WcCN",
"label" : "My Accounts",
"records" : [ {
"columns" : [ {
"fieldNameOrPath" : "Name",
"value" : "Burlington Textiles Corp of America"
}, {
"fieldNameOrPath" : "Site",
"value" : null
}, {
"fieldNameOrPath" : "BillingState",
"value" : "NC"
}, {
"fieldNameOrPath" : "Phone",
"value" : "(336) 222-7000"
}, {
"fieldNameOrPath" : "Type",
"value" : "Customer - Direct"
}, {
"fieldNameOrPath" : "Owner.Alias",
"value" : "TUser"
}, {
"fieldNameOrPath" : "Id",
"value" : "001D000000JliSTIAZ"
}, {
170
Reference List View Results
"fieldNameOrPath" : "CreatedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "LastModifiedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "SystemModstamp",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
} ]
}, {
"columns" : [ {
"fieldNameOrPath" : "Name",
"value" : "Dickenson plc"
}, {
"fieldNameOrPath" : "Site",
"value" : null
}, {
"fieldNameOrPath" : "BillingState",
"value" : "KS"
}, {
"fieldNameOrPath" : "Phone",
"value" : "(785) 241-6200"
}, {
"fieldNameOrPath" : "Type",
"value" : "Customer - Channel"
}, {
"fieldNameOrPath" : "Owner.Alias",
"value" : "TUser"
}, {
"fieldNameOrPath" : "Id",
"value" : "001D000000JliSVIAZ"
}, {
"fieldNameOrPath" : "CreatedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "LastModifiedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "SystemModstamp",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
} ]
}, {
"columns" : [ {
"fieldNameOrPath" : "Name",
"value" : "Edge Communications"
}, {
"fieldNameOrPath" : "Site",
"value" : null
}, {
"fieldNameOrPath" : "BillingState",
"value" : "TX"
}, {
"fieldNameOrPath" : "Phone",
"value" : "(512) 757-6000"
171
Reference List View Results
}, {
"fieldNameOrPath" : "Type",
"value" : "Customer - Direct"
}, {
"fieldNameOrPath" : "Owner.Alias",
"value" : "TUser"
}, {
"fieldNameOrPath" : "Id",
"value" : "001D000000JliSSIAZ"
}, {
"fieldNameOrPath" : "CreatedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "LastModifiedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "SystemModstamp",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
} ]
}, {
"columns" : [ {
"fieldNameOrPath" : "Name",
"value" : "Express Logistics and Transport"
}, {
"fieldNameOrPath" : "Site",
"value" : null
}, {
"fieldNameOrPath" : "BillingState",
"value" : "OR"
}, {
"fieldNameOrPath" : "Phone",
"value" : "(503) 421-7800"
}, {
"fieldNameOrPath" : "Type",
"value" : "Customer - Channel"
}, {
"fieldNameOrPath" : "Owner.Alias",
"value" : "TUser"
}, {
"fieldNameOrPath" : "Id",
"value" : "001D000000JliSXIAZ"
}, {
"fieldNameOrPath" : "CreatedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "LastModifiedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "SystemModstamp",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
} ]
}, {
"columns" : [ {
"fieldNameOrPath" : "Name",
172
Reference List View Results
"value" : "GenePoint"
}, {
"fieldNameOrPath" : "Site",
"value" : null
}, {
"fieldNameOrPath" : "BillingState",
"value" : "CA"
}, {
"fieldNameOrPath" : "Phone",
"value" : "(650) 867-3450"
}, {
"fieldNameOrPath" : "Type",
"value" : "Customer - Channel"
}, {
"fieldNameOrPath" : "Owner.Alias",
"value" : "TUser"
}, {
"fieldNameOrPath" : "Id",
"value" : "001D000000JliSPIAZ"
}, {
"fieldNameOrPath" : "CreatedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "LastModifiedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "SystemModstamp",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
} ]
}, {
"columns" : [ {
"fieldNameOrPath" : "Name",
"value" : "Grand Hotels and Resorts Ltd"
}, {
"fieldNameOrPath" : "Site",
"value" : null
}, {
"fieldNameOrPath" : "BillingState",
"value" : "IL"
}, {
"fieldNameOrPath" : "Phone",
"value" : "(312) 596-1000"
}, {
"fieldNameOrPath" : "Type",
"value" : "Customer - Direct"
}, {
"fieldNameOrPath" : "Owner.Alias",
"value" : "TUser"
}, {
"fieldNameOrPath" : "Id",
"value" : "001D000000JliSWIAZ"
}, {
"fieldNameOrPath" : "CreatedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
173
Reference List View Results
}, {
"fieldNameOrPath" : "LastModifiedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "SystemModstamp",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
} ]
}, {
"columns" : [ {
"fieldNameOrPath" : "Name",
"value" : "Pyramid Construction Inc."
}, {
"fieldNameOrPath" : "Site",
"value" : null
}, {
"fieldNameOrPath" : "BillingState",
"value" : null
}, {
"fieldNameOrPath" : "Phone",
"value" : "(014) 427-4427"
}, {
"fieldNameOrPath" : "Type",
"value" : "Customer - Channel"
}, {
"fieldNameOrPath" : "Owner.Alias",
"value" : "TUser"
}, {
"fieldNameOrPath" : "Id",
"value" : "001D000000JliSUIAZ"
}, {
"fieldNameOrPath" : "CreatedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "LastModifiedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "SystemModstamp",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
} ]
}, {
"columns" : [ {
"fieldNameOrPath" : "Name",
"value" : "sForce"
}, {
"fieldNameOrPath" : "Site",
"value" : null
}, {
"fieldNameOrPath" : "BillingState",
"value" : "CA"
}, {
"fieldNameOrPath" : "Phone",
"value" : "(415) 901-7000"
}, {
"fieldNameOrPath" : "Type",
174
Reference List View Results
"value" : null
}, {
"fieldNameOrPath" : "Owner.Alias",
"value" : "TUser"
}, {
"fieldNameOrPath" : "Id",
"value" : "001D000000JliSaIAJ"
}, {
"fieldNameOrPath" : "CreatedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "LastModifiedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "SystemModstamp",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
} ]
}, {
"columns" : [ {
"fieldNameOrPath" : "Name",
"value" : "United Oil and Gas Corp."
}, {
"fieldNameOrPath" : "Site",
"value" : null
}, {
"fieldNameOrPath" : "BillingState",
"value" : "NY"
}, {
"fieldNameOrPath" : "Phone",
"value" : "(212) 842-5500"
}, {
"fieldNameOrPath" : "Type",
"value" : "Customer - Direct"
}, {
"fieldNameOrPath" : "Owner.Alias",
"value" : "TUser"
}, {
"fieldNameOrPath" : "Id",
"value" : "001D000000JliSZIAZ"
}, {
"fieldNameOrPath" : "CreatedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "LastModifiedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "SystemModstamp",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
} ]
}, {
"columns" : [ {
"fieldNameOrPath" : "Name",
"value" : "United Oil and Gas, Singapore"
}, {
175
Reference List View Results
"fieldNameOrPath" : "Site",
"value" : null
}, {
"fieldNameOrPath" : "BillingState",
"value" : "Singapore"
}, {
"fieldNameOrPath" : "Phone",
"value" : "(650) 450-8810"
}, {
"fieldNameOrPath" : "Type",
"value" : "Customer - Direct"
}, {
"fieldNameOrPath" : "Owner.Alias",
"value" : "TUser"
}, {
"fieldNameOrPath" : "Id",
"value" : "001D000000JliSRIAZ"
}, {
"fieldNameOrPath" : "CreatedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "LastModifiedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "SystemModstamp",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
} ]
}, {
"columns" : [ {
"fieldNameOrPath" : "Name",
"value" : "United Oil and Gas, UK"
}, {
"fieldNameOrPath" : "Site",
"value" : null
}, {
"fieldNameOrPath" : "BillingState",
"value" : "UK"
}, {
"fieldNameOrPath" : "Phone",
"value" : "+44 191 4956203"
}, {
"fieldNameOrPath" : "Type",
"value" : "Customer - Direct"
}, {
"fieldNameOrPath" : "Owner.Alias",
"value" : "TUser"
}, {
"fieldNameOrPath" : "Id",
"value" : "001D000000JliSQIAZ"
}, {
"fieldNameOrPath" : "CreatedDate",
"value" : "Fri Aug 01 21:15:46 GMT 2014"
}, {
"fieldNameOrPath" : "LastModifiedDate",
176
Reference List Views
List Views
Returns the list of list views for the specified sObject, including the ID and other basic information about each list view. You can also get
basic information for a specific list view by ID.
This resource is available in REST API version 32.0 and later.
URI
Get a list of list views:
/services/data/vXX.X/sobjects/sobjectType/listviews
Get basic information about one list view:
177
Reference List Views
/services/data/vXX.X/sobjects/sobjectType/listviews/listViewID
Available since release
31.0
Formats
JSON, XML
HTTP Methods
GET
Authentication
Authorization: Bearer token
Parameters
None
Example:
Retrieving a list of list views for the Account object
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/listviews
-H "Authorization: Bearer token"
178
Reference List Views
"url" : "/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcC6MAK"
}, {
"describeUrl" :
"/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCEMA0/describe",
"developerName" : "RecentlyViewedAccounts",
"id" : "00BD0000005WcCEMA0",
"label" : "Recently Viewed Accounts",
"resultsUrl" :
"/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCEMA0/results",
"soqlCompatible" : true,
"url" : "/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCEMA0"
}, {
"describeUrl" :
"/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCFMA0/describe",
"developerName" : "AllAccounts",
"id" : "00BD0000005WcCFMA0",
"label" : "All Accounts",
"resultsUrl" :
"/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCFMA0/results",
"soqlCompatible" : true,
"url" : "/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCFMA0"
}, {
"describeUrl" :
"/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCNMA0/describe",
"developerName" : "MyAccounts",
"id" : "00BD0000005WcCNMA0",
"label" : "My Accounts",
"resultsUrl" :
"/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCNMA0/results",
"soqlCompatible" : true,
"url" : "/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCNMA0"
} ],
"nextRecordsUrl" : null,
"size" : 6,
"sobjectType" : "Account"
}
179
Reference Support Knowledge with REST API
"url" : "/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcBeMAK"
}
Syntax
The root endpoint for all Knowledge support APIs that can be open to guest users.
Available since release
38.0
Method
GET
Formats
JSON, XML
Authentication
OAuth accesstoken
Endpoint
/services/data/vXX.X/support
HTTP headers
Accept: Optional. Can be either application/json or application/xml.
Input
None
Output
The following resources are related to Knowledge.
{
"dataCategoryGroups" : "/services/data/vXX.X/support/dataCategoryGroups",
"knowledgeArticles" : "/services/data/vXX.X/support/knowledgeArticles"
:
}
IN THIS SECTION:
Data Category Groups
Get data category groups that are visible to the current user.
180
Reference Data Category Groups
Syntax
Available since release
38.0
Method
GET
Formats
JSON, XML
Authentication
OAuth accesstoken
Endpoint
/services/data/vXX.X/support/dataCategoryGroups
HTTP headers
Accept: Optional. Can be either application/json or application/xml.
Accept-language: Optional. Language to translate the categories. Any ISO-639 language abbreviation, and an ISO-3166 country
code subtag in the HTTP Accept-Language header. Only one language accepted. If no language specified, the non-translated labels
are returned.
Input:
string sObjectName: Required. KnowledgeArticleVersion only.
boolean topCategoriesOnly: Optional. Defaults to true
• True returns only the top level categories.
• False returns the entire tree.
Output:
A list of the active data category groups that are visible to the current user in the site context. Returns id, name, label, and their top
level categories or the entire data category group tree that are visible to the current user. The labels must be translated to the given
language if they are available.
• Data Category Group List
181
Reference Data Category Groups
This payload lists the active root Data Category Groups that can be used in other requests to return the data categories and
articles related to it.
{
"categoryGroups": [ Data Category Group, ....],
}
Note: Returns only the active groups that are associated to the given entity (by sObjectName). Only
KnowledgeArticleVersion is supported.
Note: The URL property is a pre-calculated path to the unique resource representing this data category, in this case it is
a Data Category Detail API.
Example
Input
/services/data/v51.0/support/dataCategoryGroups?sObjectName=KnowledgeArticleVersion
Output
{
"categoryGroups" : [ {
"label" : "Doc",
"name" : "Doc",
"objectUsage" : "KnowledgeArticleVersion",
"topCategories" : [ {
"childCategories" : null,
"label" : "All",
"name" : "All",
"url" :
182
Reference Data Category Detail
"/services/data/v51.0/support/dataCategoryGroups/Doc/dataCategories/All?sObjectName=KnowledgeArticleVersion"
} ]
}, {
"label" : "Manual",
"name" : "Manual",
"objectUsage" : "KnowledgeArticleVersion",
"topCategories" : [ {
"childCategories" : null,
"label" : "All",
"name" : "All",
"url" :
"/services/data/v51.0/support/dataCategoryGroups/Manual/dataCategories/All?sObjectName=KnowledgeArticleVersion"
} ]
} ]
}
Usage
Salesforce Knowledge must be enabled in your organization. This resource can be used in API version 38.0 and later. Use the language
code format used in Which Languages Does Salesforce Support?.
Only the user’s visible data categories are returned. A user might be able to see several sub trees in the category group, therefore, the
top categories that are visible to the user in each group are returned.
Syntax
Available since release
38.0
Method
GET
Formats
JSON, XML
Authentication
OAuth accesstoken
Endpoint
/services/data/vXX.X/support/dataCategoryGroups/group/dataCategories/category
HTTP headers
Accept: Optional. Can be either application/json or application/xml.
Accept-language: Optional. Language to translate the categories. Any ISO-639 language abbreviation, and an ISO-3166 country
code subtag in the HTTP Accept-Language header. Only one language accepted. If no language specified, the non-translated labels
are returned.
183
Reference Data Category Detail
Input:
string sObjectName: Required. KnowledgeArticleVersion only.
Output:
Details of the category and a list of child categories (name, label, etc.).
• Data Category Detail
Used for situations where the hierarchical representation of data categories is important. The child property contains a list of
child data categories.
{
"name": String, // the unique name of the category
"label": String, // returns the translated version if it is available
"url": URL,
"childCategories": [ Data Category Summary, ....],
}
Note: If the category isn’t visible to the current user the return is empty.
Example
Input
/services/data/v51.0/support/dataCategoryGroups/Doc/dataCategories/All?sObjectName=KnowledgeArticleVersion
Output
{
"childCategories" : [ {
"childCategories" : null,
"label" : "Help",
"name" : "Help",
"url" :
"/services/data/v51.0/support/dataCategoryGroups/Doc/dataCategories/Help?sObjectName=KnowledgeArticleVersion"
}, {
"childCategories" : null,
"label" : "QA",
"name" : "QA",
"url" :
"/services/data/v51.0/support/dataCategoryGroups/Doc/dataCategories/QA?sObjectName=KnowledgeArticleVersion"
} ],
"label" : "All",
"name" : "All",
"url" :
"/services/data/v51.0/support/dataCategoryGroups/Doc/dataCategories/All?sObjectName=KnowledgeArticleVersion"
}
Usage
Salesforce Knowledge must be enabled in your organization. This resource can be used in API version 38.0 and later. Use the language
code format used in Which Languages Does Salesforce Support?.
184
Reference Articles List
Articles List
Get a page of online articles for the given language and category through either search or query.
Syntax
Available since release
38.0
Method
GET
Formats
JSON, XML
Authentication
OAuth access token
Endpoint
[prefix]/support/knowledgeArticles
HTTP headers
Accept: Optional. Can be either application/json or application/xml.
Accept-language: Required. The article must be an active language in the user’s organization
• If the language code isn’t valid, an error message is returned: “The language code is not valid or not supported by Knowledge.”
• If the language code is valid, but not supported by Knowledge, then an error message is returned: “Invalid language code. Check
that the language is included in your Knowledge language settings."
Input:
string q: Optional, Performs an SOSL search. If the query string is null, empty, or not given, an SOQL query runs.
The characters ? and * are used for wildcard searches. The characters (, ), and " are used for complex search terms. See
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_find.htm.
string channel: Optional, defaults to user’s context. For information on channel values, see Valid channel values.
• App: Visible in the internal Salesforce Knowledge application
• Pkb: Visible in the public knowledge base
• Csp: Visible in the Customer Portal
• Prm: Visible in the Partner Portal
string categories in map json format {“group1”:”category1”,”group2”:”category2”,...} )
Optional, defaults to None. Category group must be unique in each group:category pair, otherwise you get
ARGUMENT_OBJECT_PARSE_ERROR. There is a limit of three data category conditions, otherwise you get
INVALID_FILTER_VALUE.
string queryMethod values are: AT, BELOW, ABOVE, ABOVE_OR_BELOW. Only valid when categories are specified,
defaults to ABOVE_OR_BELOW.
string sort: Optional, a sortable field name LastPublishedDate, CreatedDate, Title, ViewScore. Defaults
to LastPublishedDate for query and relevance for search.
Note: When sorting on ViewScore it is only available for query, not search, and no pagination is supported. You only get
one page of results.
string order: Optional, either ASC or DESC, defaults to DESC. Valid only when sort is valid.
185
Reference Articles List
Note: The API supports paging. Each page of responses includes a URL to its page, as well as the URL to the next page
of articles.
Note: if the user input parameter has the default value, the API does not show this parameter in either
currentPageUrl or nextPageUrl.
• Article Summary
A summary of an article used in a list of article responses. It shares similar properties to the Article Detail representation, as one
is a superset of the other.
{
"id": Id, // articleId
"articleNumber": String,
"articleType": String, // apiName of the article type, available in API v44.0
and later
"title": String,
"urlName": String, // available in API v44.0 and later
"summary": String,
"url": URL, // to the Article Detail API
"viewCount": Int, // view count in the interested channel
"viewScore": double (in xxx.xxxx precision), // view score in the interested
channel.
"upVoteCount": int, // up vote count in the interested channel.
"downVoteCount": int, // down vote count in the interested channel.
"lastPublishedDate": Date // last publish date in ISO8601 format
"categoryGroups": [ Data Category Group, …. ]}
The “url” property always points to the Article Details resource endpoint. For information on valid channel values, see the channel
parameter description
186
Reference Articles List
Note: The outputs of Data Category Group and Data Category Summary in Article List API are different from the Data
Category Groups API.
Example
Input
/services/data/v51.0/support/knowledgeArticles?sort=ViewScore&channel=Pkb&pageSize=3
HTTP Headers:
Content-Type: application/json; charset=UTF-8
Accept: application/json
Accept-Language: en-US
Output
{
"articles" : [ {
"articleNumber" : "000001002",
"categoryGroups" : [ ],
"downVoteCount" : 0,
"id" : "kA0xx000000000BCAQ",
"lastPublishedDate" : "2015-02-25T02:07:18Z",
"summary" : "With this online Chinese input tool, you can type Chinese characters
through your web browser without installing any Chinese input software in your system.
The Chinese online input tool uses the popular Pin Yin input method. It is a fast and
convenient tool to input Chinese on English OS environments.",
"title" : "Long text test",
"upVoteCount" : 0,
"url" : "/services/data/v51.0/support/knowledgeArticles/kA0xx000000000BCAQ",
"viewCount" : 4,
"viewScore" : 100.0
}, {
"articleNumber" : "000001004",
"categoryGroups" : [ ],
"downVoteCount" : 0,
"id" : "kA0xx000000000LCAQ",
"lastPublishedDate" : "2016-06-21T21:11:02Z",
"summary" : "The number of characters required for complete coverage of all these
languages' needs cannot fit in the 256-character code space of 8-bit character encodings,
requiring at least a 16-bit fixed width encoding or multi-byte variable-length encodings.
\r\n\r\nAlthough CJK encodings have common character sets, the encodings often used to
represent them have been developed separately by different East Asian governments and
software companies, and are mutually incompatible. Unicode has attempted, with some
controversy, to unify the character sets in a process known as Han unification.\r\n\r\nCJK
187
Reference Articles List
Usage
Salesforce Knowledge must be enabled in your organization. This resource can be used in API version 38.0 and later. The Custom File
Field is not supported because it returns a link to a binary stream. Use the language code format used in Which Languages Does Salesforce
Support?.
• If channel isn’t specified, the default value is determined by the type of user.
– Pkb for a guest user
– Csp for a Customer Portal user
– Prm for a Partner Portal user
– App for any other type of user
188
Reference Articles Details
Articles Details
Get all online article fields, accessible to the user.
Syntax
Available since release
38.0
Method
GET
Formats
JSON, XML
Authentication
OAuth access token
Endpoint
/services/data/vXX.X/support/knowledgeArticles/articleId
/services/data/vXX.X/support/knowledgeArticles/articleUrlName Available in API v44.0 and later
HTTP headers
Accept: Optional. Can be either application/json or application/xml.
Accept-language: Required. The article must be an active language in the user’s organization
• If the language code isn’t valid, an error message is returned: “The language code is not valid or not supported by Knowledge.”
• If the language code is valid, but not supported by Knowledge, then an error message is returned: “Invalid language code. Check
that the language is included in your Knowledge language settings."
Input:
string channel: Optional, defaults to user’s context. For information on channel values, see Valid channel Values.
• App: Visible in the internal Salesforce Knowledge application
• Pkb: Visible in the public knowledge base
• Csp: Visible in the Customer Portal
• Prm: Visible in the Partner Portal
boolean updateViewStat: Optional, defaults to true. If true, API updates the view count in the given channel as well as the
total view count.
boolean isUrlName: Optional, defaults to false. If true, indicates that the last portion of the endpoint is a URL name instead of an
article ID. Available in API v44.0 and later
Output:
The detailed fields of the article, if the article is online and visible to the current user.
• Article Detail
Full detail of an article, with complete metadata and layout-driven fields used for display of an article. It includes all the same
properties as an Article Summary representation.
{
"id": Id, // articleId,
"articleNumber": String,
"articleType": String, // apiName of the article type, available in API
189
Reference Articles Details
• User Summary
{
"id": String
"isActive": boolean // true/false
"userName": String // login name
"firstName": String
"lastName": String
"email": String
"url": String // to the chatter user detail url:
/services/data/xx.x/chatter/users/{userId}, for guest user, it will return null.
}
• Article Field
An individual field of article information, which is listed in an Article Detail in the order required by the administrator’s layout.
{
"type": Enum, // see the Notes
"name": String, // In API v43.0 and earlier, the developer name. In
API v44.0 and later, the API name.
190
Reference Articles Details
Example
Input
/services/data/v51.0/support/knowledgeArticles/kA0xx000000000LCAQ
HTTP Headers:
Content-Type: application/json; charset=UTF-8
Accept: application/json
Accept-Language: en-US
Output
{
"allViewCount" : 17,
"allViewScore" : 100.0,
"appDownVoteCount" : 0,
"appUpVoteCount" : 0,
"appViewCount" : 17,
"appViewScore" : 100.0,
"articleNumber" : "000001004",
"categoryGroups" : [ ],
"createdBy" : {
"email" : "user@company.com",
"firstName" : "Test",
"id" : "005xx000001SvoMAAS",
"isActive" : true,
"lastName" : "User",
"url" : "/services/data/v51.0/chatter/users/005xx000001SvoMAAS",
"userName" : "admin@salesforce.org"
},
"createdDate" : "2016-06-21T21:10:54Z",
"cspDownVoteCount" : 0,
"cspUpVoteCount" : 0,
"cspViewCount" : 0,
"cspViewScore" : 0.0,
"id" : "kA0xx000000000LCAQ",
"lastModifiedBy" : {
"email" : "user@company.com",
"firstName" : "Test",
"id" : "005xx000001SvoMAAS",
"isActive" : true,
"lastName" : "User",
"url" : "/services/data/v51.0/chatter/users/005xx000001SvoMAAS",
"userName" : "admin@salesforce.org"
},
"lastModifiedDate" : "2016-06-21T21:11:02Z",
"lastPublishedDate" : "2016-06-21T21:11:02Z",
"layoutItems" : [ {
"label" : "Out of Date",
"name" : "IsOutOfDate",
191
Reference Articles Details
"type" : "CHECKBOX",
"value" : "false"
}, {
"label" : "sample",
"name" : "sample",
"type" : "PICK_LIST",
"value" : null
}, {
"label" : "Language",
"name" : "Language",
"type" : "PICK_LIST",
"value" : "en_US"
}, {
"label" : "MyNumber",
"name" : "MyNumber",
"type" : "NUMBER",
"value" : null
}, {
"label" : "My File",
"name" : "My_File",
"type" : "FILE",
"value" : null
} ],
"pkbDownVoteCount" : 0,
"pkbUpVoteCount" : 0,
"pkbViewCount" : 0,
"pkbViewScore" : 0.0,
"prmDownVoteCount" : 0,
"prmUpVoteCount" : 0,
"prmViewCount" : 0,
"prmViewScore" : 0.0,
"summary" : "The number of characters required for complete coverage of all these
languages' needs cannot fit in the 256-character code space of 8-bit character encodings,
requiring at least a 16-bit fixed width encoding or multi-byte variable-length encodings.
\r\n\r\nAlthough CJK encodings have common character sets, the encodings often used to
represent them have been developed separately by different East Asian governments and
software companies, and are mutually incompatible. Unicode has attempted, with some
controversy, to unify the character sets in a process known as Han unification.\r\n\r\nCJK
character encodings should consist minimally of Han characters p",
"title" : "Test Images",
"url" : "/services/data/v51.0/support/knowledgeArticles/kA0xx000000000LCAQ",
"versionNumber" : 7
}
Usage
Salesforce Knowledge must be enabled in your organization. This resource can be used in API version 38.0 and later. The Custom File
Field is not supported because it returns a link to a binary stream. Use the language code format used in Which Languages Does Salesforce
Support?.
A lookup custom field is visible to guest users depending on the lookup entity type. For example, User is visible, but Case and Account
are not visible. Following standard fields are not visible to a guest user, even if they are in the layout:
• archivedBy
192
Reference Parameterized Search
• isLatestVersion
• translationCompletedDate
• translationImportedDate
• translationExportedDate
• versionNumber
• visibleInInternalApp
• visibleInPKB
• visibleToCustomer
• visbileToPartner
• If channel isn’t specified, the default value is determined by the type of user.
– Pkb for a guest user
– Csp for a Customer Portal user
– Prm for a Partner Portal user
– App for any other type of user
Parameterized Search
Executes a simple RESTful search using parameters instead of a SOSL clause. Indicate parameters in a URL in the GET method. Or, use
POST for more complex JSON searches.
Syntax
URI
/services/data/vXX.X/parameterizedSearch/?q=searchString
Formats
JSON, XML
HTTP Method
GET, POST
193
Reference Parameterized Search
Authentication
Authorization: Bearer token
Required Global Parameters
Name Description
q A search string that is properly URL-encoded.
dataCategories dataCategoriesFilter[] POST If an organization uses Salesforce Knowledge articles or answers, filters all search
results based on one or more data categories.
When using dataCategories, specify a Salesforce Knowledge article or answer
type with sobjects and the required parameters.
For example:
{
"q":"Acme",
"fields":["id", "title"],
"sobjects":[{"name":"KnowledgeArticleVersion",
"where":"language='en_US' and publishstatus='draft'"}],
"dataCategories":[
{"groupName" : "location__c", "operator":"below",
"categories":["North_America__c"]}
194
Reference Parameterized Search
]
}
defaultLimit string GET, Single value. The maximum number of results to return for each sobject (GET)
POST or sobjects (POST) specified.
The maximum defaultLimit is 2000.
At least one sobject must be specified.
GET example:
defaultLimit=10&sobject=Account&sobject=Contact.
When an sobject limit is specified using sobject.limit=value, such
as Account.limit=10, this parameter is ignored for that object.
division string GET, Single value. Filters search results based on the division field.
POST For example in the GET method, division=global.
Specify a division by its name rather than ID.
All searches within a specific division also include the global division.
fields string GET Comma-separated list of one or more fields to return in the response for each
sobject specified. At least one sobject must be specified at the global level.
For example: fields=id&sobject=Account&sobject=Contact.
The global fields parameter is overridden when sobject are specified using
sobject.fields=field names. For example,
Contact.fields=id,FirstName,LastName would override the global
setting of just returning the id.
If unspecified, then the search results contain the IDs of records matching all fields
for the specified object.
Functions
The following optional functions can be used within the fields parameter.
• toLabel: Translates response field value into the user’s language. For example,
Lead.fields=id,toLabel(Status). This function requires extra
setup.
• convertCurrency: Converts response currency fields to the user’s currency.
For example,
Opportunity.fields=id,convertCurrency(Amount). This
function requires extra setup. Multi-currency must be enabled for your org.
• format: Applies localized formatting to standard and custom number, date,
time, and currency fields. For example,
Opportunity.fields=id,format(Amount).
Aliasing is support within fields for toLabel, convertCurrency, and
format. In addition, aliasing is required when the query includes the same field
195
Reference Parameterized Search
fields string[] POST Array of one or more fields to return in the response for each sobjects specified.
At least one sobjects must be specified at the global level.
For example:
{
"q":"Acme",
"fields":["Id", "Name", "Phone"],
"sobjects":[{"name": "Account"},
{"name": "Contact", "fields":["Id",
"FirstName", "LastName"]},
{"name": "Lead"}]
}
196
Reference Parameterized Search
in string GET, Scope of fields to search. If you specify one or more scope values, the fields are
POST returned for all found objects.
Use one of the following values:
• ALL
• NAME
• EMAIL
• PHONE
• SIDEBAR
This clause doesn't apply to articles, documents, feed comments, feed items, files,
products, and solutions. If any of these objects are specified, the search is not limited
to specific fields; all fields are searched.
metadata string GET, Specifies if metadata should be returned in the response. No metadata is returned
POST by default. To include metadata in the response, use the LABELS value, which
returns the display label for the fields returned in search results. For example:
?q=Acme&metadata=LABELS
offset string GET, Single value. The starting row offset into the result set returned.
POST The maximum offset is 2000.
197
Reference Parameterized Search
overallLimit string GET, Single value. The maximum number of results to return across all sobject
POST parameters specified.
The maximum overallLimit is 2000.
pricebookId string GET, Single value. Filters product search results by a price book ID for only the Product2
POST object. The price book ID must be associated with the product that you’re searching
for. For example,
?q=laptop&sobject=product2&pricebookId=01sxx0000002MffAAE
snippet string GET, The target length (maximum number of snippet characters) to return in Salesforce
POST Knowledge article, case, case comment, feed, feed comment, idea, and idea
comment search results. The snippet parameter displays contextual excerpts
and highlights the search term for each article in the search results. Snippet results
are used to differentiate matches to the search term in article search results. The
target length can be from 50 to 1000 characters.
Snippet and highlights are generated from email, text, and text area (long and rich)
fields. Snippets aren’t displayed for partially matching searches or if the user doesn’t
have access to the field that contains the snippet. Snippets are only displayed when
20 or fewer results are returned on a page.
At least one of the following sobject values must be specified.
• To search a specific article type, use the article type name with the suffix
__kav.
• To search all article types, use KnowledgeArticleVersion.
• To search case, case comment, feed, feed comment, idea, and idea comment
types, use Case, CaseComment, FeedItem, FeedComment, Idea,
and IdeaComment.
For example, q=tourism&sobject=Case&snippet=500.
sobject string GET Objects to return in the response. Must be a valid object type.
You can use multiple sobject values, such as
sobject=Account&sobject=Contact.
If unspecified, then the search results contain the IDs of all objects.
sobjects sobjectsFilter[] POST Objects to return in the response. Must contain valid object types. Use with the
required parameters.
For example:
{
"q":"Acme",
"fields":["id", "title"],
"sobjects":[{"name":"Solution__kav",
198
Reference Parameterized Search
{"name":"FAQ__kav",
"where":"language='en_US' and publishstatus='draft'"}]
If unspecified, then the search results contain the IDs of all objects.
spellCorrection boolean GET, Specifies whether spell correction is enabled for a user’s search. When set to true,
POST spell correction is enabled for searches that support spell correction. The default
value is true.
For example:
q=Acme&sobject=Account&Account.fields=id&spellCorrection=true
updateTracking string GET, Specifies a value of true to track keywords that are used in Salesforce Knowledge
POST article searches only.
If unspecified, the default value of false is applied.
updateViewStat string GET, Specifies a value of true to update an article’s view statistics. Valid only for
POST Salesforce Knowledge article searches.
If unspecified, the default value of false is applied.
dataCategoriesFilter[] Parameters
Parameters must be specified in the order presented in the table (groupName, operator, categories).
199
Reference Parameterized Search
orderBy string Controls the field order of the results using the following syntax "orderBy" : "field
{ASC|DESC} [NULLS_{FIRST|LAST}]"
For example:
{
...
"sobjects":[ {"name": "Account", "fields":["Id", "name"], "orderBy":
"Name DESC Nulls_last"}]
...
}
where string Filter search results for this object by specific field values.
For example, where : conditionExpression. Here the conditionExpression of the
WHERE clause uses the following syntax: fieldExpression [logicalOperator
fieldExpression2 ... ].
Add multiple field expressions to a condition expression by using logical and comparison operators.
limit string Specifies the maximum number of rows that are returned for the sobject.
For example, Account.limit=10.
orderBy string Controls the field order of the results using the following syntax orderBy = field {ASC|DESC}
[NULLS_{FIRST|LAST}]
For example: Account.orderBy=Name
• ASC: ascending. Default.
• DESC: descending.
200
Reference Portability
where string Filter search results for this object by specific field values.
For example, Account.where = conditionExpression. Here the conditionExpression
of the WHERE clause uses the following syntax: fieldExpression [logicalOperator
fieldExpression2 ... ].
Add multiple field expressions to a condition expression by using logical and comparison operators. For
example, KnowledgeArticleVersion.where=publishstatus='online' and
language='en_US'.
{
"q":"Smith",
"fields" : ["id", "firstName", "lastName"],
"sobjects":[{"fields":["id", "NumberOfEmployees"],
"name": "Account",
"limit":20},
{"name": "Contact"}],
"in":"ALL",
"overallLimit":100,
"defaultLimit":10
}
Portability
The Portability API compiles customer information across objects and fields that you identified when creating a portability policy in
Salesforce Customer 360 Privacy Center. You can locate your customers’ personally identifiable information (PII) across multiple records
when using API version 50.0 and later. Data portability satisfies your customers’ right to obtain a copy of their PII that is kept in your
organization’s platform. To meet privacy regulations, such as the General Data Protection Regulation (GDPR), data portability requests
must be fulfilled within one month of when the request is made.
Execute the Portability API with the POST method to aggregate your data subject’s PII found in the Account, Contact, Individual, Lead,
Person, and User objects into one file. You receive a response with a URL to download the file, a policy file ID, and information on the
objects and fields you selected when creating the policy. Use the policy file ID to execute the Portability API with the GET method.
Execute the Portability API with the GET method to see the status of your POST method execution request. Use the policy file ID from
the POST method response to execute the GET method. The GET method response contains this information:
Value Description
policyFileStatus The status of the file being compiled. Values are: In Progress, Complete, or Failed.
201
Reference Portability
Value Description
policyFileURL The URL to a servlet, where you download the file after it's compiled.
policyFileID The ID of the file being compiled, which is returned in the POST method response. The
ID is 15 characters.
Note: Starting with the Spring ‘21 release, Customer 360 Privacy Center automatically deletes files generated by Portability API
after 60 days. You receive a reminder seven days before a file is deleted.
Required Permissions
To use the Portability API, you must have the ModifyAllData or PrivacyDataAccess user permission. Ensure that your Salesforce admin
has granted you these permissions.
Syntax
URI
/services/data/vXX.X/consent/dsr/rtp/execute
Available since release
50.0
Formats
JSON
HTTP methods
POST, GET
POST Request parameters
Parameter Description
dataSubjectId The ID of the customer making the request. The ID is 15 or 18 characters long, and
found in the Account, Contact, Individual, Lead, Person, and User objects.
policyName The name of an active policy. This contains the object in the dataSubjectId parameter.
Parameter Description
policyFileId The ID of the file being compiled, which is returned in the POST method response. The
ID is 15 characters.
POST Example
URI
/services/data/v50.0/consent/dsr/rtp/execute
202
Reference Process Approvals
Request Body
{
“dataSubjectID”:”<root ID>”,
“policyName”:”<policyName>”
}
Response
{
“status" : "SUCCESS",
"warnings" : [ ],
"result" : {
"policyFileStatus" : "In Progress",
"policyFileUrl" :
"https://na45.stmfb.stm.salesforce.com/servlet/policyFileDownload?file=0jeS70000004CBO",
"policyFileId" : "0jeS70000004CBO"
}
}
GET Example
URI
/services/data/v50.0/consent/dsr/rtp/execute?policyFileId=0jeS70000004CBO
Response
{
“status" : "SUCCESS",
"warnings" : [ ],
"result" : {
"policyFileStatus" : "Failed",
"policyFileUrl" :
"https://na45.stmfb.stm.salesforce.com/servlet/policyFileDownload?file=0jeS70000004CBO",
"policyFileId" : "0jeS70000004CBO"
}
}
Process Approvals
Returns a list of all approval processes. Can also be used to submit a particular record if that entity supports an approval process and one
has already been defined. Records can be approved and rejected if the current user is an assigned approver. When using a POST request
to do bulk approvals, the requests that succeed are committed and the requests that don’t succeed send back an error.
203
Reference Process Approvals
Syntax
URI
To return a list of the approvals, the URI is: /services/data/vXX.X/process/approvals/
Available since release
30.0
Formats
JSON, XML
HTTP methods
GET, HEAD, POST
Authentication
Authorization: Bearer token
Request parameters
None required
Request body
The request body contains an array of process requests that contain the following information:
comments string The comment to add to the history step associated with this request.
nextApproverIds ID[] If the process requires specification of the next approval, the ID of the user to be
assigned the next request.
skipEntryCriteria boolean Determines whether to evaluate the entry criteria for the process (true) or not
(false) if the process definition name or ID isn’t null. If the process definition name
or ID isn’t specified, this argument is ignored, and standard evaluation is followed
based on process order. By default, the entry criteria isn’t skipped if it’s not set
by this request.
Response body
The response contains an array of process results that contain the following information:
instanceId ID The ID of the ProcessInstance associated with the object submitted for processing.
204
Reference Process Rules
newWorkItemIds ID[] Case-insensitive IDs that point to ProcessInstanceWorkitem items (the set of
pending approval requests)
Examples
• See Get a List of All Approval Processes.
• See Submit a Record for Approval.
• See Approve a Record.
• See Reject a Record.
• See Bulk Approvals.
Process Rules
Returns a list of all active workflow rules. If a rule has actions, the actions will be listed under the rule. Can also be used to trigger all
workflow rules that are associated with a specified record. The actions for a rule are only fired if the rule’s criteria is met. When using a
POST request, if anything fails, the whole transaction is rolled back.
Cross-object workflow rules cannot be invoked using the REST API.
Syntax
URI
To get a list of the workflow rules or to trigger one or more workflow rules, the URI is:
/services/data/vXX.X/process/rules/
To get the rules for a particular object: /services/data/vXX.X/process/rules/sObjectName
To get the metadata for a particular rule:
/services/data/vXX.X/process/rules/sObjectName/workflowRuleId
Available since release
30.0
Formats
JSON, XML
HTTP methods
HEAD, GET, POST
Authentication
Authorization: Bearer token
Request parameters
None required
205
Reference Product Schedules
Request body
The request body contains an array of context IDs:
Examples
• See Get a List of Process Rules.
• See Get a Particular Process Rule.
• See Trigger Process Rules.
Product Schedules
Work with revenue and quantity schedules for opportunity products. Establish or reestablish a product schedule with multiple installments
for an opportunity product. Delete all installments in a schedule.
This resource is available in REST API version 43.0 and later.
In API version 46.0 and later, established and re-established schedules support custom fields, validation rules, and Apex triggers. Deleting
all schedules now also fires delete triggers.
URI
/services/data/vXX.X/sobjects/OpportunityLineItem/OpportunityLineItemId/OpportunityLineItemSchedules
Formats
JSON, XML
HTTP Method
GET, PUT, DELETE
Authentication
Authorization: Bearer token
Parameters
Parameter Description
type The type of the schedule. Required when establishing
OpportunityLineItemSchedules. Valid values include Quantity,
Revenue, or Both.
quantityScheduleType The type of the quantity schedule, if the product has one. Valid
values are Divide or Repeat.
206
Reference Product Schedules
Parameter Description
quantityScheduleInstallmentsNumber If the product has a quantity schedule, the number of
installments. Can be an integer from 1 to 150.
revenueScheduleType The type of the revenue schedule, if the product has one. Valid
values are Divide or Repeat.
Example:
Establish both quantity and revenue schedules for an opportunity product; establish a revenue schedule only; establish
a quantity schedule only.
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/OpportunityLineItem/00kR0000001WJJAIA4/OpportunityLineItemSchedules
-H "Authorization: Bearer token"
{
"type": “Revenue”,
"revenue": 100,
"revenueScheduleType": “Divide”,
"revenueScheduleInstallmentPeriod": “Quarterly”,
"revenueScheduleInstallmentsNumber": 10,
"revenueScheduleStartDate": "2018-09-15"
}
207
Reference Query
{
"type": “Quantity”,
"quantity": 10,
"quantityScheduleType": "Repeat",
"quantityScheduleInstallmentPeriod": “Daily”,
"quantityScheduleInstallmentsNumber": 150,
"quantityScheduleStartDate": "2020-09-15",
}
Query
This API resource executes the specified SOQL query.
When a SOQL query is executed, up to 2,000 records can be returned at a time in a synchronous request. If the number of results exceeds
this limit, the response contains only the first set of results and a query identifier, contained in the response’snextRecordsUrl field.
The identifier can be used in another request to retrieve the next batch of records.
URI
/services/data/vXX.X/query/?q=SOQL query
For retrieving query performance feedback without executing the query:
/services/data/vXX.X/query/?explain=SOQL query
For retrieving query performance feedback on a report or list view:
/services/data/vXX.X/query/?explain=report or list view ID
For retrieving more query results if the initial results are o large:
/services/data/vXX.X/query/query identifier
Formats
JSON, XML
HTTP Method
GET
Authentication
Authorization: Bearer token
Parameters
Parameter Description
q A SOQL query. To create a valid URI, replace spaces with a plus sign + in the query string. For example:
SELECT+Name+FROM+MyObject. If the SOQL query string is invalid, a MALFORMED_QUERY
response is returned.
explain A SOQL query to get performance feedback. Use explain instead of q to get a response that
details how Salesforce processes your query. Use this feedback to further optimize your queries. To
get feedback on how Salesforce processes a report or list view, use a report or list view ID in place of
the query string.
The explain parameter is available in API version 30.0 and later.
208
Reference Query
Parameter Description
Note: Using explain with the Query resource is a beta feature. There’s no support for
this beta feature. For more information, contact Salesforce.
If the SOQL query string is invalid, a MALFORMED_QUERY response is returned. If the report or list
view ID is invalid, an INVALID_ID response is returned.
Response body
For a query using the q parameter, the response contains an array of query result records. For a query using the explain parameter,
the response contains one or more query plans that can be used to execute the query, report, or list view. The plans are sorted from
most optimal to least optimal. Each plan has the following information:
fields string[] If the leading operation type is Index, these values are the index fields used
for the query. Otherwise, the value is null.
leadingOperationType string The primary operation type that can use to optimize the query. This type can
be one of these values:
• Index—The query uses an index on the query object.
• Other—The query uses optimizations internal to Salesforce.
• Sharing—The query uses an index based on the user’s sharing rules. If
there are sharing rules that limit which records are visible to the current
user, those rules can optimize the query.
• TableScan—The query scans all records for the query object, and doesn’t
use an index.
notes feedback note[] An array of one or more feedback notes. Each note contains:
• description— A detailed description of a part of the optimization.
This description can include information on optimizations that can’t be
used and why they can’t used.
• fields— An array of one or more fields used for the optimization.
• tableEnumOrId— The table name for the fields used for the
optimization.
This response field is available in API version 33.0 and later.
relativeCost number The cost of this query compared to the SOQL selective query threshold. A
value greater than 1.0 means the query isn’t selective. For more information
on selective queries, see More Efficient SOQL Queries in the Apex Code
Developer's Guide.
sobjectCardinality number The approximate count of all records in your organization for the query object.
209
Reference Customer 360 Audiences Query Profile Parameters
SOQL Limitations
The following queries are not supported for use with Customer 360 Audiences:
• SOQL Subqueries
• SELECT clause: aggregate functions
• SELECT clause: date functions
• SOQL HAVING clause
Sample Queries
Use Case Queries
Data Preview: Get Email Click Events SELECT SubscriberKey__c, EngagementChannel__c, EmailName__c,
Examine data that has been ingested SubjectLine__c FROM sfmc_email_engagement_click_{EID}__dll LIMIT =100
into a data lake object.
210
Reference QueryAll
QueryAll
This API resource executes the specified SOQL query. Unlike the Query resource, QueryAll returns records that are deleted because of a
merge or delete. QueryAll also returns information about archived task and event records. QueryAll is available in API version 29.0 and
later.
When a SOQL query is executed, up to 2,000 records can be returned at a time in a synchronous request. If the number of results exceeds
this limit, the response contains only the first set of results and a query identifier, contained in the response’snextRecordsUrl field.
The identifier can be used in another request to retrieve the next batch of records. Though the nextRecordsUrl has query in
the URL, it still provides remaining results from the initial QueryAll request. The remaining results include deleted records that matched
the initial query.
URI
/services/data/vXX.X/queryAll/?q=SOQL query
If the initial number of records exceeds the default limit, use the query identifier to retrieve more query results:
/services/data/vXX.X/queryAll/query identifier
Formats
JSON, XML
211
Reference Quick Actions
HTTP Method
GET
Authentication
Authorization: Bearer token
Parameters
Parameter Description
q A SOQL query. To create a valid URI, replace spaces with a plus sign + in the query
string. For example: SELECT+Name+FROM+MyObject.
Quick Actions
Returns a list of global actions and object-specific actions. This resource is available in REST API version 28.0 and later. When working
with actions, also refer to sObject Quick Actions.
URI
/services/data/vXX.X/quickActions/
Formats
JSON, XML
HTTP Method
HEAD, GET, POST
Authentication
Authorization: Bearer token
Parameters
None required
Considerations
Add all required fields to an object before you create a quick action for that object. If you add a required field after creating a quick
action, the field won’t appear in the quick action’s describe results. Then, when the quick action runs, the field won’t be available
and an error occurs for the missing field. If you don’t want the required field to appear in the quick action’s layout, set a default value
for the field.
Example usage for getting global quick actions
curl https://yourInstance.salesforce.com/services/data/v51.0/quickActions/ -H
"Authorization: Bearer token"
212
Reference Recent List Views
curl https://yourInstance.salesforce.com/services/data/v51.0/quickActions/CreateContact
-H 'Authorization: Bearer access_token -H "Content-Type: application/json" -d
@newcontact.json'
Example:
Retrieving recent list views for the Account object
curl
https://yourInstance.salesforce.com/services/data/v51.0/sobjects/Account/listviews/recent
-H "Authorization: Bearer token"
213
Reference Recently Viewed Items
}, {
"describeUrl" :
"/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcBeMAK/describe",
"developerName" : "NewThisWeek",
"id" : "00BD0000005WcBeMAK",
"label" : "New This Week",
"resultsUrl" :
"/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcBeMAK/results",
"soqlCompatible" : true,
"url" : "/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcBeMAK"
}, {
"describeUrl" :
"/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCFMA0/describe",
"developerName" : "AllAccounts",
"id" : "00BD0000005WcCFMA0",
"label" : "All Accounts",
"resultsUrl" :
"/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCFMA0/results",
"soqlCompatible" : true,
"url" : "/services/data/v51.0/sobjects/Account/listviews/00BD0000005WcCFMA0"
} ],
"nextRecordsUrl" : null,
"size" : 3,
"sobjectType" : "Account"
}
Parameter Description
limit An optional limit that specifies the maximum number of records to be returned. If this
parameter is not specified, the default maximum number of records returned is the
maximum number of entries in RecentlyViewed, which is 200 records per object.
214
Reference Record Count
Example
• For an example of retrieving a list of recently viewed items, see View Recently Viewed Records on page 65.
• For an example of setting records as recently viewed, see Mark Records as Recently Viewed on page 66.
Record Count
Lists information about object record counts in your organization.
This resource is available in REST API version 40.0 and later for API users with the “View Setup and Configuration” permission. The returned
record count is approximate, and does not include the following types of records:
• Deleted records in the recycle bin.
• Archived records.
URI
/services/data/vXX.X/limits/recordCount?sObjects=Object List
Formats
JSON, XML
HTTP Method
GET
Authentication
Authorization: Bearer token
Parameters
Parameter Description
sObjects A comma-delimited list of object names. If a listed object is not found in the org, it is
ignored and not returned in the response.
This parameter is optional. If this parameter is not provided, the resource returns record
counts for all objects in the org.
Response body
Record Count Response Body
Example
Example request to get record counts for Account and Contact:
/services/data/v51.0/limits/recordCount?sObjects=Account,Contact
215
Reference Record Count Response Body
} ]
}
JSON example
{
"sObjects" : [ {
"count" : 3,
"name" : "Account"
}, {
"count" : 10,
"name" : "Contact"
} ]
}
JSON example
{
"count" : 10,
"name" : "Contact"
}
216
Reference Relevant Items
Relevant Items
Gets the current user’s most relevant items. Relevant items include records for objects in the user’s global search scope and also most
recently used (MRU) objects.
Relevant items include up to 50 of the most recently viewed or updated records for each object in the user’s global search scope.
Note: The user’s global search scope includes the objects the user interacted with most in the last 30 days, including objects the
user pinned from the search results page in the Salesforce Classic.
Then, the resource finds more recent records for each most recently used (MRU) object until the maximum number of records, which
is 2,000, is returned.
This resource only accesses the relevant item information. Modifying the list of relevant items is not currently supported.
This resource is available in API version 35.0 and later.
URI
/services/data/vXX.X/sobjects/relevantItems
Formats
JSON
HTTP Method
GET
Authentication
Authorization: Bearer token
Parameters
Parameter Description
lastUpdatedId Optional. Compares the entire current list of relevant items to a previous version, if
available. Specify the lastUpdatedId value returned in a previous response.
sobjects Optional. To scope the results to a particular object or set of objects, specify the name
for one or more sObjects.
sobject.lastUpdatedId Optional. Compares the current list of relevant items for this particular object to a
previous version, if available. Specify the lastUpdatedId value returned in a
previous response.
Note: You can only specify this parameter for the sObjects specified in the
sobjects parameter.
Response header
The response contains headers unique to this resource.
217
Reference Retrieve Knowledge Language Settings
Response body
The response contains an array of records for each object returned, including the following information for each record.
key ID The first 3 characters of the sObject’s ID that indicates the object type.
lastUpdatedId string A unique code that can be used in subsequent calls to compare the
results for the new result set with the current results for this object.
Example
See View Relevant Items.
Syntax
URI
/services/data/vXX.X/knowledge Management/settings
Available since release
31.0
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
None required
218
Reference Search
Request parameters
None
Usage
Salesforce Knowledge must be enabled in your organization. This resource can be used in API version 31.0 and later. It retrieves the
Knowledge language settings, including the default knowledge language and a list of supported Knowledge language information.
Search
Executes the specified SOSL search. The search string must be URL-encoded.
For more information on SOSL see the SOQL and SOSL Reference.
Syntax
URI
/services/data/vXX.X/search/?q=SOSL search string
Formats
JSON, XML
HTTP Method
GET
219
Reference Search Scope and Order
Authentication
Authorization: Bearer token
Parameters
Parameter Description
q A SOSL statement that is properly URL-encoded.
Example
See Search for a String on page 52.
Syntax
URI
/services/data/vXX.X/search/scopeOrder
Formats
JSON, XML
HTTP Method
GET
Authentication
Authorization: Bearer token
Example
See Get the Default Search Scope and Order.
Syntax
URI
/services/data/vXX.X/search/layout/?q=Comma delimited object list
220
Reference Lightning Toggle Metrics
Formats
JSON, XML
HTTP Method
GET
Authentication
Authorization: Bearer token
Response format
format String The type of date field, such as the date only
or date and time. Only date related types
are specified; otherwise, null.
Example
Get Search Result Layouts for Objects
Syntax
URI
/services/data/vXX.X/sobjects/LightningToggleMetrics
Available since release
44.0
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
SOQL query.
221
Reference Lightning Usage by App Type
Request parameters
Parameter Description
UserId The user ID.
Example
This query returns the total number of switches to Salesforce Classic:
SELECT sum(RecordCount) Total FROM LightningToggleMetrics WHERE MetricsDate = LAST_MONTH
AND Action = 'switchToAloha'
Usage
Use this object with the following APIs:
• Platform
• Metadata API
• Tooling API
Syntax
URI
/services/data/vXX.X/sobjects/LightningUsageByAppTypeMetrics
Available since release
44.0
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
SOQL query.
222
Reference Lightning Usage by Browser
Request parameters
Parameter Description
AppExperience The app used:
• Salesforce Mobile
• Lightning Experience
Example
This query returns the daily active users by profile for Mobile:
SELECT MetricsDate,user.profile.name,COUNT_DISTINCT(user.id) Total FROM
LightningUsageByAppTypeMetrics WHERE MetricsDate = LAST_N_DAYS:30 AND AppExperience =
'Salesforce Mobile' GROUP BY MetricsDate,user.profile.name
Usage
Use this object with the following APIs:
• Platform
• Metadata API
• Tooling API
Syntax
URI
/services/data/vXX.X/sobjects/LightningUsageByBrowserMetrics
Available since release
44.00
Formats
JSON, XML
HTTP methods
GET
223
Reference Lightning Usage by Page
Authentication
Authorization: Bearer token
Request body
SOQL Query.
Request parameters
Parameter Description
Browser The browser used.
RecordCountEPT Number of records for a page/browser where the valid EPT was recorded.
Example
This query returns browser distribution details, for the last 3 months.
SELECT CALENDAR_MONTH(MetricsDate) MetricsDate, Browser Browser, SUM(TotalCount) Total
FROM LightningUsageByBrowserMetrics WHERE MetricsDate = Last_N_Months:3 AND (NOT Browser
like 'OTHER%') GROUP BY CALENDAR_MONTH(MetricsDate),Browser
Usage
Use this object with the following APIs:
• Platform
• Metadata API
• Tooling API
224
Reference Lightning Usage by Page
Syntax
URI
/services/data/vXX.X/sobjects/LightningUsageByPageMetrics
Available since release
44.00
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
SOQL Query.
Parameter Description
EptBin3To5 Number of times that a page loaded between 3-5 seconds.
RecordCountEPT Number of records for a page/user where the valid EPT was recorded.
Example
This example returns the top 10 most visited pages and how many times each page was visited.
SELECT TotalCount FROM LightningUsageByPageMetrics ORDER BY PageName ASC NULLS FIRST LIMIT
10
Usage
Use this object with the following APIs:
• Platform
225
Reference Lightning Usage by FlexiPage
• Metadata API
• Tooling API
Syntax
URI
/services/data/vXX.X/sobjects/LightningUsageByFlexiPageMetrics
Available since release
44.00
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
SOQL query.
Request parameters
Parameter Description
FlexiPageNameOrId Namespace and file name, or Page ID of FlexiPage files.
FlexiPageType The FlexiPage type. For example, record details are displayed using
RecordPage" type.
RecordCountEPT Number of records for a FlexiPage type, where the valid EPT was recorded.
Example
This query returns the top 10 most viewed custom pages over the past 7 days.
SELECT FlexiPageNameOrId FlexiPageNameOrId, SUM(TotalCount) Total FROM
LightningUsageByFlexiPageMetrics WHERE MetricsDate = Last_N_DAYS:7 AND (NOT FlexiPageNameOrId
= 'unknown unknown') AND (NOT FlexiPageNameOrId = 'unknown | unknown') GROUP BY
FlexiPageNameOrId ORDER BY SUM(TotalCount) Desc Limit 10
226
Reference Lightning Exit by Page Metrics
Usage
Use this object with the following APIs:
• Platform
• Metadata API
• Tooling API
Syntax
URI
/services/data/vXX.X/sobjects/LightningExitByPageMetrics
Available since release
44.0
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
SOQL query.
Request parameters
Parameter Description
MetricsDate The date the data was recorded.
PageName Current Page from which User Switched from Lightning to Aloha
Example
This query returns the top 10 pages that were switched from Lightning Experience to Salesforce Classic over the past 7 days.
SELECT PageName PageName, SUM(RecordCount) Total FROM LightningExitByPageMetrics WHERE
MetricsDate = Last_N_DAYS:7 GROUP BY PageName ORDER BY SUM(RecordCount) Desc Limit 10
227
Reference Salesforce Scheduler Resources
Usage
Use this object with the following APIs:
• Platform
• Metadata API
• Tooling API
IN THIS SECTION:
Scheduling
Returns a list of available Salesforce Scheduler REST resources and corresponding URIs.
Get Appointment Slots
Returns a list of available appointment time slots for a resource based on given work type group and territories.
Get Appointment Candidates
Returns a list of available service resources (appointment candidates) based on work type group and service territories.
Request Bodies
Response Bodies
SEE ALSO:
Connect REST API Developer Guide: Lightning Scheduler Resources
Scheduling
Returns a list of available Salesforce Scheduler REST resources and corresponding URIs.
Syntax
URI
/services/data/vXX.X/scheduling/
Available since release
45.0
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
228
Reference Get Appointment Slots
Note: The Lightning Platform REST API supports OAuth 2.0 (an open protocol to allow secure API authorization). See Authorize
Apps with OAuth in the Salesforce Help for more details.
Response Body
Execution of a successful request returns names of resources and their URIs as key-value pairs.
JSON Example
{
"getAppointmentCandidates" : "/services/data/v51.0/scheduling/getAppointmentCandidates",
"getAppointmentSlots" : "/services/data/v51.0/scheduling/getAppointmentSlots"
}
Syntax
URI
/services/data/vXX.X/scheduling/getAppointmentSlots
Available since release
45.0
Formats
JSON, XML
HTTP methods
POST
Authentication
Authorization: Bearer token
Note: The Lightning Platform REST API supports OAuth 2.0 (an open protocol to allow secure API authorization). See Authorize
Apps with OAuth in Salesforce Help for more details.
Request body
endTime No String The latest time that a time slot can end (inclusive).
workTypeGroupId Required if String The ID of the work type group containing the work types that are
workType being performed.
is not
given.
229
Reference Get Appointment Slots
territoryIds Yes String[] List of IDs of service territories, where the work that is being
requested is performed.
requiredResourceIds Yes String[] List of resource IDs that must be available during the time slot.
Note: To determine the required fields in your request body, consider the following points:
• Provide either workTypeGroupId or workType in your request body, but not both
• If workType is given, then you must provide either id or durationInMinutes, but not both.
• If id of the workType is given, the rest of workType fields are optional.
Response Body
Execution of a successful request returns the response body containing a list of available time slots.
Examples
Request Body Example
Using workTypeGroupId:
{
"startTime" : "2019-01-23T00:00:00.000Z",
"endTime" : "2019-02-30T00:00:00.000Z",
"workTypeGroupId" : "0VSB0000000KyjBOAS",
"accountId" : "001B000000qAUAWIA4",
230
Reference Get Appointment Slots
"territoryIds" : ["0HhB0000000TO9WKAW"],
"schedulingPolicyId" : "0VrB0000000KyjB",
"requiredResourceIds" : ["0HnB0000000TO8gKAK"]
}
Using workType:
{
"startTime" : "2019-01-23T00:00:00.000Z",
"endTime" : "2019-02-30T00:00:00.000Z",
"workType" : {
"id" : "08qRM00000003fkYAA"
},
"requiredResourceIds" : ["0HnB0000000TO8gKAK"],
"territoryIds" : ["0HhRM00000003OZ0AY"]
"accountId" : "001B000000qAUAWIA4",
"schedulingPolicyId" : "0VrB0000000KyjB"
}
Prerequisites
The appointment time slots are determined based on your Salesforce Scheduler data model configurations. Here are some prerequisites
that you can consider while setting up data.
231
Reference Get Appointment Slots
• Set up Salesforce Scheduler before making your requests. This setup includes creating or configuring Service Resources, Service
Territory Members, Work Type Groups, Work Types, Work Type Group Members, and Service Territory Work Types. See Set Up
Salesforce Scheduler for more information.
• Configure a work type mapped for each territory in the request body via Service Territory Work Type. Map the same work type to
the work type group, via work type group member.
Parameter Description
Timeframe Start Time slots sooner than current time + Timeframe Start are not
returned.
Timeframe End Time slots later than current time + Timeframe End are not returned.
Block Time Before Appointment The time period before the appointment is considered as unavailable.
Block Time After Appointment The time period after the appointment is considered as unavailable.
Operating Hours The overlap of all operating hours from the account, work type, service territory, and
service territory member are considered while determining time slots. For more
information, see Manage Operating Hours in Salesforce Scheduler.
• Only the time slots within the period of 31 days are returned.
• The earliest and latest appointment slots are calculated using the following guidelines:
– The earliest appointment slot = maximum of
• Service Territory Member Start Date
• current time + Time frame Start
• Start Time passed in the request body
Note: If asset scheduling is enabled, you can provide an asset-based service resource in requiredResourceIds to
retrieve available timeslots for the asset resource.
232
Reference Get Appointment Candidates
Syntax
URI
/services/data/vXX.X/scheduling/getAppointmentCandidates
Available since release
45.0
Formats
JSON, XML
HTTP methods
POST
Authentication
Authorization: Bearer token
Note: The Lightning Platform REST API supports OAuth 2.0 (an open protocol to allow secure API authorization). See Authorize
Apps with OAuth in the Salesforce Help for more details.
Request body
filterByResources No String[] A comma-separated list of service resource IDs. API returns only
eligible service resources that are both in the list and in the selected
service territory sorted by the order in which the resource IDs are
passed. Available in API version 51.0 and later.
territoryIds Yes String[] List of service territory IDs, where the work that is being requested
is performed.
startTime No String The earliest time that a time slot can begin (inclusive). Defaults to
the current time of the request, if empty. You can also use a time
from the past.
233
Reference Get Appointment Candidates
Note: To determine the required fields in your request body, consider the following points:
• Provide either workTypeGroupId or workType in your request body, but not both
• If workType is given, then you must provide either id or durationInMinutes, but not both.
• If id of the workType is given, the rest of workType fields are optional.
Response Body
Execution of a successful request returns the response body containing a list of available appointment resources.
Examples
Request Body Example
Using workTypeGroupId:
{
"startTime" : "2019-01-23T00:00:00.000Z",
"endTime" : "2019-02-30T00:00:00.000Z",
"workTypeGroupId" : "0VSB0000000KyjBOAS",
"accountId" : "001B000000qAUAWIA4",
"territoryIds" : ["0HhB0000000TO9WKAW"],
"schedulingPolicyId" : "0VrB0000000KyjB"
}
Using workType:
{
"startTime" : "2019-01-23T00:00:00.000Z",
"endTime" : "2019-02-30T00:00:00.000Z",
"workType" : {
"id" : "08qRM00000003fkYAA"
},
"territoryIds" : ["0HhRM00000003OZ0AY"],
"accountId" : "001B000000qAUAWIA4",
234
Reference Get Appointment Candidates
"schedulingPolicyId" : "0VrB0000000KyjB"
}
Prerequisites
The appointment time slots are determined based on your Salesforce Scheduler data model configurations. Here are some prerequisites
that you can consider while setting up data.
• Set up Salesforce Scheduler before making requests. This setup includes creating or configuring Service Resources, Service Territory
Members, Work Type Groups, Work Types, Work Type Group Members, and Service Territory Work Types. See Set Up Salesforce
Scheduler for more information.
• The territory type of the Service Territory Member must be either Primary, Secondary, or Relocation. The Primary and Relocation
territory types are considered the same.
• The territory type of the Service Territory Member must be either Primary, Secondary, or Relocation. The Primary and Relocation
territory types are considered the same.
235
Reference Request Bodies
Note: If asset scheduling is enabled, the response also includes asset-based candidates.
Request Bodies
To perform a POST, PATCH, or PUT request, create a request body formatted in either XML or JSON. This chapter lists the request bodies.
IN THIS SECTION:
Work Type
Details about the type of work to be performed.
Skill Requirement
List of skills that are required to complete a particular task for a work type.
Work Type
Details about the type of work to be performed.
236
Reference Response Bodies
skillRequirements Skill Requirement[] No List of skills that are required to complete a particular task
for a work type.
Note: Provide either Id or durationInMinutes in the request body, but not both.
Skill Requirement
List of skills that are required to complete a particular task for a work type.
SkillLevel String No The level of the skill required. Skill levels can range from
zero to 99.99. Depending on your business needs, you might
want the skill level to reflect years of experience, certification
levels, or license classes.
Response Bodies
Successful execution of a request to a Salesforce Scheduler resource can return a response body either in JSON or XML format. For
example, the request to get appointment time slots returns a list of available time slots for a selection of work type group and territories.
IN THIS SECTION:
Time Slots
Describes the result of Get Appointments Slots request.
Candidates
Describes the result of Get Appointments Candidates request.
Time Slots
Describes the result of Get Appointments Slots request.
List of time slots available for each territory.
territoryId String The service territory associated with this time slot.
237
Reference Search for Records Suggested by Autocomplete and Instant
Results
Candidates
Describes the result of Get Appointments Candidates request.
List of available service resources.
Syntax
URI
/services/data/vXX.X/search/suggestions?q=search_string&sobject=object_types
Available since release
32.0
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
238
Reference Search for Records Suggested by Autocomplete and Instant
Results
Request body
None required
Request parameters
Parameter Description
fields Optional. Used for creating lookup queries. Specify multiple fields using a
comma-separated list. Specifies which lookup fields to be returned in the response.
dynamicFields Optional. Available in API version 48.0 and later. Used to return additional dynamic
fields. Specify multiple options using a comma-separated list. For example, if
dynamicFields=secondaryField then each suggested record in the results
contains an additional field besides Id and Name (or Title) based on the next
eligible field in the search layout.
groupId Optional. Specifies one or more unique identifiers of one or more groups that the
question to return was posted to. Specify multiple groups using a comma-separated
list. This parameter is only applicable when the parameter type equals question.
Don’t use with the userId.
ignoreUnsupportedSObjects Optional. Specifies what to do if unsupported objects are included in the request. If
false and an unsupported object is included, an error is returned. If true and an
unsupported object is included, the object is ignored and no error is returned. See the
Unsupported Objects section for reference. The default is false.
limit Optional. Specifies the maximum number of suggested records to return. If a limit isn’t
specified, 5 records are returned by default. If there are more suggested records than
the limit specified, the response body’s hasMoreResults property is true.
networkId Optional. Specifies one or more unique identifiers for the Experience Cloud sites that
the question to return is associated to. Specify multiple sites using a comma-separated
list. This parameter is only applicable when the parameter type equals question
or parameter sobject equals user.
q Required. The user’s search query string, properly URL-encoded. Suggestions are
returned only if the user’s query string meets the minimum length requirements: one
character for queries in Chinese, Japanese, Korean, and Thai; three characters for all
other languages. Query strings that exceed the maximum length of 255 characters (or
200 consecutive characters without a space break) return an error.
sobject Required. The objects that the search is scoped to, such as Account or offer__c.
If the sobject value is feedItem, it is required to have the type parameter
with a value of question.
Specify up to 10 objects with a comma-separated list. For example:
sobject=Account,Contact,Lead. To take advantage of this feature, activate
the CrossObjectTypeahead permission.
To specify the specific fields to return by object, use the following syntax with multiple
fields in a comma-separated list. The sobject is lowercase.
sobject=sobject.fields=fields
239
Reference Search for Records Suggested by Autocomplete and Instant
Results
Parameter Description
For example:
&sobject=Account,Contact,Lead&account.fields=Website,Phone
&contact.fields=Phone
topicId Optional. Specifies the unique identifier of the single topic that the question to return
was tagged as. This parameter is only applicable when the parameter type equals
question.
type Required when the sobject value is feedItem. Including this parameter for all
other sobject values doesn’t affect the query. Specifies that the type of Feed is
questions. Valid value: question.
userId Optional. Specifies one or more unique identifiers of one or more users who authored
the question to return. Specify multiple users using a comma-separated list. This
parameter is only applicable when the parameter type equals question. Don’t use
with the groupId.
useSearchScope Optional. Available in API version 40.0 and later. The default value is false. If false,
the objects specified in the request are used to suggest records. If true, in addition
to the objects specified in the request, the user's search scope is used to suggest records.
The search scope is the list of objects a user uses most frequently.
• If the request doesn’t specify an object, use useSearchScope=true.
• If useSearchScope=true and the user's search scope is empty, the default
search scope is used to suggest records.
• Only the first 10 objects are used to suggest records.
• Objects specified in the sobject parameter are prioritized over objects in the
user's search scope.
• Values for the ignoreUnsupportedSObjects parameter aren’t applied
to the objects in the search scope.
This example uses only the search scope.
.../search/suggestions?q=Acme&useSearchScope=true
This example uses the search scope and the Account object.
.../search/suggestions?q=Acme&sobject=Account&useSearchScope=true
where Optional. A filter that follows the same syntax as the SOQL WHERE clause. URLs encode
the expression.
Use the clause for an object, or globally for all compatible objects. An example of an
object-specific clause is:
account.where=name%20LIKE%20%27Smith%25%27. An example of a
global clause is: where=name%20LIKE%20%27Smith%25%27. The parameter
must be lower case. Any object-specific where clauses override the global where
clause. You can’t use this parameter for the Question object.
240
Reference Search for Records Suggested by Autocomplete and Instant
Results
Parameter Description
To specify multiple entities, see the following example. This feature is available in
version 38.0 and later.
...search/suggestions?q=Smith
&sobject=Account,Contact,KnowledgeArticleVersion,CollaborationGroup,Topic,FeedItem
Usage
The suggestions resource returns records when the record’s name field includes the exact text in the search string. The last term in the
search string can match the beginning of a word. Records that contain the search string within a word aren’t considered a match.
Note: If the user’s search query contains quotation marks or wildcards, those symbols are automatically removed from the query
string in the URI.
Example: The text string national u is treated as national u* and returns “National Utility”, “National Urban Company”,
and “First National University”.
Element Description
Attributes The record’s object type and the URL for accessing the record.
Also includes the requested lookup fields’ values. For example, if you requested
fields=Id,Name, the result would include the ID and name.
241
Reference Search for Records Suggested by Autocomplete and Instant
Results
Element Description
Name (or Title) The record’s Name field. In the absence of a standard Name field, the Title field is used
for these objects:
• Dashboard
• Idea
• IdeaTheme
• Note
• Question
In the absence of a standard Name or Title field, the main identifying field is used. For
example, in cases, the Case Number is used.
242
Reference Search for Records Suggested by Autocomplete and Instant
Results
243
Reference Search Suggested Article Title Matches
</autoSuggestResults>
<autoSuggestResults type="Account"
url="/services/data/v51.0/sobjects/Account/001xx000003DHscAAG">
<Id>001xx000003DHscAAG</Id>
<Name>National Urban Technology Center</Name>
</autoSuggestResults>
<hasMoreResults>true</hasMoreResults>
<meta>
<nameFields>
<entityApiName>Account</entityApiName>
<fieldApiName>Name</fieldApiName>
</nameFields>
<nameFields>
<entityApiName>ContentDocument</entityApiName>
<fieldApiName>Title</fieldApiName>
</nameFields>
</meta>
</suggestions>
Unsupported Objects
The suggestions resource supports all searchable objects except the following.
• ContentNote
• Event
• External objects
• FeedComment
• FeedPost
• IdeaComment
• Pricebook2
• Reply
• TagDefinition
• Task
Syntax
URI
/services/data/vXX.X/search/suggestTitleMatches?q=searchString
&language=articleLanguage&publishStatus=articlePublicationStatus
Available since release
30.0
244
Reference Search Suggested Article Title Matches
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
None required
Request parameters
Parameter Description
articleTypes Optional. Three-character ID prefixes indicating the desired article types. You can specify
multiple values for this parameter in a single REST call, by repeating the parameter
name for each value. For example, articleTypes=ka0&articleTypes=ka1.
categories Optional. The name of the data category group and name of the data category for
desired articles, expressed as a JSON mapping. You can specify multiple data category
group and data category pairs in this parameter. For example,
categories={"Regions":"Asia","Products":"Laptops"}.
Characters in the URL might need to be encoded. For this example,
categories=%7B%22Regions%22%3A%22Asia
%22%2C%22Products%22%3A%22Laptops%22%7D.
channel Optional. The channel where the matching articles are visible. Valid values:
• AllChannels–Visible in all channels the user has access to
• App–Visible in the internal Salesforce Knowledge application
• Pkb–Visible in the public knowledge base
• Csp–Visible in the Customer Portal
• Prm–Visible in the Partner Portal
If channel isn’t specified, the default value is determined by the type of user.
• Pkb for a guest user
• Csp for a Customer Portal user
• Prm for a Partner Portal user
• App for any other type of user
If channel is specified, the specified value may not be the actual value requested,
because of certain requirements.
• For guest, Customer Portal, and Partner Portal users, the specified value must match
the default value for each user type. If the values don’t match or AllChannels
is specified, then App replaces the specified value.
• For all users other than guest, Customer Portal, and Partner Portal users:
– If Pkb, Csp, Prm, or App are specified, then the specified value is used.
– If AllChannels is specified, then App replaces the specified value.
245
Reference Search Suggested Article Title Matches
Parameter Description
language Required. The language of the user’s query. Specifies the language that matching
articles are written in.
limit Optional. Specifies the maximum number of articles to return. If there are more
suggested articles than the limit specified, the response body’s hasMoreResults
property is true.
q Required. The user’s search query string, properly URL-encoded. Suggestions are
returned only if the user’s query string meets the minimum length requirements: one
character for queries in Chinese, Japanese, and Korean, and three characters for all
other languages. Query strings exceeding the maximum length of 250 characters return
an error.
246
Reference Search Suggested Queries
Usage
Salesforce Knowledge must be enabled in your organization. The user must have the “View Articles” permission enabled. The articles
suggested include only the articles the user can access, based on the data categories and article types the user has permissions to view.
The Suggest Article Title Matches resource is designed to return display-ready data about likely relevant articles. Articles are suggested
if their titles contain the entire query string, except stopwords, such as “a,” “for,” and “the.”
For example, a search for Backpacking for desert returns the article, “Backpacking in the desert.”
Note: Articles with titles that include stopwords from the query string, such as “Backpacking for desert survival” in this example,
appear before matching articles with titles that don’t include the stopwords.
Stopwords at the end of the query string are treated as search terms.
Note: If the user’s search query contains quotation marks or wildcards, those symbols are automatically removed from the query
string in the URI along with any other special characters.
If the number of suggestions returned exceeds the limit specified in the request, the end of the response contains a field called
hasMoreResults. Its value is true if the suggestions returned are only a subset of the suggestions available, and false otherwise.
Syntax
URI
/services/data/vXX.X/search/suggestSearchQueries?q=searchString
&language=languageOfQuery
Available since release
30.0
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
None required
Request parameters
Parameter Description
channel Optional. Specifies the Salesforce Knowledge channel where the article can be viewed.
Valid values:
• AllChannels–Visible in all channels the user has access to
247
Reference Search Suggested Queries
Parameter Description
• App–Visible in the internal Salesforce Knowledge application
• Pkb–Visible in the public knowledge base
• Csp–Visible in the Customer Portal
• Prm–Visible in the Partner Portal
If channel isn’t specified, the default value is determined by the type of user.
• Pkb for a guest user
• Csp for a Customer Portal user
• Prm for a Partner Portal user
• App for any other type of user
If channel is specified, the specified value may not be the actual value requested,
because of certain requirements.
• For guest, Customer Portal, and Partner Portal users, the specified value must match
the default value for each user type. If the values don’t match or AllChannels
is specified, then App replaces the specified value.
• For all users other than guest, Customer Portal, and Partner Portal users:
– If Pkb, Csp, Prm, or App are specified, then the specified value is used.
– If AllChannels is specified, then App replaces the specified value.
limit Optional. Specifies the maximum number of suggested searches to return. If there are
more suggested queries than the limit specified, the response body’s
hasMoreResults property is true.
q Required. The user’s search query string, properly URL-encoded. Suggestions are
returned only if the user’s query string meets the minimum length requirements: one
character for queries in Chinese, Japanese, and Korean, and three characters for all
other languages. Query strings exceeding the maximum length of 250 characters return
an error.
248
Reference Salesforce Surveys Translation Resources
"hasMoreResults" : false
}
Usage
Salesforce Knowledge must be enabled in your organization.
Queries are suggested if they exactly match the query string text. The text string must be a prefix within the query; it’s not considered
a match if it appears within a word. For example, the text string app would return suggested queries apple banana and banana apples
but not pineapple.
If the number of suggestions returned exceeds the limit specified in the request, the end of the response contains a field called
hasMoreResults. Its value is true if the suggestions returned are only a subset of the suggestions available, and false otherwise.
If the user’s search query contains quotation marks or wildcards, those symbols are automatically removed from the query string in the
URI.
IN THIS SECTION:
Add or Change the Translation of a Survey Field
If a survey field can be translated or is already translated into a particular language, you can add or change the translated value of
the survey field.
Add or Update the Translated Value of Multiple Survey Fields in One or More Languages
If one or more survey fields can be translated or are already translated, you can add or update the translated values of the survey
fields in the languages into which survey fields can be translated.
Delete the Translated Value of a Survey Field
After a survey field is translated into a particular language, you can delete the translated value of the survey field.
Delete the Translated Value of Multiple Survey Fields in One or More Languages
After survey fields are translated into one or more languages, you can delete the translated values of multiple survey fields.
Get Translated Value of a Survey Field
After a survey field is translated into a particular language, you can use this resource to the translated value of the survey field.
Get the Translated Values of Multiple Survey Fields in One or More Languages
After survey fields are translated into one or more languages, you can view the translated values of multiple survey fields in the
translated languages.
249
Reference Add or Change the Translation of a Survey Field
Note: This URI can only be used for the flow process type Survey.
Syntax
URI
/services/data/vXX.X/localizedvalue/record/developerName/language
Available since release
48.0
Formats
JSON
HTTP methods
POST
Request body JSON example
{
"value": "China"
}
Request parameters
Parameter Description
developerName Optional. Developer name of the flow field.
Response parameters
Parameter Description
createdBy ID of the user who translated the flow field.
250
Reference Add or Update the Translated Value of Multiple Survey Fields
in One or More Languages
{
"createdBy": "005xxx",
"createdDate": "2018-09-14T00:10:30Z",
"developerName": "Flow.Flow.MyFlow.1.Choice.Choice_1_Master.InputLabel",
"language": "zh_CN",
"value": " ",
"isOutOfDate": true
}
Note: This URI can only be used for the flow process type Survey.
Syntax
URI
/services/data/vXX.X/localizedvalue/records/upsert
Available since release
48.0
Formats
JSON
HTTP methods
POST
Request body JSON example
[
{
"developerName": "Flow.Flow.MyFlow.1.Choice.Choice_1_Master.InputLabel",
"language": "en_US",
"value": "China"
},
{
"developerName": "Flow.Flow.MyFlow.1.Choice.Choice_1_Master.InputLabel",
"language": "zh_CN",
"value": " "
}
]
Request parameters
Parameter Description
developerName Required. Developer name of the flow field.
251
Reference Delete the Translated Value of a Survey Field
Parameter Description
language Required. Language into which the flow field is translated.
Response parameters
Parameter Description
createdBy ID of the user who translated the flow field.
Note: This URI can only be used for the flow process type Survey.
252
Reference Delete the Translated Value of Multiple Survey Fields in One
or More Languages
Syntax
URI
/services/data/vXX.X/localizedvalue/record/developerName/language
Available since release
48.0
Formats
JSON
HTTP methods
DELETE
Request body
None
Request parameters
Parameter Description
developerName The developer name of the flow field. For example,
Flow.Flow.MyFlow.1.Choice.Choice_1_Master.InputLabel
Note: This URI can only be used for the flow process type Survey.
Syntax
URI
/services/data/vXX.X/localizedvalue/records/delete
Available since release
48.0
Formats
JSON
HTTP methods
POST
253
Reference Get Translated Value of a Survey Field
Request parameters
Parameter Description
developerName Required. Developer name of the flow field.
language Required. Language into which the flow field was translated.
Response body
None
Note: This URI can only be used for the flow process type Survey.
Syntax
URI
/services/data/vXX.X/localizedvalue/record/developerName/language
Available since release
48.0
Formats
JSON
HTTP methods
Request body
None
GET
Request parameters
254
Reference Get the Translated Values of Multiple Survey Fields in One or
More Languages
Response parameters
Parameter Description
createdBy ID of the user who translated the flow field.
Note: This URI can only be used for the flow process type Survey.
Syntax
URI
/services/data/vXX.X/localizedvalue/records/get
255
Reference Get the Translated Values of Multiple Survey Fields in One or
More Languages
Request parameters
Parameter Description
developerName Required. Developer name of the flow field.
language Required. Language into which the flow field was translated.
Response parameters
Parameter Description
createdBy ID of the user who translated the flow field.
256
Reference Tabs
"value": "China",
"isOutOfDate": true
},
{
"createdBy": "005xxx",
"createdDate": "2018-09-14T00:10:30Z",
"developerName": "Flow.Flow.MyFlow.1.Choice.Choice_1_Master.InputLabel",
"language": "zh_CN",
"value": " ",
"isOutOfDate": true
}
]
Tabs
Returns a list of all tabs—including Lightning page tabs—available to the current user, regardless of whether the user has chosen to
hide tabs via the All Tabs (+) tab customization feature. This resource is available in REST API version 31.0 and later.
Syntax
URI
/services/data/vXX.X/tabs/
Formats
JSON, XML
HTTP methods
GET, HEAD
Authentication
Authorization: Bearer token
Request body
None
Request parameters
None
Example
Usage for getting tabs
/services/data/v51.0/tabs
257
Reference Themes
"color" : "236FBD",
"context" : "primary",
"theme" : "theme3"
} ],
"custom" : false,
"iconUrl" : "https://yourInstance.salesforce.com/img/icon/accounts32.png",
"icons" : [ {
"contentType" : "image/png",
"height" : 32,
"theme" : "theme3",
"url" : "https://yourInstance.salesforce.com/img/icon/accounts32.png",
"width" : 32
}, {
"contentType" : "image/png",
"height" : 16,
"theme" : "theme3",
"url" : "https://yourInstance.salesforce.com/img/icon/accounts16.png",
"width" : 16
}, {
"contentType" : "image/svg+xml",
"height" : 0,
"theme" : "theme4",
"url" : "https://yourInstance.salesforce.com/img/icon/t4/standard/account.svg",
"width" : 0
}, {
"contentType" : "image/png",
"height" : 60,
"theme" : "theme4",
"url" : "https://yourInstance.salesforce.com/img/icon/t4/standard/account_60.png",
"width" : 60
}, {
"contentType" : "image/png",
"height" : 120,
"theme" : "theme4",
"url" : "https://yourInstance.salesforce.com/img/icon/t4/standard/account_120.png",
"width" : 120
} ],
"label" : "Accounts",
"miniIconUrl" : "https://yourInstance.salesforce.com/img/icon/accounts16.png",
"name" : "standard-Account",
"sobjectName" : "Account",
"url" : "https://yourInstance.salesforce.com/001/o",
...]
Themes
Gets the list of icons and colors used by themes in the Salesforce application. Theme information is provided for objects in your organization
that use icons and colors in the Salesforce UI.
258
Reference Themes
The If-Modified-Since header can be used with this resource, with a date format of EEE, dd MMM yyyy HH:mm:ss
z. When this header is used, if the object metadata has not changed since the provided date, a 304 Not Modified status code
is returned, with no response body.
Syntax
URI
/services/data/vXX.X/theme
Available since release
29.0
Formats
JSON, XML
HTTP methods
GET
Authentication
Authorization: Bearer token
Request body
None
Request parameters
None
Response data
An array of theme items. Each theme item contains the following fields:
name string Name of the object that the theme colors and icons are associated with.
context string The color context, which determines whether the color is the main color
(“primary”) for the object, or not.
259
Reference Themes
height number The icon’s height in pixels. If the icon content type is an SVG type, height and
width values are not used.
width number The icon’s width in pixels. If the icon content type is an SVG type, height and
width values are not used.
Example
The following is an example JSON response using a request of services/data/v29.0/theme:
{
"themeItems" : [
{
"name" : "Merchandise__c",
"icons" : [
{
"contentType" : "image/png",
"width" : 32,
"url" : "https://yourInstance.salesforce.com/img/icon/computer32.png",
"height" : 32,
"theme" : "theme3"
},
{
"contentType" : "image/png",
"width" : 16,
"url" : "https://yourInstance.salesforce.com/img/icon/computer16.png",
"height" : 16,
"theme" : "theme3"
} ],
260
Reference Composite Resources
"colors" : [
{
"context" : "primary",
"color" : "6666CC",
"theme" : "theme3"
},
{
"context" : "primary",
"color" : "66895F",
"theme" : "theme4"
},
...
}
...
}
Composite Resources
Use REST API composite resources to improve your application’s performance by minimizing the number of round-trips between the
client and server.
IN THIS SECTION:
Composite
Executes a series of REST API requests in a single call. You can use the output of one request as the input to a subsequent request.
The response bodies and HTTP statuses of the requests are returned in a single response body. The entire series of requests counts
as a single call toward your API limits.
Composite Graphs
Composite graphs provide an enhanced way to perform composite requests, which execute a series of REST API requests in a single
call.
Batch
Executes up to 25 subrequests in a single request. The response bodies and HTTP statuses of the subrequests in the batch are returned
in a single response body. Each subrequest counts against rate limits.
sObject Tree
Creates one or more sObject trees with root records of the specified type. An sObject tree is a collection of nested, parent-child
records with a single root record.
sObject Collections
Executes actions on multiple records in one request. Use sObject Collections to reduce the number of round-trips between the client
and server. The response bodies and HTTP statuses of the requests are returned in a single response body. The entire request counts
as a single call toward your API limits. This resource is available in API version 42.0 and later.
Composite
Executes a series of REST API requests in a single call. You can use the output of one request as the input to a subsequent request. The
response bodies and HTTP statuses of the requests are returned in a single response body. The entire series of requests counts as a single
call toward your API limits.
261
Reference Composite
The requests in a composite call are called subrequests. All subrequests are executed in the context of the same user. In a subrequest’s
body, you specify a reference ID that maps to the subrequest’s response. You can then refer to the ID in the url or body fields of later
subrequests by using a JavaScript-like reference notation.
For example, the following composite request body includes two subrequests. The first creates an account and designates the output
as refAccount. The second creates a contact parented under the new account by referencing refAccount in the subrequest
body.
{
"compositeRequest" : [{
"method" : "POST",
"url" : "/services/data/v51.0/sobjects/Account",
"referenceId" : "refAccount",
"body" : { "Name" : "Sample Account" }
},{
"method" : "POST",
"url" : "/services/data/v51.0/sobjects/Contact",
"referenceId" : "refContact",
"body" : {
"LastName" : "Sample Contact",
"AccountId" : "@{refAccount.id}"
}
}]
}
You can specify whether an error in a subrequest causes the whole composite request to roll back or just the subrequests that depend
on it. You can also specify headers for each subrequest.
Composite is supported for the following resources.
• All sObject resources (vXX.X/sobjects/), including sObject Rows by External ID on page 112
• The Query resource (vXX.X/query/?q=soql)
• The QueryAll resource (vXX.X/queryAll/?q=soql)
• The sObject Collections resource (vXX.X/composite/sobjects). Available in API version 43.0 and later.
Note: You can have up to 25 subrequests in a single call. Up to 5 of these subrequests can be sObject Collections or query
operations, including Query and QueryAll requests.
URI
/services/data/vXX.X/composite
Formats
JSON
HTTP method
GET (lists other available composite resources), POST
Authentication
Authorization: Bearer token
Parameters
None required
Request body
Composite Request Body
Response body
Composite Response Body
262
Reference Composite
Examples
For examples of using the Composite resource, see Execute Dependent Requests in a Single API Call and Update an Account, Create
a Contact, and Link Them with a Junction Object.
collateSubrequests Boolean Controls whether the API collates unrelated subrequests to Optional
bulkify them (true) or not (false).
When subrequests are collated, the processing speed is faster,
but the order of execution is not guaranteed (unless there is an
explicit dependency between the subrequests).
If collation is disabled, then the subrequests are executed in the
order in which they are received.
Subrequests that contain valid HTTP headers are not collated.
In API version 49.0 and later, the default value is true. In version
48.0, the default value is false.
Subrequests can be collated if they meet these conditions:
• The HTTP methods are the same.
• The API versions of the resources are the same.
263
Reference Composite
JSON example
{
"allOrNone" : true,
"collateSubrequests": true,
"compositeRequest" : [{
Composite Subrequest
},{
Composite Subrequest
},{
Composite Subrequest
}]
}
Composite Subrequest
Contains the resource, method, headers, body, and reference ID for the subrequest.
264
Reference Composite
Properties
httpHeaders Map<String, Request headers and their values to include with the subrequest. Optional
String> You can include any header supported by the requested resource
except for the following three headers.
• Accept
• Authorization
• Content-Type
Subrequests inherit these three header values from the top-level
request. Don’t specify these headers in a subrequest. If you do,
the top-level request fails and returns an HTTP 400 response.
method String The method to use with the requested resource. Possible values Required
are POST, PUT, PATCH, GET, and DELETE (case-sensitive).
For a list of valid methods, refer to the documentation for the
requested resource.
referenceId String Reference ID that maps to the subrequest’s response and can Required
be used to reference the response in later subrequests. You can
reference the referenceId in either the body or URL of a
subrequest. Use this syntax to include a reference:
@{referenceId.FieldName}.
You can use two operators with the reference ID.
The . operator references a field on a JSON object in the
response. For example, let’s say you retrieve an account record’s
data in one subrequest and assign the reference ID
Account1Data to the output. You can refer to the account’s
name in later subrequests like this:
@{Account1Data.Name}.
The [] operator indexes a JSON collection in the response. For
example, let’s say you request basic account information with
the sObject Basic Information resource in one subrequest and
assign the reference ID AccountInfo to the output. Part of
the response includes a collection of recently created accounts.
You can refer to the ID of the first account in the recent items
collection like this:
@{AccountInfo.recentItems[0].Id}.
265
Reference Composite
JSON examples
{
"method" : "GET",
"url" : "/services/data/v51.0/sobjects/Account/describe",
"httpHeaders" : { "If-Modified-Since" : "Tue, 31 May 2016 18:00:00 GMT" },
"referenceId" : "AccountInfo"
}
{
"method" : "POST",
"url" : "/services/data/v51.0/sobjects/Account",
"referenceId" : "refAccount",
"body" : { "Name" : "Sample Account" }
}
{
"method" : "GET",
"url" : "/services/data/v51.0/sobjects/Account/@{refAccount.id}",
"referenceId" : "NewAccountFields"
}
{
"method" : "PATCH",
"url" : "/services/data/v51.0/sobjects/Account/ExternalAcctId__c/ID12345",
"referenceID" : "NewAccount",
"body" : { "Name" : "Acme" }
}
Usage
Because referenceId is case-sensitive, it’s important to note the case of the fields that you’re referring to. The same field can
use different cases in different contexts. For example, when you create a record, the ID field appears as id in the response. But
when you access a record’s data with the sObject Rows resource, the ID field appears as Id. In the last example subrequest above,
the @{refAccount.id} reference is valid because refAccount refers to the response from the POST in the second
266
Reference Composite
subrequest. If you use Id instead (mixed case rather than all lowercase), as in @{refAccount.Id}, you get an error when
sending the request because the reference ID uses the wrong case.
Note: You can have up to 25 subrequests in a single call. Up to 5 of these subrequests can be sObject Collections or query
operations, including Query and QueryAll requests.
Composite Results
Properties
JSON example
{
"compositeResponse" : [{
Composite Subrequest Result
},{
Composite Subrequest Result
},{
Composite Subrequest Result
}]
}
httpHeaders Map<String, String> Response headers and their values for this subrequest. The Composite
resource doesn’t support the Content-Length header, so subrequest
responses don’t include this header and neither does the top-level
response.
267
Reference Composite
referenceID String The reference ID specified in the subrequest. This property lets you easily
associate subrequests with their results.
JSON example
The following example shows the response for a subrequest that successfully created an Account:
{
"body" : {
"id" : "001R00000033I6AIAU",
"success" : true,
"errors" : [ ]
},
"httpHeaders" : {
"Location" : "/services/data/v51.0/sobjects/Account/001R00000033I6AIAU"
},
"httpStatusCode" : 201,
"referenceId" : "refAccount"
}
The following example shows the response for a subrequest that had an error while trying to create a Contact:
{
"body" : [ {
"message" : "Email: invalid email address: Not a real email address",
"errorCode" : "INVALID_EMAIL_ADDRESS",
"fields" : [ "Email" ]
} ],
"httpHeaders" : { },
"httpStatusCode" : 400,
"referenceId" : "badContact"
}
268
Reference Composite
Consider, for example, what happens with this job where a Composite request includes two items: an sObject Collections request and
a request to create a Contact. The sObject Collections request tries to create two Accounts, one of which fails because there is already
an existing Account with the same information.
POST https://instance.salesforce.com/services/data/v51.0/composite
{
"allOrNone" : outerFlag,
"collateSubrequests" : false,
"compositeRequest" : [
{
"method" : "POST",
"url" : "/services/data/v51.0/composite/sobjects",
"body" : {
"allOrNone" : innerFlag,
"records" : [
{
"attributes" : { "type" : "Account" },
"Name" : "Northern Trail Outfitters",
"BillingCity" : "San Francisco"
},
{
"attributes" : { "type" : "Account" },
"Name" : "Easy Spaces",
"BillingCity" : "Calgary"
}
]
},
"referenceId" : "newAccounts"
},
{
"method" : "POST",
"url" : "/services/data/v51.0/sObject/Contact",
"body" : {
"FirstName" : "John",
"LastName" : "Smith"
},
"referenceId" : "newContact"
}
]
}
The outerFlag and innerFlag parameters are either true or false, which leads to four possible cases.
Case 1: outerFlag = false, innerFlag = false
In this case, neither request has allOrNone set to true, so neither request is rolled back. One account is created and one fails.
269
Reference Composite
270
Reference Composite
271
Reference Composite Graphs
}
]
}
In this case, the inner sObject Collections request has allOrNone set to false, so it is not immediately rolled back. However, the
outer Composite request has allOrNone set to true so it is rolled back, which also rolls back the inner sObject Collections request.
Note: Even though the response body for sObject Collections request shows "success" : true for the creation of the
first Account, the fact that the Composite request is rolled back means that the Account creation is rolled back. The final result is
that the new Account is not created.
Composite Graphs
Composite graphs provide an enhanced way to perform composite requests, which execute a series of REST API requests in a single call.
• Regular composite requests allow you to execute a series of REST API requests in a single call. And you can use the output of one
request as the input to a subsequent request.
• Composite graphs extend this by allowing you to assemble a more complicated and complete series of related objects and records.
• Composite graphs also enable you to ensure that the steps in a given set of operations are either all completed or all not completed.
This avoids requiring you to check for a mix of successful and unsuccessful results.
• Regular composite requests have a limit of 25 subrequests. Composite graphs increase this limit to 500. This gives a single API call
much greater power.
272
Reference Composite Graphs
In the context of composite graph operations, the nodes are composite subrequests. For example, a node can be a composite subrequest
like this:
{
"url" : "/services/data/v51.0/sobjects/Account/",
"body" : {
"name" : "Cloudy Consulting"
},
"method" : "POST",
"referenceId" : "reference_id_account_1"
}
/services/data/vXX.X/sobject/ POST
sObject
See sObject Basic Information.
sObject/id
See sObject Rows.
sObject/customFieldName/externalId
See sObject Rows by External ID.
A composite graph can be directed meaning that some nodes use information from other nodes. For example, a node that creates a
Contact can use the ID of an Account node to link the Contact with the Account.
For example:
{
"graphs": [{
"graphId": "graph1",
"compositeRequest": [{
273
Reference Composite Graphs
"body": {
"name": "Cloudy Consulting"
},
"method": "POST",
"referenceId": "reference_id_account_1",
"url": "/services/data/v51.0/sobjects/Account/"
},
{
"body": {
"FirstName": "Nellie",
"LastName": "Cashman",
"AccountId": "@{reference_id_account_1.id}"
},
"method": "POST",
"referenceId": "reference_id_contact_1",
"url": "/services/data/v51.0/sobjects/Contact/"
}
]
}]
}
{
"graphId" : "graphId",
"compositeRequest" : [
compositeSubrequest,
compositeSubrequest,
...
]
}
The graphId parameters enable you to identify the graphs when viewing the response. They need not be numeric, but they must
follow these restrictions:
• They must be unique within each composite graph operation.
• They must begin with an alphanumeric character.
• They must be less that 40 characters long.
• They can’t contain a period (’.’).
A single composite graph request can use one or more composite graphs. See Using a Composite Graph.
274
Reference Composite Graphs
4. Create a Campaign.
5. Create an Opportunity linked to Account 2 and the Campaign.
6. Create a Lead.
7. Create a CampaignMember linked to the Lead and the Campaign.
275
Reference Composite Graphs
."ParentId" : "@{reference_id_account_1.id}"
},
"method" : "POST",
"referenceId" : "reference_id_account_2"
},
{
"url" : "/services/data/v51.0/sobjects/Contact/",
"body" : {
"FirstName" : "Sam",
"LastName" : "Steele",
"AccountId" : "@{reference_id_account_2.id}"
},
"method" : "POST",
"referenceId" : "reference_id_contact_1"
},
{
"url" : "/services/data/v51.0/sobjects/Contact/",
"body" : {
"FirstName" : "Charlie",
"LastName" : "Dawson",
"ReportsToId" : "@{reference_id_contact_1.id}"
},
"method" : "POST",
"referenceId" : "reference_id_contact_2"
},
{
"url" : "/services/data/v51.0/sobjects/Contact/",
"body" : {
"FirstName" : "Nellie",
"LastName" : "Cashman",
"ReportsToId" : "@{reference_id_contact_2.id}"
},
"method" : "POST",
"referenceId" : "reference_id_contact_3"
},
{
"url" : "/services/data/v51.0/sobjects/Campaign/",
"body" : {
"name" : "Spring Campaign"
},
"method" : "POST",
"referenceId" : "reference_id_campaign"
},
{
"url" : "/services/data/v51.0/sobjects/Opportunity/",
"body" : {
"name" : "Opportunity",
"stageName" : "Value Proposition",
"closeDate" : "2025-12-31",
"CampaignId" : "@{reference_id_campaign.id}",
"AccountId" : "@{reference_id_account_2.id}"
},
"method" : "POST",
"referenceId" : "reference_id_opportunity"
276
Reference Composite Graphs
},
{
"url" : "/services/data/v51.0/sobjects/Lead/",
"body" : {
"FirstName" : "Belinda",
"LastName" : "Mulroney",
"Company" : "Klondike Quarry",
"Email" : "bmulroney@example.com"
},
"method" : "POST",
"referenceId" : "reference_id_lead"
},
{
"url" : "/services/data/v51.0/sobjects/CampaignMember/",
"body" : {
"CampaignId" : "@{reference_id_campaign.id}",
"LeadId" : "@{reference_id_lead.id}"
},
"method" : "POST",
"referenceId" : "reference_id_campaignmember"
}
]
}
Example: GET Details About a Resource and Then Use Them in a Composite Graph
Request
This example shows how you can use GET on a resource, and then use properties of that resource in subsequent requests.
{
"graphs" : [
{
"graphId" : "graph1",
"compositeRequest" : [
{
"method" : "GET",
"url" : "/services/data/v51.0/sobjects/Account/001R0000003fSRrIAM",
"referenceId" : "refAccount"
},
{
"body" : {
"name" : "Amazing opportunity for @{refAccount.Name}",
"StageName" : "Stage 1",
"CloseDate" : "2025-06-01T23:28:56.782Z",
"AccountId" : "@{refAccount.Id}"
},
"method" : "POST",
"url" : "/services/data/v51.0/sobjects/Opportunity",
"referenceId" : "newOpportunity"
}
]
}
277
Reference Composite Graphs
]
}
Graph Depth
• Nodes with no parents are considered to be at depth 1.
• The depth of another node is the maximum number of edges in the graph from depth 1 to that node. An edge between two nodes
occurs when the one node uses a property (such as @{reference_account.id} ) from another node.
Best Practices
As a general practice, keep your graphs as small as possible. For example, it’s more efficient to have 50 graphs with 10 nodes rather than
1 graph with 500 nodes. Keeping graphs small has two advantages:
• If one item in a graph fails, only the items in that graph are rolled back. This makes it easier to handle errors.
• The server can process multiple, smaller graphs faster and more efficiently.
IN THIS SECTION:
Composite Subrequest
The composite subrequest describes a subrequest to execute with the Composite Graph resource.
278
Reference Composite Graphs
Composite Subrequest
The composite subrequest describes a subrequest to execute with the Composite Graph resource.
Properties
279
Reference Composite Graphs
280
Reference Composite Graphs
Examples
{
"body" : {
"Name" : "Sample Account"
},
"method" : "POST",
"referenceId" : "refAccount",
"url" : "/services/data/v51.0/sobjects/Account"
}
{
"method" : "GET",
"referenceId" : "NewAccountFields",
"url" : "/services/data/v51.0/sobjects/Account/@{refAccount.id}"
}
Usage
Because referenceId is case-sensitive, it’s important to note the case of the fields that you’re referring to. The same field can use
different cases in different contexts. For example, when you create a record, the ID field appears as id in the response. But when you
access a record’s data with the sObject Rows resource, the ID field appears as Id. In the last example subrequest above, the
@{refAccount.id} reference is valid because refAccount refers to the response from the POST in the second subrequest. If
you use Id instead (mixed case rather than all lowercase), as in @{refAccount.Id}, you get an error when sending the request
because the reference ID uses the wrong case.
Properties
httpHeaders Map<String, String> Response headers and their values for this
subrequest. The Composite resource doesn’t
support the Content-Length header, so
subrequest responses don’t include this
header and neither does the top-level
response.
281
Reference Composite Graphs
Example
{
"body": {
"id": "001R00000064wdtIAA",
"success": true,
"errors": []
},
"httpHeaders": {
"Location": "/services/data/v51.0/sobjects/Account/001R00000064wdtIAA"
},
"httpStatusCode": 201,
"referenceId": "refAccount"
}
Syntax
URI
/services/data/vXX.X/composite/graph
Available since release
This resource is available in API version 50.0 and later.
Formats
JSON
HTTP methods
POST
Authentication
Authorization: Bearer token
Request parameters
None
282
Reference Composite Graphs
Request Body
{
"graphId" : "graphId",
"compositeRequest" : [
compositeSubrequest,
compositeSubrequest,
...
]
}
283
Reference Composite Graphs
"body" : {
"name" : "Easy Spaces"
},
"method" : "POST",
"referenceId" : "reference_id_account_2"
},
{
"url" : "/services/data/v51.0/sobjects/Contact/",
"body" : {
"FirstName" : "Charlie",
"LastName" : "Dawson",
"AccountId" : "@{reference_id_account_2.id}"
},
"method" : "POST",
"referenceId" : "reference_id_contact_2"
}
]
}
]
}
Response Body
{
"graphs" : [
{
"graphId" : "graphId",
"graphResponse" : {
"compositeResponse" : [
compositeSubrequest,
compositeSubrequest,
compositeSubrequest,
...
]
},
"isSuccessful" : flag
},
...
]
}
compositeResponse Array of composite subrequest results. Results for each node in the graph.
284
Reference Composite Graphs
Example
{
"graphs" : [
{
"graphId" : "1",
"graphResponse" : {
"compositeResponse" : [
{
"body" : {
"id" : "001R00000064wc7IAA",
"success" : true,
"errors" : [ ]
},
"httpHeaders" : {
"Location" : "/services/data/v51.0/sobjects/Account/001R00000064wc7IAA"
},
"httpStatusCode" : 201,
"referenceId" : "reference_id_account_1"
},
{
"body" : {
"id" : "003R000000DDMlTIAX",
"success" : true,
"errors" : [ ]
},
"httpHeaders" : {
"Location" : "/services/data/v51.0/sobjects/Contact/003R000000DDMlTIAX"
},
"httpStatusCode" : 201,
"referenceId" : "reference_id_contact_1"
},
{
"body" : {
"id" : "006R0000003FPYxIAO",
"success" : true,
"errors" : [ ]
},
"httpHeaders" : {
"Location" :
"/services/data/v51.0/sobjects/Opportunity/006R0000003FPYxIAO"
},
"httpStatusCode" : 201,
"referenceId" : "reference_id_opportunity_1"
}
]
},
"isSuccessful" : true
},
{
"graphId" : "2",
"graphResponse" : {
"compositeResponse" : [
285
Reference Composite Graphs
{
"body" : {
"id" : "001R00000064wc8IAA",
"success" : true,
"errors" : [ ]
},
"httpHeaders" : {
"Location" : "/services/data/v51.0/sobjects/Account/001R00000064wc8IAA"
},
"httpStatusCode" : 201,
"referenceId" : "reference_id_account_2"
},
{
"body" : {
"id" : "003R000000DDMlUIAX",
"success" : true,
"errors" : [ ]
},
"httpHeaders" : {
"Location" : "/services/data/v51.0/sobjects/Contact/003R000000DDMlUIAX"
},
"httpStatusCode" : 201,
"referenceId" : "reference_id_contact_2"
}
]
},
"isSuccessful" : true
}
]
}
Note: The response bodies and HTTP statuses of the requests are returned in a single response body. The entire request counts
as a single call toward your API limits.
Item Limit
Maximum number of graphs in one payload. 75
286
Reference Batch
Item Limit
For example:
• /services/data/v50.0/sobjects/account
and /services/data/v52.0/sobjects/account
are considered different.
• /services/data/vXX.X/sobjects/account and
/services/data/vXX.Xsobjects/contact are
considered different.
Limits on Nodes
Item Limit
Maximum number of nodes supported in one payload. 500
(For example, there can be one graph with 500 nodes, or 250
graphs with 2 nodes each.)
Batch
Executes up to 25 subrequests in a single request. The response bodies and HTTP statuses of the subrequests in the batch are returned
in a single response body. Each subrequest counts against rate limits.
The requests in a batch are called subrequests. All subrequests are executed in the context of the same user. Subrequests are independent,
and you can’t pass information between them. Subrequests execute serially in their order in the request body. When a subrequest
executes successfully, it commits its data. Commits are reflected in the output of later subrequests. If a subrequest fails, commits made
by previous subrequests are not rolled back. If a batch request doesn’t complete within 10 minutes, the batch times out and the remaining
subrequests aren’t executed.
Batching for the following resources and resource groups is available in API version 34.0 and later.
• Limits—vXX.X/limits
• sObject resources—vXX.X/sobjects/
• Query—vXX.X/query/?q=soql
• QueryAll—vXX.X/queryAll/?q=soql
• Search—vXX.X/search/?q=sosl
• Connect resources—vXX.X/connect/
• Chatter resources—vXX.X/chatter/
Batching for the following resources and resource groups is available in API version 35.0 and later.
• Actions—vXX.X/actions
The API version of the resource accessed in each subrequest must be no earlier than 34.0 and no later than the Batch version in the
top-level request. For example, if you post a Batch request to /services/data/v35.0/composite/batch, you can include
subrequests that access version 34.0 or 35.0 resources. But if you post a Batch request to
/services/data/v34.0/composite/batch, you can only include subrequests that access version 34.0 resources.
287
Reference Batch
URI
/services/data/vXX.X/composite/batch
Formats
JSON, XML
HTTP method
POST
Authentication
Authorization: Bearer token
Parameters
None required
Request body
Batch Request Body on page 288
Response body
Batch Response Body on page 290
Examples
For an example of using the Batch resource, see Update a Record and Get Its Field Values in a Single Request on page 85.
haltOnError Boolean Controls whether Salesforce should stop processing subrequests Optional
if a subrequest fails. The default is false.
If the value is false and a subrequest in the batch doesn’t
complete, Salesforce attempts to execute the subsequent
subrequests in the batch.
If the value is true and a subrequest in the batch doesn’t
complete due to an HTTP response in the 400 or 500 range,
Salesforce halts execution. It returns an HTTP 412 status code
and a BATCH_PROCESSING_HALTED error message for
each subsequent subrequest. The top-level request to
/composite/batch returns HTTP 200, and the
hasErrors property in the response is set to true.
This setting is only applied during subrequest processing, and
not during initial request deserialization. If an error is detected
during deserialization, such as a syntax error in the Subrequest
288
Reference Batch
Subrequest
Contains the resource, method, and accompanying information for the subrequest.
Properties
binaryPartNameAlias String The name parameter in the Content-Disposition header of the Optional
binary body part. Different resources expect different values. See
Insert or Update Blob Data.
If this value exists, a binaryPartName value must also exist.
method String The method to use with the requested resource. For a list of valid Required
methods, refer to the documentation for the requested resource.
289
Reference Batch
Batch Results
Properties
JSON example
{
"hasErrors" : false,
"results" : [{
"statusCode" : 204,
"result" : null
},{
"statusCode" : 200,
"result": {
"attributes" : {
"type" : "Account",
290
Reference sObject Tree
"url" : "/services/data/v51.0/sobjects/Account/001D000000K0fXOIAZ"
},
"Name" : "NewName",
"BillingPostalCode" : "94105",
"Id" : "001D000000K0fXOIAZ"
}
}]
}
Subrequest Result
Properties
Important: If the
result is an error,
the type is a
collection
containing the
error message and
error code.
statusCode Integer An HTTP status code indicating the status of this subrequest.
JSON example
{
"attributes" : {
"type" : "Account",
"url" : "/services/data/v51.0/sobjects/Account/001D000000K0fXOIAZ"
},
"Name" : "NewName",
"BillingPostalCode" : "94015",
"Id" : "001D000000K0fXOIAZ"
}
sObject Tree
Creates one or more sObject trees with root records of the specified type. An sObject tree is a collection of nested, parent-child records
with a single root record.
In the request data, you supply the record hierarchies, required and optional field values, each record’s type, and a reference ID for each
record. Upon success, the response contains the IDs of the created records. If an error occurs while creating a record, the entire request
fails. In this case, the response contains only the reference ID of the record that caused the error and the error information. The response
bodies and HTTP statuses of the requests are returned in a single response body. The entire request counts as a single call toward your
API limits.
291
Reference sObject Tree
292
Reference sObject Tree
Properties
XML example
<SObjectTreeRequest>
<records type="Account" referenceId="ref1">
<name>SampleAccount</name>
<phone>1234567890</phone>
<website>www.salesforce.com</website>
<numberOfEmployees>100</numberOfEmployees>
<industry>Banking</industry>
293
Reference sObject Tree
<Contacts>
<records type="Contact" referenceId="ref2">
<lastname>Smith</lastname>
<title>President</title>
<email>sample@salesforce.com</email>
</records>
<records type="Contact" referenceId="ref3">
<lastname>Evans</lastname>
<title>Vice President</title>
<email>sample@salesforce.com</email>
</records>
</Contacts>
</records>
<records type="Account" referenceId="ref4">
<name>SampleAccount2</name>
<phone>1234567890</phone>
<website>www.salesforce2.com</website>
<numberOfEmployees>100</numberOfEmployees>
<industry>Banking</industry>
</records>
</SObjectTreeRequest>
Required object fields Depends on Required fields and field values for this record. Required
field
Optional object fields Depends on Optional fields and field values for this record. Optional
field
Child relationships sObject Tree This record’s child relationships, such as an account’s child Optional
Collection contacts. Child relationships are either master-detail or lookup
Input relationships. To view an object’s valid child relationships, use
the sObject Describe resource or Schema Builder. The value of
this property is an sObject Tree Collection Input that contains
child sObject trees.
294
Reference sObject Tree
XML example
<records type="Account" referenceId="ref1">
<name>SampleAccount</name>
<phone>1234567890</phone>
<website>www.salesforce.com</website>
<numberOfEmployees>100</numberOfEmployees>
<industry>Banking</industry>
<Contacts>
<records type="Contact" referenceId="ref2">
<lastname>Smith</lastname>
<title>President</title>
<email>sample@salesforce.com</email>
</records>
<records type="Contact" referenceId="ref3">
<lastname>Evans</lastname>
<title>Vice President</title>
<email>sample@salesforce.com</email>
</records>
</Contacts>
</records>
295
Reference sObject Tree
Properties
results Collection Upon success, results contains the reference ID of each requested
record and its new record ID. Upon failure, it contains only the reference
ID of the record that caused the error, error status code, error message,
and fields related to the error. In the case of duplicate reference IDs,
results contains one item for each instance of the duplicate ID.
296
Reference sObject Collections
sObject Collections
Executes actions on multiple records in one request. Use sObject Collections to reduce the number of round-trips between the client
and server. The response bodies and HTTP statuses of the requests are returned in a single response body. The entire request counts as
a single call toward your API limits. This resource is available in API version 42.0 and later.
URI
The URI to use depends on the operation.
Create
POST /services/data/vXX.X/composite/sobjects
Retrieve
GET
/services/data/vXX.X/composite/sobjects/SobjectName?ids=recordId,recordId&fields=fieldname,fieldname
Update
PATCH /services/data/vXX.X/composite/sobjects
Upsert
PATCH /services/data/vXX.X/composite/sobjects/SobjectName/ExternalIdFieldName
Delete
DELETE /services/data/vXX.X/composite/sobjects?ids=recordId,recordId
Formats
JSON, XML
297
Reference sObject Collections
HTTP method
GET, DELETE, PATCH, POST
Authentication
Authorization: Bearer token
The parameters, request body, and response body you use depend on the operation. For details, see the specific operation.
IN THIS SECTION:
Create Multiple Records with Fewer Round-Trips
Use a POST request with sObject Collections to add up to 200 records, returning a list of SaveResult objects. You can choose whether
to roll back the entire request when an error occurs.
Retrieve Multiple Records with Fewer Round-Trips
Use a GET or POST request with sObject Collections to retrieve one or more records of the same object type. A list of sObjects that
represents the individual records of the specified type is returned. The number of sObjects returned matches the number of IDs
passed in the request.
Update Multiple Records with Fewer Round-Trips
Use a PATCH request with sObject Collections to update up to 200 records, returning a list of SaveResult objects. You can choose
whether to roll back the entire request when an error occurs.
Upsert Multiple Records with Fewer Round-Trips
Use a PATCH request with sObject Collections to either create or update (upsert) up to 200 records based on an external ID field.
This method returns a list of UpsertResult objects. You can choose whether to roll back the entire request when an error occurs.
Delete Multiple Records with Fewer Round-Trips
Use a DELETE request with sObject Collections to delete up to 200 records, returning a list of DeleteResult objects. You can choose
to roll back the entire request when an error occurs.
Request Syntax
POST /services/data/vXX.X/composite/sobjects
Parameters
Parameter Description
allOrNone Optional. Indicates whether to roll back the entire request when the creation of any object
fails (true) or to continue with the independent creation of other objects in the request.
The default is false.
298
Reference sObject Collections
Parameter Description
records Required. A list of sObjects. In a POST request using sObject Collections, set the type
attribute for each object, but don’t set the id field for any object.
Usage Guidelines
• The list can contain up to 200 objects.
• The list can contain objects of different types, including custom objects.
• Each object must contain an attributes map. The map must contain a value for type.
Note: Using sObject Collections to insert blob data requires more values in the attributes map. For more information, see
Using sObject Collections to Insert a Collection of Blob Records.
• Objects are created in the order they’re listed. The SaveResult objects are returned in the order in which the create requests were
specified.
• If the request body includes objects of more than one type, they are processed as chunks. For example, if the incoming objects are
{account1, account2, contact1, account3}, the request is processed in three chunks: {{account1,
account2}, {contact1}, {account3}}. A single request can process up to 10 chunks.
• You can’t create records for multiple object types in one call when one of the types is related to a feature in the Salesforce Setup
area.
299
Reference sObject Collections
[
{
"id" : "001RM000003oLnnYAE",
"success" : true,
"errors" : [ ]
},
{
"id" : "003RM0000068xV6YAI",
"success" : true,
"errors" : [ ]
}
]
This example shows a response when some items caused errors and allOrNone is false.
HTTP/1.1 200 OK
[
{
"success" : false,
"errors" : [
{
"statusCode" : "DUPLICATES_DETECTED",
"message" : "Use one of these records?",
"fields" : [ ]
}
]
},
{
"id" : "003RM0000068xVCYAY",
"success" : true,
"errors" : [ ]
}
]
This example shows a response when some items caused errors and allOrNone is true.
HTTP/1.1 200 OK
[
{
"success" : false,
"errors" : [
{
"statusCode" : "DUPLICATES_DETECTED",
"message" : "Use one of these records?",
"fields" : [ ]
}
]
},
{
"success" : false,
"errors" : [
{
"statusCode" : "ALL_OR_NONE_OPERATION_ROLLED_BACK",
300
Reference sObject Collections
"message" : "Record rolled back because not all records were valid and the
request was using AllOrNone header",
"fields" : [ ]
}
]
}
]
Request Syntax
If you’re using a GET request, use the following syntax, where sObjectName is the object type of the records from which you’re
retrieving data.
GET
/services/data/vXX.X/composite/sobjects/sObjectName?ids=recordId,recordId&fields=fieldname,fieldname
If you’re using a POST request, use the following syntax, where sObjectName (required) is the object type of the records from which
you’re retrieving data.
POST /composite/sobjects/sObjectName
{
"ids" : ["recordId", "recordId", "recordId"],
"fields" : ["fieldname", "fieldname"]
}
Parameters
Parameter Description
ids Required. A list of one or more IDs of the objects to return. All IDs must belong to the
same object type.
fields Required. A list of fields to include in the response. The field names you specify must be
valid, and you must have read-level permissions to each field.
Usage Guidelines
• If you specify an invalid field name or a field name that you don’t have permission to read, HTTP 400 Bad Request is returned.
• If you don’t have access to an object, or if a passed ID is invalid, the array returns null for that object.
301
Reference sObject Collections
Request Example
If you’re using a GET request, use the syntax shown in the following example.
GET
/composite/sobjects/Account?ids=001xx000003DGb1AAG,001xx000003DGb0AAG,001xx000003DGb9AAG&fields=id,name
If you’re using a POST request, use a request body as shown in the following example.
POST /composite/sobjects/Account
{
"ids" : ["001xx000003DGb1AAG", "001xx000003DGb0AAG", "001xx000003DGb9AAG"],
"fields" : ["id", "name"]
}
Request Syntax
PATCH /services/data/vXX.X/composite/sobjects
302
Reference sObject Collections
Parameters
Parameter Description
allOrNone Optional. Indicates whether to roll back the entire request when the update of any object
fails (true) or to continue with the independent update of other objects in the request.
The default is false.
records Required. A list of sObjects. In a POST request using sObject Collections, set the type
attribute for each object, but don’t set the id field for any object.
Usage Guidelines
• The list can contain up to 200 objects.
• The list can contain objects of different types, including custom objects.
• Each object must contain an attributes map. The map must contain a value for type.
Note: Using sObject Collections to update blob data requires more values in the attributes map. For more information, see
Using sObject Collections to Insert a Collection of Blob Records.
303
Reference sObject Collections
[
{
"id" : "001RM000003oCprYAE",
"success" : true,
"errors" : [ ]
},
{
"id" : "003RM0000068og4YAA",
"success" : true,
"errors" : [ ]
}
]
This example shows a response when some items caused errors and allOrNone is false.
HTTP/1.1 200 OK
[
{
"id" : "001RM000003oCprYAE",
"success" : true,
"errors" : [ ]
},
{
"success" : false,
"errors" : [
{
"statusCode" : "MALFORMED_ID",
"message" : "Contact ID: id value of incorrect type: 001xx000003DGb2999",
"fields" : [
"Id"
]
}
]
}
]
This example shows a response when some items caused errors and allOrNone is true.
HTTP/1.1 200 OK
[
{
304
Reference sObject Collections
"id" : "001RM000003oCprYAE",
"success" : false,
"errors" : [
{
"statusCode" : "ALL_OR_NONE_OPERATION_ROLLED_BACK",
"message" : "Record rolled back because not all records were valid and the
request was using AllOrNone header",
"fields" : [ ]
}
]
},
{
"success" : false,
"errors" : [
{
"statusCode" : "MALFORMED_ID",
"message" : "Contact ID: id value of incorrect type: 001xx000003DGb2999",
"fields" : [
"Id"
]
}
]
}
]
Request Syntax
POST /services/data/vXX.X/composite/sobjects/SobjectName/ExternalIdFieldName
Parameters
Parameter Description
allOrNone Optional. Indicates whether to roll back the entire request when the creation of any object
fails (true) or to continue with the independent creation of other objects in the request.
The default is false.
records Required. A list of sObjects. In a PATCH request using sObject Collections, set the type
attribute for each object, but don’t set the id field for any object. Instead use the external
ID field specified in the request URI.
305
Reference sObject Collections
Usage Guidelines
• The list can contain up to 200 objects.
• The list can contain objects only of the type indicated in the request URI.
• Each object in the request body must contain an attributes map. The map must contain a value for type.
Note: Using sObject Collections to insert blob data requires more values in the attributes map. For more information, see
Using sObject Collections to Insert a Collection of Blob Records.
• Objects are created or updated in the order they’re listed in the request body. The UpsertResult objects are returned in the same
order.
306
Reference sObject Collections
}
]
This example shows a response when some items caused errors and allOrNone is false.
HTTP/1.1 200 OK
[
{
"id" : "001xx0000004GxDAAU",
"success" : true,
"errors" : [ ]
},
{
"success" : false,
"errors" : [
{
"statusCode" : "MALFORMED_ID",
"message" : "Contact ID: id value of incorrect type: 001xx0000004GxEAAU",
"fields" : [
"Id"
]
}
]
}
]
This example shows a response when some items caused errors and allOrNone is true.
HTTP/1.1 200 OK
[
{
"id" : "001xx0000004GxDAAU",
"success" : false,
"errors" : [
{
"statusCode" : "ALL_OR_NONE_OPERATION_ROLLED_BACK",
"message" : "Record rolled back because not all records were valid and the
request was using AllOrNone header",
"fields" : [ ]
}
]
},
{
"success" : false,
"errors" : [
{
"statusCode" : "MALFORMED_ID",
"message" : "Contact ID: id value of incorrect type: 001xx0000004GxEAAU",
"fields" : [
"Id"
]
}
]
307
Reference sObject Collections
}
]
SEE ALSO:
sObject Rows by External ID
Request Syntax
DELETE /services/data/vXX.X/composite/sobjects?ids=recordId,recordId
Parameters
Parameter Description
allOrNone Optional. Indicates whether to roll back the entire request when the deletion of any object
fails (true) or to continue with the independent deletion of other objects in the request.
The default is false.
ids Required. A list of up to 200 IDs of objects to be deleted. The IDs can belong to different
object types, including custom objects.
Usage Guidelines
• The DeleteResult objects are returned in the order in which the IDs of the deleted objects were specified.
• You can't delete records for multiple object types in one call when one of those types is related to a feature in the Salesforce Setup
area.
Request Example
DELETE /composite/sobjects?ids=001xx000003DGb2AAG,003xx000004TmiQAAS&allOrNone=false
308
Reference sObject Collections
[
{
"id" : "001RM000003oLrHYAU",
"success" : true,
"errors" : [ ]
},
{
"id" : "001RM000003oLraYAE",
"success" : true,
"errors" : [ ]
}
]
This example shows a response when some items caused errors and allOrNone is false.
HTTP/1.1 200 OK
[
{
"id" : "001RM000003oLrfYAE",
"success" : true,
"errors" : [ ]
},
{
"success" : false,
"errors" : [
{
"statusCode" : "MALFORMED_ID",
"message" : "malformed id 001RM000003oLrB000",
"fields" : [ ]
}
]
}
]
This example shows a response when some items caused errors and allOrNone is true.
HTTP/1.1 200 OK
[
{
"id" : "001RM000003oLruYAE",
"success" : false,
"errors" : [
{
"statusCode" : "ALL_OR_NONE_OPERATION_ROLLED_BACK",
"message" : "Record rolled back because not all records were valid and the
request was using AllOrNone header",
"fields" : [ ]
}
309
Reference Headers
]
},
{
"success" : false,
"errors" : [
{
"statusCode" : "MALFORMED_ID",
"message" : "malformed id 001RM000003oLrB000",
"fields" : [ ]
}
]
}
]
Headers
This section lists custom HTTP request and response headers used for REST API.
IN THIS SECTION:
Assignment Rule Header
The Assignment Rule header is a request header applied when creating or updating Accounts, Cases, or Leads. If enabled, the active
assignment rules are used. If disabled, the active assignment rules are not applied. If a valid AssignmentRule ID is provided, the
AssignmentRule is applied. If the header is not provided with a request, REST API defaults to using the active assignment rules.
Call Options Header
Specifies client-specific options when accessing REST API resources. For example, you can write client code that ignores namespace
prefixes by specifying the prefix in the call options header.
Limit Info Header
This response header is returned in each request to REST API. You can use the information to monitor API limits.
Package Version Header
Specifies the version of each package referenced by a client. A package version is a number that identifies the set of components
and behavior contained in a package. This header can also be used to specify a package version when making calls to an Apex REST
web service.
Query Options Header
Specifies options used in a query, such as the query results batch size. Use this request header with the Query resource.
Note: This header also gets applied when making REST API calls that indirectly result in creating or updating Accounts, Cases, or
Leads. For example, if you use this header with a call that updates a record, and the update executes an Apex trigger that updates
a Case, the assignment rules would be applied.
310
Reference Call Options Header
/services/data/vXX.X/query/?q=SELECT+Id+botID__c+FROM+Account
311
Reference Limit Info Header
The defaultNamespace field is ignored when retrieving describe information, which avoids ambiguity between namespace
prefixes and customer fields of the same name.
312
Reference Status Codes and Error Responses
The default is 2,000; the minimum is 200, and the maximum is 2,000. There is no guarantee that the requested batch size is the
actual batch size. Changes are made as necessary to maximize performance.
Example
Sforce-Query-Options: batchSize=1000
300 The value returned when an external ID exists in more than one record. The response body contains the list
of matching records.
304 The request content has not changed since a specified date and time. The date and time is provided in a
If-Modified-Since header. See Get Object Metadata Changes for an example.
400 The request couldn’t be understood, usually because the JSON or XML body contains an error.
401 The session ID or OAuth token used has expired or is invalid. The response body contains the message and
errorCode.
403 The request has been refused. Verify that the logged-in user has appropriate permissions. If the error code is
REQUEST_LIMIT_EXCEEDED, you’ve exceeded API request limits in your org.
404 The requested resource couldn’t be found. Check the URI for errors, and verify that there are no sharing issues.
405 The method specified in the Request-Line isn’t allowed for the resource specified in the URI.
409 The request could not be completed due to a conflict with the current state of the resource. Check that the
API version is compatible with the resource you are requesting.
412 The request was not executed because one or more of the preconditions that the client specified in the request
headers was not satisfied. For example, the request includes an If-Unmodified-Since header, but the
data was modified after the specified date.
414 The length of the URI exceeds the 16,384 byte limit.
415 The entity in the request is in a format that’s not supported by the specified method.
431 The combined length of the URI and headers exceeds the 16,384 byte limit.
313
Reference Status Codes and Error Responses
503 The server is unavailable to handle the request. Typically this occurs if the server is down for maintenance or
is currently overloaded.
Incorrect ID example
Using a non-existent ID in a request using JSON or XML (request_body.json or request_body.xml)
[
{
"fields" : [ "Id" ],
"message" : "Account ID: id value of incorrect type: 001900K0001pPuOAAU",
"errorCode" : "MALFORMED_ID"
}
]
314