You need an API token (elefork_…) for your organization.
1. Install the CLI and SDK
Section titled “1. Install the CLI and SDK”pip install 'elefork[mcp,sql]'export ELEFORK_URL=https://api.elefork.comexport ELEFORK_TOKEN=elefork_...2. Create a project
Section titled “2. Create a project”elefork project create demo # returns when its default branch "main" is runningexport ELEFORK_PROJECT=demoelefork 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.
3. Connect
Section titled “3. Connect”Get short-lived credentials and connect with any Postgres client:
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-fullThe 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:
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):
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.
4. Checkpoint, fork, reset
Section titled “4. Checkpoint, fork, reset”elefork checkpoint create br_main --name seed # snapshotelefork branch create --checkpoint ckp_... --count 10 # 10 identical copieselefork branch create --parent br_main # fork the current stateelefork branch reset br_main --checkpoint ckp_... # back to the snapshot5. Clean up
Section titled “5. Clean up”elefork branch delete br_...L0 branches you forget about are deleted after 24 hours (see Branches).
The same in Python
Section titled “The same in Python”from elefork import Client
c = Client() # reads ELEFORK_URL / ELEFORK_TOKENproject = 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"])