Skip to main content
GET
/
v1
/
misc
/
db
Get Db
curl --request GET \
  --url https://api.xpander.ai/v1/misc/db \
  --header 'x-api-key: <api-key>'
{
  "connection_uri": "postgresql://user:***@host:5432/dbname?sslmode=require"
}
Retrieve the PostgreSQL database connection details for your organization. This provides direct access to your organization’s database instance for custom analytics, integrations, and data management.

Response

id
string
Database project identifier
name
string
Database project name (typically org_[organization_id])
organization_id
string
Your organization UUID
connection_uri
object
Database connection details

Example Request

curl -X GET -H "x-api-key: <your-api-key>" \
  https://api.xpander.ai/v1/misc/db

Example Response

{
  "id": "still-meadow-47437464",
  "name": "org_f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "organization_id": "<org-id>",
  "connection_uri": {
    "uri": "postgresql://<user>:<password>@<host>/<database>?sslmode=require"
  }
}

Usage Examples

Python (psycopg2)

import psycopg2
import requests

# Get connection string
response = requests.get(
    "https://api.xpander.ai/v1/misc/db",
    headers={"x-api-key": "<your-api-key>"}
)
connection_uri = response.json()["connection_uri"]["uri"]

# Connect to database
conn = psycopg2.connect(connection_uri)
cursor = conn.cursor()

# Query data
cursor.execute("SELECT * FROM agents LIMIT 10")
results = cursor.fetchall()

cursor.close()
conn.close()

Node.js (pg)

const fetch = require('node-fetch');
const { Client } = require('pg');

// Get connection string
const response = await fetch('https://api.xpander.ai/v1/misc/db', {
  headers: { 'x-api-key': '<your-api-key>' }
});
const { connection_uri } = await response.json();

// Connect to database
const client = new Client({
  connectionString: connection_uri.uri
});
await client.connect();

// Query data
const result = await client.query('SELECT * FROM agents LIMIT 10');
console.log(result.rows);

await client.end();

CLI (psql)

# Get connection string and connect
psql "$(curl -s -H 'x-api-key: <your-api-key>' \
  https://api.xpander.ai/v1/misc/db | jq -r '.connection_uri.uri')"

Database Schema

Your organization database contains tables for:
  • agents - Agent configurations and metadata
  • tasks - Task execution records
  • knowledge_bases - Knowledge base metadata
  • documents - Document records and processing status
  • users - User information and permissions
  • organization - Organization settings and data
  • And more…

Security Notes

  • The connection string includes credentials - keep it secure
  • Store the connection string as an environment variable, never in version control
  • Use HTTPS only when retrieving connection strings
  • The database requires SSL connections (sslmode=require)
  • Be cautious with write operations to avoid accidental data modification
  • Regularly rotate credentials in your organization settings

Use Cases

  • Custom analytics - Query task and agent data directly for reporting
  • Data export - Extract data for external analysis and backup
  • Business intelligence - Connect BI tools like Tableau, Metabase, Power BI
  • Integration - Build custom integrations with third-party systems
  • Automation - Create automated data processing pipelines
  • Advanced queries - Perform complex SQL queries not available via REST API

Notes

  • This is a Neon PostgreSQL serverless database
  • Connection pooling is handled automatically
  • Database is located in AWS us-west-2 region
  • SSL connections are required for security
  • Connection credentials are organization-specific and should not be shared

Authorizations

x-api-key
string
header
required

API Key for authentication

Response

Successful Response

Represents a Neon project used in xpander.ai for managing database resources.

Attributes: id (str): Unique identifier for the Neon project. name (str): Name of the Neon project. organization_id (Optional[str]): The associated organization ID, inferred from the name if not provided. connection_uri (Optional[ConnectionURIResponse]): The connection URI for the project.

id
string
name
string
organization_id
string | null
connection_uri
ConnectionURIResponse · object