Skip to content

Connections

Connections are what the agent can reach. There are two kinds:

Kind Who connects it Who the agent uses it for Today
Company An admin, in Klaris or through this API Everyone in the workspace Google Cloud SQL (Postgres), Google Drive (company files)
Personal Each person, by signing in to their own account Only that person Gmail

They're the same connections as on Data → Connectors in Klaris. Whatever you add here shows there, and the other way round. Logins are stored encrypted and are never sent back, not even to you.

GET /connections/types lists every kind, with the fields each needs and what the agent can do with it.

Company connections

Add one

curl "$KLARIS_API/connections" \
  -H "Authorization: Bearer $KLARIS_KEY" -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "type": "cloud_sql_postgres",
  "name": "Policy database",
  "values": {
    "instance_connection_name": "acme-prod:us-east1:policies",
    "database": "policies",
    "db_user": "klaris-reader",
    "db_password": "…",
    "service_account_json": {"type": "service_account", "project_id": "acme-prod", "client_email": "klaris-reader@acme-prod.iam.gserviceaccount.com", "private_key": "-----BEGIN PRIVATE KEY-----\n…"},
    "schemas": "public, reporting"
  }
}
JSON
import json
key_file = json.load(open("klaris-reader-key.json"))
connection = requests.post(f"{API}/connections", headers={"Authorization": f"Bearer {KEY}"}, json={
    "type": "google_drive_files",
    "name": "Shared drive",
    "values": {"service_account_json": key_file},
}).json()

Google Cloud SQL (Postgres), cloud_sql_postgres:

Field
instance_connection_name required From the instance page in Google Cloud, like project:region:instance.
database required
db_user required A user that can read the tables the agent should see. For a service-account login, the account's email without .gserviceaccount.com.
db_password secret Leave out to sign in as the service account (IAM).
service_account_json required, secret The key file of a service account with the Cloud SQL Client role.
schemas Comma-separated. Default public.

The agent can list tables, describe a table, look at sample rows and run read-only queries. It can't change anything in the database: every query runs read-only, and is stopped after a time limit.

Google Drive (company files), google_drive_files:

Field
service_account_json required, secret The key file of a Google service account. Share the shared drive or folders the agent may read with its email.
impersonate Only with domain-wide delegation set up by your Google Workspace admin: the person whose Drive the agent reads. Leave out to see only what's shared with the service account.

The agent can search, list folders, and read Google Docs, Sheets and Slides, PDFs (not scanned ones), Word files and text files up to 20 MB. Shared drives are included.

Check it

A new connection isn't used until it has been checked and works:

curl -X POST "$KLARIS_API/connections/{id}/check" -H "Authorization: Bearer $KLARIS_KEY"

The connection comes back with status ok or failed, and a plain detail, such as "Connected as klaris-reader. 42 tables and views in public, reporting." or what to fix.

Change or remove it

  • PATCH /connections/{id} with name and/or the values that change. A secret sent as an empty string is removed.
  • DELETE /connections/{id} removes it. The agent stops using it straight away.

Personal connections

A person connects their own Gmail by signing in to Google themselves. Your app never sees their Google password or tokens.

curl "$KLARIS_API/connections/connect_link" \
  -H "Authorization: Bearer $KLARIS_KEY" -H "Content-Type: application/json" \
  -d '{
    "user": "nick@example.com",
    "type": "gmail",
    "return_url": "https://app.example.com/settings/assistant"
  }'
link = requests.post(f"{API}/connections/connect_link", headers={"Authorization": f"Bearer {KEY}"}, json={
    "user": "nick@example.com",
    "type": "gmail",
    "return_url": "https://app.example.com/settings/assistant",
}).json()
# Send the person's browser to link["url"]
{
  "object": "connect_link",
  "url": "https://accounts.google.com/o/oauth2/v2/auth?…",
  "expires_at": 1793900600
}

The link works once, within 10 minutes. Open it in the person's browser: a button in your app, or a redirect.

2. The person signs in and comes back

After Google, the person is sent to your return_url with the result added:

Added to the address Meaning
connected=gmail&ok=1 Connected. The agent can use their Gmail from now on.
connected=gmail&ok=0&reason=cancelled They cancelled on Google's screen.
connected=gmail&ok=0&reason=google_error Google refused. Try again.
connected=gmail&ok=0&reason=not_working Signed in, but the mailbox couldn't be read.
connected=gmail&ok=0&reason=no_lasting_sign_in Google didn't give lasting access. Try again.
connected=gmail&ok=0&reason=link_used The link was already used. Make a new one.

return_url must be one of your workspace's allowed return addresses, set on Settings → API Keys. A return address matches when the scheme, host and port are the same and the path starts with the allowed one. This stops a link being used to send people somewhere else. Leave return_url out and the person lands on a Klaris page that tells them it worked and to go back to your app.

What the agent can do with Gmail

It can search and read mail, and draft and send emails. Drafting and sending always wait for the person's yes. See Approvals.

See or remove a person's connection

  • GET /connections?user=… lists company connections plus that person's own.
  • DELETE /connections/{id}?user=… disconnects it. For a personal connection, user must be its owner.

A connection

{
  "id": "6b0e2f0c-…",
  "name": "Policy database",
  "type": "cloud_sql_postgres",
  "label": "Google Cloud SQL (Postgres)",
  "scope": "company",
  "status": "ok",
  "detail": "Connected as klaris-reader. 42 tables and views in public, reporting.",
  "warnings": [],
  "checked_at": "2026-11-05T09:12:44",
  "created_via": "api",
  "settings": {
    "instance_connection_name": "acme-prod:us-east1:policies",
    "database": "policies",
    "db_user": "klaris-reader",
    "schemas": "public, reporting"
  },
  "secrets_set": {
    "db_password": true,
    "service_account_json": true
  },
  "service_account_email": "klaris-reader@acme-prod.iam.gserviceaccount.com",
  "abilities": [],
  "address": null
}

abilities lists what the agent can do with a connection on its own. A SQL database has none: the agent reads it through its data skill, on top of the workspace's data model.

secrets_set tells you which secrets are stored, never what they are. For a personal connection, address is the account's email address.