Generating an OpenAPI 3.0 Document for sObjects REST API (Beta)
Supported Editions
This beta feature is available to all editions, sandboxes, and scratch orgs that have API Enabled.
About the Document
The OpenAPI document adheres to Version 3.0 of the OpenAPI Specification. For more information, see https://www.openapis.org.
What the OpenAPI Document Covers
You can retrieve, create, and update object data with REST API resources that this OpenAPI document describes.
-
/sobjects
- Lists the available objects and their metadata for your data. Provides the organization encoding, and the maximum batch size permitted in queries.
- See Describe Global.
-
/sobjects/{sObject}
- Describes the individual metadata for the specified object. Can create an object record. For example, retrieve the metadata for the Account object using the GET method or create an Account object using the POST method. Generates a list of all accessible sObjects in your org and adds them to the components section of the OpenAPI spec.
- See sObject Basic Information.
-
/sobjects/{sObject}/describe
- Describes the individual metadata at all levels for sObjects
- See sObject Describe.
-
/sobjects/{sObject}/{id}
- Accesses records based on the specified object ID. Retrieves, updates, or deletes records. Can 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. Generates a list of all accessible sObjects in your org and adds them to the components section of the OpenAPI spec.
- See sObject Rows.
-
/query
- Retrieves records using a SOQL query.
- See Execute the Specified SOQL Query.
-
/query/queryLocator
- Retrieves the next batch of records from a SOQL query using a query locator.
- See Query More Results.
-
/sobjects/{sObject}/updated
- Retrieves the list of individual updated records within the timespan for sObjects
- See Get a List of Updated Records Within a Given Timeframe.
-
/sobjects/{sObject}/deleted
- Retrieves the list of individual deleted records within the timespan for sObjects
- See sObject Get Deleted.
-
/sobjects/{sObject}/{id}/{blobField}
- Retrieves the specified blob field from an individual record and returns it as binary data
- See sObject Blob Get.
Enabling the Beta
- From Setup, in the Quick Find box, enter User Interface, and then select User Interface.
- On the User Interface page, select Enable Salesforce Platform REST API, OpenAPI Spec Generation (Beta).
Generate an OpenAPI Document
{
"resources" : [ selectors ]
}
{
"resources" : ["*"]
}
To get specific sections of the OpenAPI document, use one or more quoted targeted selectors:
- "/sobjects"
- "/sobjects/{sObject}"
- "/sobjects/{sObject}/{id}"
- "/sobjects/{sObject}/deleted"
- "/sobjects/{sObject}/describe"
- "/sobjects/{sObject}/{id}/{blobField}"
{
"resources" : [
"/sobjects/{sObject}",
"/sobjects/{sObject}/{id}",
"/sobjects/{sObject}/deleted",
"/sobjects/{sObject}/describe",
"/sobjects/{sObject}/{id}/{blobField}"
]
}
{
"resources" : [
"/sobjects/{sObject}",
"/sobjects/{sObject}/{id}",
"/sobjects/{sObject}/deleted",
"/sobjects/{sObject}/describe",
"/sobjects/{sObject}/{id}/{blobField}"
],
"sobjects" : {
"include" : ["Account", "Contact"]
}
}
A successful POST request returns a JSON response body containing a URI to view the details page and a URI to get the OpenAPI document. The URIs contain a locator ID. In this example, the locator ID is NTByUjAwMDAwMDAwMDBh.
HTTP/1.1 202 Accepted
{ "results" : "/v63.0/async/specifications/oas3/NTByUjAwMDAwMDAwMDBh/results",
"details" : "/v63.0/async/specifications/oas3/NTByUjAwMDAwMDAwMDBh"}
If the server encounters errors processing the request, it reports a “Failed” status and returns a 4xx or 5xx status.
View the Details Page
You can check the status of your request to generate an OpenAPI document and view other information from the details page. This is an example details page.
{
"name" : "OAS3",
"apiTaskStatus" : "INPROGRESS",
"errors" : [],
"createdById" : "005xxxxxxxxxxxx",
"version" : 63.0
}
https://MyDomainName.my.salesforce.com/services/data/vXX.X/async/specifications/oas3/locatorID
For example:
https://MyDomainName.my.salesforce.com/services/data/vXX.X/async/specifications/oas3/NTByUjAwMDAwMDAwMDBh
The API version in the GET request must be the latest version.
View the OpenAPI Document
https://MyDomainName.my.salesforce.com/services/data/vXX.X/async/specifications/oas3/locatorID/results
For example:
https://MyDomainName.my.salesforce.com/services/data/vXX.X/async/specifications/oas3/NTByUjAwMDAwMDAwMDBh/results
HTTP/1.1 200 OK{
"openapi": "3.0.1",
"info": {
"title": "Lightning Platform REST API",
"description": "REST API provides you with programmatic access to your data in Salesforce.
The flexibility and scalability of REST API make it an excellent choice for integrating Salesforce into your applications
and for performing complex operations on a large scale. You can use REST API tools to create, manipulate,
and search data in Salesforce by sending HTTP requests to endpoints in Salesforce.
Depending on where you send requests, you access and operate on different pieces of information, called resources.
Resources include records, query results, metadata, and more. ",
"version": "63.0
},
"servers": [
...
],
"security": [
...
],
"paths": {
"/sobjects": { ... },
"/sobjects/{sObject}": { ... },
"/sobjects/{sObject}/{id}": { ... },
"/sobjects/{sObject}/deleted": { ... },
"/sobjects/{sObject}/describe": { ... },
"/sobjects/{sObject}/{id}/{blobField}": { ... }
},
"components": {
...
}
}
If you select a resource that doesn’t match any of the supported resources, or you select a resource that you don’t have permissions to access, the request doesn’t fail but the OpenAPI document won’t contain that resource. Also, the resource’s path won’t be visible in the OpenAPI document.
After the OpenAPI document is generated, you can retrieve the OpenAPI document again by using the same locator ID for 48 hours. After 48 hours, using that locator ID results in a 404 (Not Found) error.
Giving Feedback
To give us your feedback, log in to Trailhead and then join the OpenAPI Specs for Salesforce REST APIs Trailblazer Community.
Your feedback is valuable and can help us find existing problems and inspire future change. We’re looking for general impressions, improvement suggestions, bugs, and feedback about how well this OpenAPI document aligns with your OpenAPI use cases.