Skip to main content
Use the Magic Link endpoints to create hosted authentication or file-upload flows that you can send directly to end users. This page covers the provider, single-provider authentication, and file-upload link variants, along with the settings object they share. For conceptual background, see Magic Link.

Overview

Magic Links are shareable URLs that let your users connect provider accounts or upload files without embedding widgets in your application. There are three types:
  • Provider — multi-provider authentication (connect one or more providers).
  • Authentication — single-provider authentication (connect exactly one provider).
  • File Upload — manual file upload through a hosted interface.
Base URL: https://api.withleaf.io/services/widgets/api
All Magic Link types share the same expiresIn parameter: lifetime in seconds, minimum 900, maximum approximately 1 year.
The GET endpoints return usage-tracking fields such as usageCount and maxUsage. Magic Links are not inherently single-use.

Settings object

Every Magic Link type accepts an optional settings object to customize the hosted page:
Lets the end user authenticate with multiple providers in a single session.

Endpoints


POST /magic-link/users/{leafUserId}/provider Creates a Magic Link for an existing Leaf user.

Path parameters

Request body

Response


POST /magic-link/provider Creates a Magic Link for flows where Leaf creates a Leaf user based on the provided externalId.

Request body


GET /magic-link/provider Returns all Provider Magic Links for your API owner.

Query parameters

Response


GET /magic-link/provider/{magicLinkId} Returns a single Provider Magic Link by ID.

Path parameters

Response


DELETE /magic-link/provider/{magicLinkId} Permanently deletes a Provider Magic Link. The URL immediately stops working.

Path parameters


Lets the end user authenticate with a single, specified provider.

Endpoints


POST /magic-link/users/{leafUserId}/authentication Creates a Magic Link scoped to a single provider for an existing Leaf user.

Path parameters

Request body

Response


POST /magic-link/authentication Creates a Magic Link for flows where Leaf creates a Leaf user based on the provided externalId.

Request body

Use the auto-create variant when you do not want to create the Leaf user separately before sending the link.

Get, Delete

The Get all, Get one, and Delete endpoints for Authentication Magic Links follow the same pattern as the Provider Magic Link endpoints, but the resource includes a single provider field instead of allowedProviders. Authentication list endpoints also use the same paginated envelope with items and nextPageToken.

Authentication list/get response shape


Lets the end user upload machine files through a hosted interface.

Endpoints


POST /magic-link/users/{leafUserId}/file-upload Creates a Magic Link for uploading machine files, tied to an existing Leaf user.

Path parameters

Request body

Response


POST /magic-link/file-upload Creates a Magic Link for flows where Leaf creates a Leaf user based on the provided externalId.

Request body


Get, Delete

The Get all, Get one, and Delete endpoints for File Upload Magic Links follow the same paginated pattern as the Provider Magic Link endpoints. File Upload list endpoints also use the same paginated envelope with items and nextPageToken.

File Upload list/get response shape

Last modified on April 13, 2026