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

# Get Customer Magic Link

> The API to create a Link which logs a user into the billing portal directly

## Request

**Request type**: POST

**URL**: `{{baseUrl}}/api/v1/customers/{{externalCustomerId}}/magic_link`

**Body** (optional):

```json theme={null}
{
    "return_url": "https://merchant.example.com/manage_plans",
    "intent": "new_purchase",
    "plan_id": "45e46575-bf1d-4667-8acc-8b0ade8441e1"
}
```

### Constraints

| Parameter Name | Required?                  | Constraints                                                                                          | Remarks                                                                                                                                          |
| -------------- | -------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| return\_url    | no                         | When present, it should be a valid URL                                                               | Once the user is done with the billing portal, the user will be redirected to this URL.                                                          |
| intent         | yes, when body is provided | It must be either `new_purchase` or `cancel_subscription` (as a string)                              | The intent will govern where the resulting magic link will take the user - to either the new plan purchase page or the cancel subscription page. |
| plan\_id       | yes, when body is provided | Must be the plan ID from one of the plans that you got from [List Plans](/api-list-active-plans) API | This is the plan to which the magic link will take the user.                                                                                     |

## Success Response

**HTTP code**: 200 (OK)

**Body**:

```json theme={null}
{
	"magic_link": "{{mbsUrl}}/p/login?token={{userLoginToken}}"
}
```

**Meaning of Response field values**:

| Field       | Expected Value                                                              | Remarks |
| ----------- | --------------------------------------------------------------------------- | ------- |
| magic\_link | A link to the [MBS](/nomenclature) that takes the user to the intended page |         |
