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

# configure

> Configure PortalAuth with your auth environment and redirect URL.

## Function Signature

```dart theme={null}
Future<void> configure({
  required String authEnvironmentId,
  required String redirectUrl,
  String? apiHost,
  PortalMagicLinkConfig? magicLink,
  bool? isAccountAbstracted,
})
```

## Description

A [`PortalAuth`](./portalauth) method. Builds the native `PortalAuth`, replacing any previous configuration. Call it once at startup, before any other `PortalAuth` method, and again only when the auth environment or the account-abstraction mode changes: each call replaces the native instance, and with it the memory that lets a re-delivered redirect replay.

Available starting from `portal_flutter` 2.0.0.

## Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `authEnvironmentId` | `String` | Yes | Your environment's Auth Environment ID. Also the key the session is stored under. |
| `redirectUrl` | `String` | Yes | Where Portal returns the user. Must be on the environment's allow list and registered as a deep link by the app, byte for byte. |
| `apiHost` | `String` | No | API host override. Defaults to `api.portalhq.io`, and must point at the backend that owns `authEnvironmentId`. |
| `magicLink` | `PortalMagicLinkConfig` | No | Sender and template for [`sendMagicLink`](./portalauthsendmagiclink). OAuth-only apps can omit it. |
| `isAccountAbstracted` | `bool` | No | Whether the client Portal creates for a first-time user uses gas sponsorship. Ignored for a returning user. |

## Returns

**`Future<void>`** - Completes once the native instance is built.

## Example

```dart theme={null}
import 'package:portal_flutter/portal_flutter.dart';

await PortalAuth().configure(
  authEnvironmentId: 'YOUR_AUTH_ENVIRONMENT_ID',
  redirectUrl: 'myapp://auth/callback',
  magicLink: PortalMagicLinkConfig(
    fromEmail: 'hello@auth.example.com',
    templateId: 'YOUR_TEMPLATE_ID',
  ),
);
```

## Errors

| Code | Description |
| - | - |
| `AUTH_INVALID_ARGUMENT` | `authEnvironmentId` or `redirectUrl` is blank |
| `AUTH_CONFIGURE_ERROR` | The native instance could not be built |

## Related

* [Configure PortalAuth guide](../guide/client-auth#configure-portalauth)
* [Register your redirect](../guide/client-auth#register-your-redirect)
* [PortalAuth](./portalauth)
* [getMethods](./portalauthgetmethods)


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