Databases

Connect a database that stays where it is (Neon, Supabase, PlanetScale, Upstash, MongoDB Atlas, …) to a project: the URL is checked (public addresses only), tested once and stored only as the project's encrypted variables (DATABASE_URL and the usual framework names)

post/projects/{projectId}/databases/external

Request

  • Base URL: https://hostingsurge.com/api/v1
  • URL: https://hostingsurge.com/api/v1/projects/{projectId}/databases/external
  • Auth: one of:
    • HTTP bearer
    • API key in cookie __Host-hs_session

Path parameters

projectIdstring uuid required
Example:3f2b8a4e-5c1d-4e8f-9a7b-2c6d1e0f4a5b

Request body

urlstring required

Connection URL with credentials: postgresql://, postgres://, mysql://, mariadb://, mongodb://, mongodb+srv://, redis:// or rediss://. Stored only as the project's encrypted variables; never returned or logged

tls'prefer' | 'require' | 'verify-full' | 'disable'

TLS for the test: prefer (default), require, verify-full or disable; the app follows the URL's own options

conventionsboolean

true (default): every name the usual frameworks read (PostgreSQL: DATABASE_URL, DATABASE_URL_UNPOOLED, POSTGRES_URL, POSTGRES_PRISMA_URL, POSTGRES_URL_NON_POOLING, POSTGRES_HOST/USER/PASSWORD/DATABASE and PG*; MySQL: DATABASE_URL, MYSQL_URL and MYSQL_*; MongoDB: MONGODB_URI, MONGO_URL, DATABASE_URL; Redis: REDIS_URL, KV_URL). false: envKey alone

envKeystring

the main variable (default DATABASE_URL, MONGODB_URI for MongoDB, REDIS_URL for Redis)

testboolean

false saves without the connection test (e.g. a firewall that only lets the app's server in)

overwriteboolean

replace variables of those names that the project already has (otherwise 409 conflict with their names)

redeployboolean

deploy the project again so the running app gets the variables

Response

Connected, or the test failed and nothing was saved (state test_failed)

state'connected' | 'test_failed' required

test_failed: nothing was saved; fix what the message says, or save with test: false

engine'postgresql' | 'mysql' | 'mariadb' | 'mongodb' | 'redis' required
hoststring required

the server, without credentials

variablesstring[] required

the names written (connected) or that would be written (test_failed)

deploymentIdstring uuid nullable required

redeploy: the new deployment

Changes

No recorded changes to this operation across all 1 revision of this API.