Skip to content

Create a managed database binding

POST
/api/databases/managed/{id}/bindings
curl --request POST \
--url https://gateway.example.com/api/databases/managed/550e8400-e29b-41d4-a716-446655440000/bindings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "targetNodeId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "targetType": "container", "targetResourceId": "example", "environment": { "connectionUri": "example", "host": "example", "port": "example", "database": "example", "username": "example", "password": "example" }, "replaceExistingEnvironment": true, "targetEnvironment": { "additionalProperty": "example" } }'

The link is saved into the workload whatever it is doing and the call does not wait for the workload to become healthy; observedState is target_applied until the workload runs it, then active. A Git-source container whose first build has not created it yet is linked by its name, authorized on its reserved identity, and its first build starts it with the link. A Compose service may be linked before the project’s first revision or while a build rollout or another operation holds the project, by a service name the next revision defines; the link fails with the reason when that revision lacks the service.

id
required
string
>= 1 characters
Example
550e8400-e29b-41d4-a716-446655440000

JSON request body

Media typeapplication/json
object
targetNodeId
required
string format: uuid
targetType
required
string
Allowed values: container deployment compose_service
targetResourceId
required
string
>= 1 characters <= 255 characters
environment
required

The environment variable names the link injects into its workload, by value. At least one is required (400 MANAGED_DATABASE_BINDING_ENV_REQUIRED).

object
connectionUri
string
>= 1 characters <= 128 characters /^[A-Za-z_][A-Za-z0-9_]*$/
host
string
>= 1 characters <= 128 characters /^[A-Za-z_][A-Za-z0-9_]*$/
port
string
>= 1 characters <= 128 characters /^[A-Za-z_][A-Za-z0-9_]*$/
database
string
>= 1 characters <= 128 characters /^[A-Za-z_][A-Za-z0-9_]*$/
username
string
>= 1 characters <= 128 characters /^[A-Za-z_][A-Za-z0-9_]*$/
password
string
>= 1 characters <= 128 characters /^[A-Za-z_][A-Za-z0-9_]*$/
replaceExistingEnvironment
boolean
targetEnvironment
object
key
additional properties
string

Created

Media typeapplication/json
object
data
required

Resource object. Exact fields depend on the endpoint.

object
id
string
name
string
key
additional properties
Example
{
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Production Postgres",
"type": "postgres",
"healthStatus": "online"
}
}

Bad request

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": [
{
"path": [
"name"
],
"message": "Required"
}
]
}

Authentication required

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "UNAUTHORIZED",
"message": "Authentication required"
}

Forbidden

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "FORBIDDEN",
"message": "Insufficient permissions"
}

Not found

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "NOT_FOUND",
"message": "Resource not found"
}

Conflict

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "CONFLICT",
"message": "Resource already exists"
}

Unprocessable entity

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "UNPROCESSABLE_ENTITY",
"message": "Request could not be processed"
}

Internal server error

Media typeapplication/json
object
code
required

Error code

string
message
required

Human-readable error message

string
details

Additional error details

Example
{
"code": "INTERNAL_ERROR",
"message": "Internal server error"
}