Loading

Debug Automated or System Users Using Tooling API in Salesforce

Julkaisupäivä: Jun 25, 2026
Kuvaus

The standard Debug Logs page in Salesforce Setup does not allow setting up debug logs for automated or system-level users, such as S2S (Salesforce-to-Salesforce) connection users or integration users. To capture debug logs for these users, you must use the Salesforce Tooling API to create a TraceFlag record manually. A TraceFlag defines the debug log scope — including who to debug, when to start and stop, and what logging level to apply.

Ratkaisu

Steps to Create a Debug Log for a System User

Use Workbench's REST Explorer to send a POST request to the Tooling API TraceFlag endpoint. Workbench is a free Salesforce developer tool available at workbench.developerforce.com.

  1. Log in to Workbench and navigate to Utilities > REST Explorer.
  2. Select the POST method.
  3. Enter the Tooling API URI: /services/data/v35.0/tooling/sobjects/TraceFlag/
  4. In the request body, provide the following required fields:
    1. TracedEntityId — the 15 or 18-character Salesforce User ID of the system user you want to debug. You can obtain this by querying the record that was created or updated by that user.
    2. ExpirationDate — the date and time (in ISO 8601 format) when the debug log should stop collecting data.
    3. StartDate — the date and time when the debug log should begin collecting data.
    4. LogType — set this to USER_DEBUG to capture user-level debug information.
    5. DebugLevelId — the ID of an existing DebugLevel configuration. This controls the granularity of the log (e.g., FINEST, DEBUG, ERROR).
/services/data/v35.0/tooling/sobjects/TraceFlag/

{ 
 "TracedEntityId" : "005i0000002Xx2qAAC", 
 "ExpirationDate" : "2016-01-07T15:04:31.000+0000", 
 "DebugLevelId" : "7dli0000000GmaEAAS", 
 "LogType" : "USER_DEBUG", 
 "StartDate" : "2016-01-07T14:34:31.000+0000" 
 }

How to Find Your DebugLevelId

To obtain the DebugLevelId, run the query "SELECT Id, DeveloperName FROM DebugLevel" in the Developer Console. Make sure to check the Tooling API checkbox in the Query Editor to enable Tooling API queries. The returned Id values correspond to available debug levels you can use in your TraceFlag request.

Knowledge-artikkelin numero

000386565

 
Ladataan
Salesforce Help | Article