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

# Migrate to DSN

> Update your existing AdonisJS connection in a few steps

A DSN replaces your API key and connection settings with a single value for each
service. Your existing API keys keep working, so you can migrate one service at a time.

## 1. Copy your DSN

Open your service in Monocle. Under **SDK connection**, click **Create DSN** and
copy it. You can find and copy it again from this page at any time.

## 2. Update your AdonisJS configuration

Use a version of the Monocle SDK that supports DSNs, then add your DSN to `.env`:

```dotenv title=".env" theme={"theme":"vesper"}
MONOCLE_DSN=https://mk_live_********@ingest.monocle.sh/00000000-0000-4000-8000-000000000001
```

Replace this example with the full DSN you copied. Add the variable to your environment schema:

```typescript title="start/env.ts" theme={"theme":"vesper"}
MONOCLE_DSN: Env.schema.string.optional(),
```

In `config/monocle.ts`, replace `apiKey`, `serviceName`, and `endpoint` with `dsn`:

```diff title="config/monocle.ts" theme={"theme":"vesper"}
 export default defineConfig({
-  apiKey: env.get('MONOCLE_API_KEY'),
-  serviceName: env.get('APP_NAME'),
-  endpoint: 'https://ingest.monocle.sh',
+  dsn: env.get('MONOCLE_DSN'),
   environment: env.get('APP_ENV'),
   serviceVersion: env.get('APP_VERSION'),
 });
```

Keep your environment, integrations, sampling, and other options unchanged.
If you also export to another destination, you can keep `serviceName` for it.

## 3. Check that data arrives

Restart or redeploy your application, then make a request. Check that new data
appears under the expected service and environment in Monocle. You can also check
the DSN's **Last used** timestamp on the service page.

You can find your old keys under **Previous project API keys**. Only revoke a key
after every application using it has migrated.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.