Private Connections API

Use these routes to read an organization's visible resources, create and remove private connections between applications, scheduled Jobs, databases, and Valkey, and save map card positions. The layout is independent and does not change connections, permissions, or resource settings.

Authentication and authorization

These routes require a valid user session. API keys are not accepted and return 401. Select the active organization: the x-organization-id header must match the organization ID in the route.

Authorization: Bearer <user-token>
x-organization-id: <organization-id>
Content-Type: application/json

To read the map, the user must be able to view the organization's resources. Creating or removing a connection requires two permissions:

PermissionWhere
project.connections.outgoing.updateSource (application or scheduled Job)
project.connections.incoming.updateTarget (application, database, or Valkey)

The organization owner has all permissions. Responses describe only resources the user can view and do not include credentials or implementation details.

Base URL and routes

https://api.zenifra.com/v1
PurposeMethod and route
Read resources and connectionsGET /organizations/:id/connections
Create a connectionPUT /organizations/:id/connections/:sourceId/:targetId
Remove a connectionDELETE /organizations/:id/connections/:sourceId/:targetId
Read the map layoutGET /organizations/:id/connection-layout
Save the map layoutPUT /organizations/:id/connection-layout

Read the map

GET /v1/organizations/:id/connections

The response uses the { "data": ... } envelope and contains nodes (visible resources) and connections (connections between resources). Sources can be HTTP applications and scheduled Jobs; targets can be HTTP applications, PostgreSQL, MariaDB, ClickHouse, and Valkey. Databases and Valkey are never a source, and Jobs are never a target.

{
  "data": {
    "nodes": [
      {
        "id": "<application-id>",
        "name": "Checkout API",
        "kind": "application",
        "status": "<resource-status>",
        "eligible": true,
        "sourceEligible": true,
        "targetEligible": true,
        "internalHostname": "checkout-api.6a11bedda78ad3108eb20e2c.zenifra.local"
      },
      {
        "id": "<another-application-id>",
        "name": "Orders worker",
        "kind": "application",
        "status": "<resource-status>",
        "eligible": true,
        "sourceEligible": true,
        "targetEligible": true
      },
      {
        "id": "<database-id>",
        "name": "Orders PostgreSQL database",
        "kind": "database",
        "status": "<resource-status>",
        "eligible": true,
        "sourceEligible": false,
        "targetEligible": true,
        "internalHostname": "orders-db.6a11bedda78ad3108eb20e2c.zenifra.local",
        "internalPort": 5432,
        "internalReadHostname": "ro.orders-db.6a11bedda78ad3108eb20e2c.zenifra.local"
      },
      {
        "id": "<job-id>",
        "name": "Nightly report",
        "kind": "job",
        "status": "<resource-status>",
        "eligible": true,
        "sourceEligible": true,
        "targetEligible": false
      }
    ],
    "connections": [
      {
        "id": "<connection-id>",
        "sourceId": "<another-application-id>",
        "targetId": "<application-id>",
        "status": "active"
      }
    ]
  }
}

Resources (nodes)

FieldDescription
id, name, statusIdentification and current state of the resource.
kindResource family, such as application, job, database, or managed_service.
eligibleWhether the resource can take part in connections.
sourceEligibleWhether the resource can be a source.
targetEligibleWhether the resource can be a target.
reasonReason, when the resource is not eligible.
internalHostnameThe project's internal address. Present after the project becomes the target of a connection for the first time, and stays afterward. It is released if the project is deleted.
internalPortPort of the internal address. Present on managed targets (PostgreSQL 5432, MariaDB 3306, ClickHouse 9440, which also allows the HTTPS port 8443; Valkey the service port). On HTTP applications the port is the default one and the field is absent.
internalReadHostnameInternal read address (ro.<project>.<organization-id>.zenifra.local). Present only on PostgreSQL or MariaDB databases with replicas (plans with more than one instance).

Connections (connections)

FieldDescription
idConnection identifier.
sourceIdSource (the caller): an HTTP application or a scheduled Job.
targetIdTarget (the receiver): an HTTP application, a database, or Valkey.
statuspreparing, active, removing, or failed.
failedActionconnect or disconnect. Present only when status is failed.

A failed connection means the last operation did not complete. Repeat the same call (PUT if failedAction is connect, DELETE if it is disconnect) to try again.

Create a connection

PUT /v1/organizations/:id/connections/:sourceId/:targetId

The request has no body. The connection applies only from sourceId to targetId; to allow the opposite direction, create another connection. The source calls a target application at http://<project>.<organization-id>.zenifra.local, over HTTP on the default port; this call travels only inside the organization's private network, and public traffic stays on HTTPS. For a database or Valkey, the source connects to the same address on the internalPort port, using TLS without hostname verification (for example, sslmode=require; the parameter name varies by client); credentials stay the same as the database's. The address uses the organization identifier (24 hexadecimal characters) to be unique, and it does not change if the project or the organization is renamed.

StatusMeaning
201Connection created.
200The connection was already active.

The response contains { "status": "success", "data": <connection> }, with the connection in the same shape as an item of connections.

{
  "status": "success",
  "data": {
    "id": "<connection-id>",
    "sourceId": "<another-application-id>",
    "targetId": "<application-id>",
    "status": "active"
  }
}

A source application may be restarted to apply the change, and the address is available on every instance of it once the restart finishes. A scheduled Job does not restart: the change applies to its next runs.

Remove a connection

DELETE /v1/organizations/:id/connections/:sourceId/:targetId

Returns 204 and is idempotent: removing a connection that does not exist also returns 204. New connections for the pair are blocked immediately. Connections that are already open are not cut by the disconnection itself, but they may end if a source application is restarted to apply the change.

Errors

StatusWhen
401Missing or invalid session. API keys are not accepted on these routes.
403No permission on the source, the target, or to read the organization.
409The target is not ready yet, or an operation is already in progress for the pair.
422The source or target is not eligible, for example because it is a preview, a database used as a source, a Job used as a target, or a resource from another organization.
502The operation failed. The connection is left with status: "failed" and can be tried again.

On a 409 for an operation in progress or a target that is not ready, wait and repeat the call. Error messages are sanitized and do not expose implementation details.

Read and save the layout

GET /v1/organizations/:id/connection-layout

The layout is per user and organization and has the following shape:

{
  "data": {
    "positions": [
      { "projectId": "<resource-id>", "x": 160, "y": 80 },
      { "projectId": "<another-resource-id>", "x": 520, "y": 80 }
    ]
  }
}

Save positions with PUT /v1/organizations/:id/connection-layout, sending { "positions": [...] }. Each item contains projectId, x, and y. The list can contain up to 5,000 positions; coordinates must be finite numbers between -100000 and 100000, and each ID must belong to a resource the user can view in that organization.

Moving a card changes only that layout. This operation does not create or remove connections.

Next steps

Last updated on

On this page