Skip to main content
Human guide: work with your agent →
Read one bounded customer query and distinguish permitted customer writes from managed data.
For an application or agent, query the Database through the Deepline API. Your Deepline API key selects the workspace. The API runs one bounded SQL statement against that workspace’s Database. You do not need to expose a PostgreSQL connection string. Use a direct PostgreSQL URI only when a database-native tool, such as BI or psql, genuinely needs one.

Query the API securely

Send the request from your server, worker, or trusted agent runtime. Keep DEEPLINE_API_KEY in server-side secret storage. Never put it in a browser application or commit it to source control.
A successful response returns rows, columns, row_count_returned, and truncated. An empty rows array means the query ran but found no matches.
The API accepts one SQL statement and up to 1,000 returned rows per request. Use max_rows to bound the result you need.

Use the SDK

The SDK uses the same API boundary:

Query rules

For example, an agent or application can create its own scratch table:
These statements are intentionally blocked:
Customer-managed schemas can also be created and used through this API, for example CREATE SCHEMA tenant_custom, followed by a separate qualified CREATE TABLE tenant_custom.agent_notes (...) statement. Reserved names and internal objects remain protected. See the Database contract.

Keep the boundary safe

  • Do not forward arbitrary browser input as SQL. Build queries in trusted server-side code and constrain the tables, columns, and filters your product permits.
  • Do not accept query text from an end user. Use fixed, allowlisted queries and validate request values before your server builds the SQL. Treat raw SQL as privileged input.
  • Set max_rows and select only the columns your caller needs.
  • Use the Database for working state. Write approved outcomes to your CRM. See Where data lives.

Direct PostgreSQL access

Use a Database URI only for a database-native application or BI tool. Obtain it from the dashboard’s Database Access flow, store it in server-side secret storage, and write only to permitted customer storage objects. Provisioning, URI reveal, and password rotation are dashboard/admin-session controls. they are not the public query API.

SDK API reference

See the supported POST /api/v2/db/query contract and SDK method.

Verify this task

Inspect returned columns, row count, and truncation. Test writes only in permitted customer-owned objects, not managed enrichment views. Ask your agent to explain a failed check before repeating work or expanding the scope.