---
title: Service URLs
description: How Forge builds the base URL of a deployed web app, API, or event service, and where to read it from Terraform outputs and pipeline variables.
---

# Service URLs

Every service that Forge deploys through Azure Front Door has one canonical URL per environment. The URL is the environment's base URL plus a service-specific path, and each service type exposes it as a Terraform output so pipelines and other tools can read it instead of rebuilding it by hand.

---

## 🌐 Environment base URLs

The `saif-resources` environment module computes two base URLs and publishes them as `context.naming.internal_base_url` and `context.naming.external_base_url`. They contain the scheme and host with no trailing slash.

| Audience | Production | Non-production |
| --- | --- | --- |
| Internal | `https://app-int.saif.com` | `https://app-int-<env>.saif.com` |
| External | `https://app.saif.com` | `https://app-<env>.saif.com` |

`<env>` is the lowercase environment short name, for example `test`. The choice of subdomain follows [ADR 0005](decisions/0005-subdomain-names-of-applications-and-apis.md).

---

## 🔗 Service URLs

| Service type | Terraform output | URL | Internal or external |
| --- | --- | --- | --- |
| Web app (`saif-web-service`) | `app_url` | `<base>/<application_name>` | External when `is_external_app` is `true`, otherwise internal |
| API (`saif-api-service`) | `api_url` | `<base>/api/<type>/<name>` | External when `is_external_app` is `true`, otherwise internal |
| Event service (`saif-event-service`) | `event_url` | `<internal base>/api/event/<name>` | Always internal |

- **`<type>`** for an API is the short API type: `exp` (Experience), `proc` (Process), or `sys` (System). Event services always use `event`.
- **`<name>`** differs by service type. For an API it is the `api.name` input, lowercased. For an event service it is the project ID with the first `api-` removed, lowercased, so it can differ from `api.name`.
- **`event_url`** is `null` when the service's OpenAPI file declares no operations, because no API is created in that case. Terraform does not store null outputs, so reading it then reports "output not found".

For example:

```text
https://app-test.saif.com/policyportal
https://app-int-test.saif.com/api/event/events-gwcceventservice
```

The first is an external web app in the test environment. The second is an event service in the test environment.

!!! note "Custom subdomains are not included"
    These outputs return the shared Front Door URL. A [custom subdomain](../build/deploy/custom-subdomains.md) is an additional hostname for the same service and does not change `app_url`.

---

## 📤 Reading the URLs

### From Terraform

Each project's infra root declares the output in its `outputs.tf`. From that directory, after a deploy:

```powershell
terraform output -raw event_url
```

Use `app_url` or `api_url` for the other service types.

### From a pipeline

The `tf_outputs` step in the Terraform deploy job publishes each scalar output as a `TF_OUTPUT_<name>` pipeline variable, so later jobs read `TF_OUTPUT_event_url`, `TF_OUTPUT_api_url`, or `TF_OUTPUT_app_url`. An output that the project does not declare evaluates to an empty string.

### From another Terraform module

Modules that receive the environment `context` can read `context.naming.internal_base_url` and `context.naming.external_base_url` directly and append their own path. The `api` module uses this to build its `base_url`, and the `webapp` and `event-service` modules use it for `app_url` and `event_url`.

---

## 📚 Related

- [Terraform output event_url, api_url, or app_url not found](../troubleshoot/terraform-output-service-url-not-found.md): projects generated before these outputs existed
- [Custom Subdomains](../build/deploy/custom-subdomains.md)
- [Subdomain Names of Applications and APIs](decisions/0005-subdomain-names-of-applications-and-apis.md)
- [Service ↔ Azure Resource Model](service-azure-resource-model.md)
- [Service Discovery](service-discovery.md)
