Sessions

Create and manage isolated database sessions.

Create session

Creates a new isolated session. All mutations within this session are staged in shadow tables until approved.

POST /sessions
Request
curl -X POST http://localhost:8080/sessions \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "my-project"
  }'
Response
{
  "session_id": "sess_abc123def456",
  "project_id": "my-project",
  "status": "active",
  "created_at": "2024-01-15T10:30:00Z"
}

Request body

project_idstringProject identifier for grouping sessions
metadataobjectOptional key-value metadata

Get session

Retrieve details about an existing session including its status and mutation count.

GET /sessions/:id
Response
{
  "session_id": "sess_abc123def456",
  "project_id": "my-project",
  "status": "active",
  "mutation_count": 3,
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:35:00Z"
}

Session statuses

activeSession is open for mutations
proposedSubmitted for review, read-only
approvedChanges applied to production
rejectedChanges discarded

Delete session

Destroy a session and discard all staged changes. Only works for active or proposed sessions.

DELETE /sessions/:id
Response
{
  "session_id": "sess_abc123def456",
  "status": "deleted",
  "deleted_at": "2024-01-15T10:40:00Z"
}

Connect via Postgres

Use the session ID to route your Postgres connection through the proxy. All queries will be isolated to your session.

psql
psql "host=localhost port=5433 dbname=mydb \
  options='-c astapa_session=sess_abc123def456'"
Connection string
postgresql://user:pass@localhost:5433/mydb?options=-c%20astapa_session%3Dsess_abc123def456