Newer Version Available
Generating an OpenAPI 3.0 Specification for sObjects REST API (Beta)
This Beta feature enables you to generate an OpenAPI specification that represents four sObjects REST API resources reflecting the customizations and configurations in your org.
Supported Editions
This Beta feature is available to Developer Editions, Partner Developer Editions, sandboxes, and scratch orgs that have API Enabled.
About the Specification
This specification uses Version 3.0.1 of the OpenAPI Specification. For more information, see https://www.openapis.org.
What the Specification Covers
This specification describes four REST API resources that allow you to retrieve, create, and update object data in your org.
-
/services/data/vXX.X/sobjects/
- 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.
- See Describe Global.
-
/services/data/vXX.X/sobjects/sObject/
- Describes the individual metadata for the specified object. Can also be used to create a new record for a given object. For example, this can be used to retrieve the metadata for the Account object using the GET method, or create a new Account object using the POST method.
- See sObject Basic Information.
-
/services/data/vXX.X/sobjects/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.
- See sObject Describe.
-
/services/data/vXX.X/sobjects/sObject/id/
- 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.
- See sObject Rows.
Enabling the Beta
To enable this beta, follow these steps. (You must have either the “Modify All Data” or the “Customize Application” permission.)
- From Setup, enter 'User Interface' in the Quick Find box and access the 'User Interface' page.
- On the User Interface page, select Enable Salesforce Platform REST API, OpenAPI 3.0 Spec Generation (Beta).
- Click Save.
Generating a Specification for Your Org
After the Beta has been enabled, generate the specification by following these steps. (You must have either the “Modify All Data” or the “Customize Application” permission.)
-
Authenticate as usual when using the Lightning Platform REST API.
-
Send a GET request to
The API version must be 54.0 or greater.
If the server encounters errors processing the request, it reports a “Failed” status and returns a 4xx or 5xx status.
-
Assuming the request can be parsed without errors, the server responds with JSON that contains a URI where the specification can be obtained. For example:
The last part of this URI (NTByUjAwMDAwMDAwMDBh in this example) is referred to as the locator ID for the specification.
-
Send a GET request to the same URI with the locator ID appended. For example:
-
If the server hasn’t finished preparing the specification yet, it responds with a 202 (Accepted) status code and a status message of “Not Started” or “In Progress”. For example:
-
If the server has finished, it responds with a 200 (OK) status and returns the specification in the response body. For example:
-
After the specification has been generated, you can retrieve the specification again (using the same locator ID) for 48 hours. After 48 hours, using that locator ID results in a 404 (Not Found) error.
A new specification can only be generated every 6 hours per user. If you call /async/specifications/oas3 again within 6 hours of the last generation, the API returns the same locator ID.
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 specification aligns with your OpenAPI use cases.