# Query Code Extension Logs by Using the Query API

Use the Data 360 Query API to programmatically retrieve logs generated for code extension runs. Logs are stored in the Data Lake Object (DLO) named `DataCustomCodeLogs__dll`. You can query them like any other DLO.

| Edition Table                                                                                                                                                                                                 |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Available in: **Developer**, **Enterprise**, **Performance**, and **Unlimited** Editions. See Data 360 [edition availability](https://help.salesforce.com/s/articleView?id=sf.c360_a_dc_editions.htm&type=5). |

| User Permissions Needed                              |                                                        |
| :--------------------------------------------------- | :----------------------------------------------------- |
| To query code extension logs by using the Query API: | Permission set: <ul><li>Data Cloud Architect</li></ul> |

## Prerequisites

- Data 360 access with permission to query data
- Enable Code Extension in Data Cloud Setup by using the Feature Manager. See [Enable Data 360 Features in Feature Manager](https://help.salesforce.com/s/articleView?id=data.c360\_a_feature_manager.htm\&language=en_US\&type=5).
- Authenticate to the Data 360 Connect API. See [Get Started with Data 360 Connect API](https://developer.salesforce.com/docs/data/connectapi/guide/get-started.md).
- A completed batch transform or search index run

## Considerations

- **Latency:** Logs typically appear within a few minutes after code execution. Allow up to about 10 minutes.
- **Message limits:** Maximum log message length is 31,072 characters. Longer messages are truncated.

## Steps to Query Code Extension Logs by Using the Query API

1. Understand the relevant fields of the `DataCustomCodeLogs__dll` DLO.
   - `EventId__c` — DLO primary key for each log record
   - `Timestamp__c` — Log record timestamp
   - `Message__c` — Your log message
   - `CorrelationId__c` — Correlates your code extension logs to Data 360 internal logs
   - `DataCustomCodeName__c` — Name of the code extension package
   - `ProcessDefinitionName__c` — Name of the batch data transform or search index that uses the code package
   - `ExecutionId__c` — Unique identifier for the code execution. More than one `CorrelationId__c` can share one execution
   - `UsedInFeature__c` — Feature where the code is used, for example, batch data transform
   - `OrgId__c` — Org identifier

2. Create your SQL query to query the `DataCustomCodeLogs__dll` DLO like any other Data 360 object. See [Create sql query](https://developer.salesforce.com/docs/data/connectapi/references/spec?meta=createSqlQuery).

   **Examples**

   - Filter by transform (process) name.

   ```
   curl -X POST "https://{yourInstance}/services/data/v64.0/ssot/query-sql" \
     -H "Authorization: Bearer ${ACCESS_TOKEN}" \
     -H "Content-Type: application/json" \
     -d '{
       "sql": "SELECT \"Timestamp__c\", \"Message__c\" FROM \"DataCustomCodeLogs__dll\" WHERE \"ProcessDefinitionName__c\" = '\''MyTransformName'\'' ORDER BY \"Timestamp__c\" DESC LIMIT 100"
     }'
   ```

   - Filter by code extension package name.

   ```
   curl -X POST "https://{yourInstance}/services/data/v64.0/ssot/query-sql" \
     -H "Authorization: Bearer ${ACCESS_TOKEN}" \
     -H "Content-Type: application/json" \
     -d '{
       "sql": "SELECT \"Timestamp__c\", \"Message__c\" FROM \"DataCustomCodeLogs__dll\" WHERE \"DataCustomCodeName__c\" = '\''my_custom_code'\'' ORDER BY \"Timestamp__c\" DESC LIMIT 100"
     }'
   ```

   - Filter by execution ID.

   ```
   curl -X POST "https://{yourInstance}/services/data/v64.0/ssot/query-sql" \
     -H "Authorization: Bearer ${ACCESS_TOKEN}" \
     -H "Content-Type: application/json" \
     -d '{
       "sql": "SELECT * FROM \"DataCustomCodeLogs__dll\" WHERE \"ExecutionId__c\" = '\''00000000-0000-0000-0000-000000000000'\'' ORDER BY \"Timestamp__c\" DESC"
     }'
   ```

   - Filter by correlation ID.

   ```
   curl -X POST "https://{yourInstance}/services/data/v64.0/ssot/query-sql" \
     -H "Authorization: Bearer ${ACCESS_TOKEN}" \
     -H "Content-Type: application/json" \
     -d '{
       "sql": "SELECT * FROM \"DataCustomCodeLogs__dll\" WHERE \"CorrelationId__c\" = '\''00000000-0000-0000-0000-000000000000'\'' ORDER BY \"Timestamp__c\" DESC"
     }'
   ```

3. Check the query status. See [Get SQL Query Status](https://developer.salesforce.com/docs/data/connectapi/references/spec?meta=getSqlQuery).

4. (Optional) Retrieve additional rows.
   If your query returns more data than the initial response, retrieve additional rows. See [getSqlQueryRows](https://developer.salesforce.com/docs/data/connectapi/references/spec?meta=getSqlQueryRows).

## See Also

- [Query Code Extension Logs by Using Query Editor](/docs/data/data-cloud-code-ext/guide/query-logs-queryeditor.md)
- [Query Code Extension Logs by Using Salesforce CLI](/docs/data/data-cloud-code-ext/guide/query-logs-cli.md)
