# Authenticate using a Magic Link

The [magic link](https://docs.suggestic.com/graphql/helpful-resources/glossary#magic-link) is a passwordless sign-up and login option that sends a unique link to your email inbox, which you can use to get into your third-party application.

Use the `generateMagicLink` mutation to generate this link to be later used to send to a user's email.

Take into consideration that the link will last 24 hours only. Afterward, **the link will no longer be valid**.

## Requirements

In order to have the magic link generated, third-party users must have the following information in their databases:&#x20;

* `firebase_deep_link`
* `android_package_name` or
* `ios_bundle_id`

## Required Arguments

<table data-header-hidden><thead><tr><th width="256.3333333333333">Argument</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>Argument</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>email</code></td><td>email</td><td>Use this as reference only.</td></tr></tbody></table>

## Available Fields

<table data-header-hidden><thead><tr><th width="256.3333333333333">Argument</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>Argument</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>success</code></td><td>Boolean</td><td><strong>True</strong> if the magic link has been generated successfully. Otherwise it returns <strong>False</strong></td></tr><tr><td><code>message</code></td><td>String</td><td>Description of the result</td></tr><tr><td><code>magicLink</code></td><td>String</td><td>Link which will be used to send an email. </td></tr></tbody></table>

## Example

The following example returns a magic link based on a user's email provided in the query variable.

{% tabs %}
{% tab title="Mutation" %}

```graphql
mutation($email: String!) {
  generateMagicLink(email: $email) {
    success
    message
    magicLink
  }
}
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "generateMagicLink": {
      "success": true,
      "message": "Magic link was created",
      "magicLink": "https://suggestic.page.link/ZEqtmLupJttJD6eSA"
    }
  }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="QUERY VARIABLES" %}

```graphql
{
  "email": "user@company.com"
}
```

{% endtab %}
{% endtabs %}

## Send Magic Link Email

## Send Magic Link

<mark style="color:green;">`POST`</mark> `https://production.suggestic.com/api/v1/auth/send-magic-link`

Use this **REST** method to request a magic link email.

#### Headers

| Name                                           | Type   | Description      |
| ---------------------------------------------- | ------ | ---------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json |
| Suggestic-Partner                              | String |                  |

#### Request Body

| Name                                         | Type   | Description |
| -------------------------------------------- | ------ | ----------- |
| email<mark style="color:red;">\*</mark>      | String | User email. |
| client\_id<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK Magic Link email sent." %}

{% endtab %}
{% endtabs %}

## Send Magic Link Email Curl Example

{% tabs %}
{% tab title="Curl" %}

```sh
curl --location --request POST 'https://production.suggestic.com/api/v1/auth/send-magic-link' \
--header 'Suggestic-Partner: suggestic' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "user@suggestic.com",
    "client_id": "6541f95a-18ce-4e10-abf8-b0dao799650b"
}'
```

{% endtab %}
{% endtabs %}
