Skip to content
EleforkDocs
Internal preview. Elefork is not publicly available yet; APIs and hostnames may change.

Quickstart

Create a branch, connect with psql, fork it and reset it.

You need an API token (elefork_…) for your organization.

Terminal window
pip install 'elefork[mcp,sql]'
export ELEFORK_URL=https://api.elefork.com
export ELEFORK_TOKEN=elefork_...
Terminal window
elefork project create demo # returns when its default branch "main" is running
export ELEFORK_PROJECT=demo
elefork branch list # main never expires; note its id (br_...)

To start from another template, pass --template (elefork templates lists them); --no-branch creates an empty project.

Get short-lived credentials and connect with any Postgres client:

Terminal window
psql "$(elefork branch credentials br_...)"

The command prints a URI like this one:

postgresql://postgres:<token>@br-xxxx.db.elefork.com:5432/postgres?sslmode=verify-full

The password is a JWT that is valid for one hour by default. The hostname selects your branch (see Connecting).

sslmode=verify-full checks the server certificate against libpq’s root certificates, which default to ~/.postgresql/root.crt. Most machines do not have that file; to use the operating system’s trusted CAs instead (libpq 16 or later), set:

Terminal window
export PGSSLROOTCERT=system

(or add &sslrootcert=system to the URI). elefork export and elefork import do this for you when neither PGSSLROOTCERT nor ~/.postgresql/root.crt is set.

Without a driver, run SQL through the API (as the postgres role, through the same gateway):

Terminal window
elefork sql br_... "create table t(id int primary key); insert into t values (1); select * from t"

The script runs as one transaction: if a statement fails, the statements before it are rolled back too.

The console has the same flow: create a project, copy the connection string, then use the Tables, SQL Editor and Monitoring tabs of a branch.

Terminal window
elefork checkpoint create br_main --name seed # snapshot
elefork branch create --checkpoint ckp_... --count 10 # 10 identical copies
elefork branch create --parent br_main # fork the current state
elefork branch reset br_main --checkpoint ckp_... # back to the snapshot
Terminal window
elefork branch delete br_...

L0 branches you forget about are deleted after 24 hours (see Branches).

from elefork import Client
c = Client() # reads ELEFORK_URL / ELEFORK_TOKEN
project = c.project_by_name("demo")["id"]
main = c.create_branch(project, template="pg18", name="main")
ck = c.checkpoint(main["id"], "seed")
envs = c.create_branches(project, checkpoint=ck["id"], count=10, name="env")
creds = c.credentials(main["id"]) # creds["uri"] works with psycopg, asyncpg, …
c.reset(main["id"], ck["id"])