API Reference

Create a Send Magic Link end point

Call the /send API with the below body parameters to ensure a magic link being sent to the user.

Call

curl --request POST
  --url https://api.ezid.io/email-link/send \
  --header 'Content-Type: application/json' \
  --data {
   email: "[email protected]",
   client_id: "ezid_client_id",
   client_secret: "ezid_client_secret",
   base_url_email_link: "http://localhost:3000/auth",
   expiry: "3600000",
   push_email: "Yes",
   callback_url: "http://localhost:3000",
   login_hint: "[email protected]",
   claims: {
     test-claim: "read-only"
  },
}
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));');

let url = 'https://api.ezid.io/email-link/send';

let options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: {
  	email:"[email protected]",
  	client_id:"your_client_id",
  	client_secret:"your_client_secret",
  	expiry:"3600000",
  	push_email:"Yes",
  	base_url_email_link:"http://localhost:3000/auth",
  	callback_url:"http://localhost:3000",
  	login_hint:"[email protected]",
  	claims:{
  		test-claim:"read-only"
		}
	}
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error('error:' + err));
AttributesDefinition
email* email of end user
client_id* Your companies unique ID, provided by EZiD
client_secret*You companies unique secret, provided by EZiD
**base_url_email_link**The base URL embedded into the email
expiryAn expiry for the email link, in milliseconds
push_emailChoose 'Yes' if you would like to send emails using EZiD's in-house email service. Choose 'No' if you would like to use your own email provider e.g. SendGrid
callback_urlThe URL to redirect the user once authenticated
login_hintPre-populate the email field with your users email id once they click the magic link
claimsAdd custom claims for your own API access control. These will be encoded into the access token you receive

Responses:

{
  success: true,
  email_link: "http://localhost:3000/auth?code=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1dWlkIjoiM2ZhYzk3NzQtMjhlZS00ZTlkLWJlYzgtYWI0NDE4NmNjOWQzIiwiaWF0IjoxNjQ1NTE3Mjg5LCJleHAiOjE2NDU1MjA4ODl9.Txtjy905HOMjEZQlJ5QIE0O5vBh3nij65VdV7RU77qw&callback_url=unspecified"
}
{
  success: false,
  reason: "Invalid Client Secret"
}
AttributesDefinition
successThe result of the request. Will be true for a successful request
email_linkThe URL of the email link sent to the user

You should extract the code= from the URL return in the email_link as it needs to be passed as auth_code in the next API call.

📘

Please note: To get this code parameter, in Javascript, you can use the URLSearchParams() or split() method.