Internal preview. Elefork is not publicly available yet; APIs and hostnames may change.
POST
/v1/branches/{id}/credentials
package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.elefork.com/v1/branches/example/credentials"
payload := strings.NewReader("{ \"role\": \"postgres\", \"database\": \"postgres\", \"ttl_seconds\": 3600 }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}const url = 'https://api.elefork.com/v1/branches/example/credentials';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"role":"postgres","database":"postgres","ttl_seconds":3600}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.elefork.com/v1/branches/example/credentials \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "role": "postgres", "database": "postgres", "ttl_seconds": 3600 }'A short-lived JWT used as the Postgres password at the gateway, plus a ready libpq URI.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”id
required
string
Request Body
Section titled “Request Body”Media typeapplication/json
object
role
Database role. On L2 branches postgres is not a superuser (CREATEDB, CREATEROLE). Roles starting with elefork_ are reserved for the platform (400).
string
database
string
ttl_seconds
integer
Responses
Section titled “Responses”Credentials
Media typeapplication/json
object
host
required
<branch id with - instead of _>.db.
string
port
required
integer
user
required
string
database
required
string
password
required
Short-lived JWT.
string
expires_at
required
string format: date-time
token_id
required
string
uri
required
string
Example generated
{ "host": "example", "port": 1, "user": "example", "database": "example", "password": "example", "expires_at": "2026-04-15T12:00:00Z", "token_id": "example", "uri": "example"}Error
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
Example
{ "error": { "code": "not_found" }}Error
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
Example
{ "error": { "code": "not_found" }}Error
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
Example
{ "error": { "code": "not_found" }}Error
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
Example
{ "error": { "code": "not_found" }}The branch’s episode is sealed (branch_sealed)
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
Example
{ "error": { "code": "not_found" }}Error
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
Example
{ "error": { "code": "not_found" }}Temporarily unavailable; retry after the Retry-After seconds. Codes:
database_unavailable (the metadata database is failing over) and
cube_admission (a compute node runs a sandbox shim below the
platform minimum, so creates, forks, checkpoints and resets are
refused until it is upgraded).
Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
Example
{ "error": { "code": "not_found" }}Headers
Section titled “Headers”Retry-After
integer