> ## Documentation Index
> Fetch the complete documentation index at: https://developer.upsun.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Define relationships between your multiple apps

> Find out how relationships are managed between your apps.

When you set up a project containing multiple applications,
by default your apps can't communicate with each other.
To enable connections, define relationships between apps using the `http` endpoint.

You can't define circular relationships.
If `app1` has a relationship to `app2`, then `app2` can't have a relationship to `app1`.
If you need data to go both ways, consider coordinating through a shared data store,
like a database or [RabbitMQ server](/docs/add-services/rabbitmq).

Relationships between apps use HTTP, not HTTPS.
This is still secure because they're internal and not exposed to the outside world.

## Relationships example

You have two apps, `app1` and `app2`, and `app1` needs data from `app2`.

In your app configuration for `app1`, define a relationship to `app2`:

```yaml .upsun/config.yaml theme={null}
applications:
  app1:
    relationships:
      api:
        service: "app2"
        endpoint: "http"
```

Once they're both built, `app1` can access `app2` at the following URL: `http://api.internal`.<br />
The specific URL is always available through the [service environment variables](/docs/development/variables#service-environment-variables),
or through the [`PLATFORM_RELATIONSHIPS` variable](/docs/development/variables/use-variables#use-provided-variables):

<Tabs>
  <Tab title="Service environment variables">
    ```bash {location="Terminal on app1 container", no-copy="true"} theme={null}
    $ echo $API_HOST
    api.internal
    ```
  </Tab>

  <Tab title="`PLATFORM_RELATIONSHIPS` environment variable">
    It uses the `jq` library, which is included in all app containers for this purpose.

    ```bash {location="Terminal on app1 container", no-copy="true"} theme={null}
    $ echo $PLATFORM_RELATIONSHIPS | base64 --decode | jq '.api[0].host'
    api.internal
    ```
  </Tab>
</Tabs>
