# Deep links

If you're embedding Agility into another application — a partner dashboard, an internal portal, an "Open in Agility" button on a third-party tool, an email link from a back-office system — you can hand-craft a URL that opens a specific page in the Agility portal. The same URL works whether or not the user is already signed in, and whether the tenant uses SSO or password authentication.

## The link to use

```
https://<portal-host>/<path>?tenant=<your-tenant-id>
```

| Environment | Portal host                 |
| ----------- | --------------------------- |
| Production  | `app.agilitycredit.net`     |
| UAT         | `app.agc-dev.com`           |

## Parameters

| Parameter | Required | Notes                                                                                                                                            |
| --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `tenant`  | Yes      | Your tenant ID — same value shown in the portal's **Account** settings. Used by the portal to route an unauthenticated user to the right sign-in flow, and to detect tenant mismatches for already-signed-in users. |

## Example

```
https://app.agilitycredit.net/applicants/abc123?tenant=BLWFJRNC
```

## Flow

1. User clicks the link.
2. The Agility portal loads.
3. The portal checks the user's session and reconciles it against the `tenant` hint in the URL:

   - **Not signed in.** The portal redirects to the sign-in flow (SSO or password, depending on tenant config) and lands the user back on `/applicants/abc123` after authentication.
   - **Signed in to the same tenant.** The portal renders `/applicants/abc123` immediately. The `?tenant=` hint is silently stripped from the URL so it doesn't linger in history.
   - **Signed in to a different tenant, user has access to the target tenant.** The portal shows a "Switch account?" prompt; on confirm, it switches tenants and lands on `/applicants/abc123`.
   - **Signed in to a different tenant, user doesn't have access to the target tenant.** The portal shows a "You don't have access to this account" message and lets the user sign out.

The user always ends up on the right page, or gets a clear reason why they can't.

## Common patterns

**"Open in Agility" button on your dashboard:**

```
https://app.agilitycredit.net/?tenant=<id>
```

No path — drop the user on the portal home and let them navigate from there.

**Deep-link an email or notification to a specific resource:**

```
https://app.agilitycredit.net/applicants/abc123?tenant=<id>
```

Authenticates the user (if needed) and lands them on the applicant detail page.

## Safety notes

- The link works for any user in the named tenant — Agility doesn't pre-restrict who's allowed to click it. Access control on the destination page (e.g. who's allowed to view `/applicants/abc123`) is enforced once the user is signed in.
- The `tenant` hint is just a hint. The user's actual access is determined by their session — Agility never grants access based on a URL parameter alone.
- If the tenant doesn't exist or has been disabled, the user is redirected to the portal's `/error` page with a generic error code.

Source: https://apidocs.agilitycredit.com/deep-links
