Initiate authentication via magic link
const url = 'https://api-dev.mindflow.io/v1/auth';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"email":"hello@example.com","name":"example","tenant":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api-dev.mindflow.io/v1/auth \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "email": "hello@example.com", "name": "example", "tenant": "example" }'Providing an email and name will create a new user if they don’t exist. It will then initiate a custom authentication challenge using a magic link mechanism via Cognito.
Curl Example
curl -X POST \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "alice@example.com", "name": "Alice Smith"}' \
"https://api.example.com/v1/auth"
Flow
- The frontend or third-party backend sends a request with the user email and name.
- Mindflow:
- Checks if the user exists in Cognito
- Creates the user if missing
- Sets a random password for the user
- Triggers the
InitiateAuthflow to retrieve a session - Creates a magic link for the user to complete authentication
- Returns the magic link URL
- This URL can later be used to complete authentication.
Security
- This endpoint will only be deployed to specific accounts
- This endpoint will have its own API key
Response
- A
200response returns a JSON payload with the magic link URL. - A
500is returned if the flow fails (user creation, Cognito errors, etc.).
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Email of the user requesting SSO via magic link.
Name of the user requesting SSO via magic link.
Tenant of the user requesting SSO via magic link.
Examplegenerated
{ "email": "hello@example.com", "name": "example", "tenant": "example"}Responses
Section titled “Responses”Successfully initiated magic link authentication.
object
Direct URL to complete authentication.
Examplegenerated
{ "magicLink": "https://example.com"}Headers
Section titled “Headers”The maximum number of requests per time window.
The number of requests remaining in the current rate limit window.
The time at which the current rate limit window resets.
The number of seconds to wait before retrying the request after receiving a 429 response.
Specifies the allowed origins for CORS.
The request was invalid. Common causes include:
- Invalid timestamp format.
- Using
cursorwithbeforeorafter. - Missing
limitwhen usingbeforeorafter. - Invalid field names in the
fieldsparameter.
See the error response for specific details about what went wrong.
object
URI reference identifying the problem type. When absent, “about:blank” per RFC 9457 Section 3.1.1.
Short, human-readable summary of the problem type (RFC 9457 Section 3.1.3).
HTTP status code for this occurrence (advisory; same as response status) (RFC 9457 Section 3.1.2).
Human-readable explanation specific to this occurrence (RFC 9457 Section 3.1.4).
URI reference identifying the specific occurrence (RFC 9457 Section 3.1.5).
Machine-readable error code for bad request / validation failure.
Example
{ "type": "about:blank", "code": "BAD_REQUEST"}Headers
Section titled “Headers”The maximum number of requests per time window.
The number of requests remaining in the current rate limit window.
The time at which the current rate limit window resets.
The number of seconds to wait before retrying the request after receiving a 429 response.
Specifies the allowed origins for CORS.
Authentication failed. The request lacks valid credentials or the provided credentials are invalid.
Ensure you have:
- A valid API key or token.
- Proper authentication headers.
- Required permissions.
object
URI reference identifying the problem type. When absent, “about:blank” per RFC 9457 Section 3.1.1.
Short, human-readable summary of the problem type (RFC 9457 Section 3.1.3).
HTTP status code for this occurrence (advisory; same as response status) (RFC 9457 Section 3.1.2).
Human-readable explanation specific to this occurrence (RFC 9457 Section 3.1.4).
URI reference identifying the specific occurrence (RFC 9457 Section 3.1.5).
Machine-readable error code for this authentication failure.
Example
{ "type": "about:blank", "code": "MISSING_OR_INVALID_TOKEN"}Headers
Section titled “Headers”The maximum number of requests per time window.
The number of requests remaining in the current rate limit window.
The time at which the current rate limit window resets.
The number of seconds to wait before retrying the request after receiving a 429 response.
Specifies the allowed origins for CORS.
Too many requests. The request rate limit has been exceeded.
Please wait until the rate limit window resets before making additional requests.
object
URI reference identifying the problem type. When absent, “about:blank” per RFC 9457 Section 3.1.1.
Short, human-readable summary of the problem type (RFC 9457 Section 3.1.3).
HTTP status code for this occurrence (advisory; same as response status) (RFC 9457 Section 3.1.2).
Human-readable explanation specific to this occurrence (RFC 9457 Section 3.1.4).
URI reference identifying the specific occurrence (RFC 9457 Section 3.1.5).
Machine-readable error code for rate limit exceeded.
Example
{ "type": "about:blank", "code": "RATE_LIMIT_EXCEEDED"}Headers
Section titled “Headers”The maximum number of requests per time window.
The number of requests remaining in the current rate limit window.
The time at which the current rate limit window resets.
The number of seconds to wait before retrying the request after receiving a 429 response.
Specifies the allowed origins for CORS.
Internal server error. The server encountered an unexpected condition that prevented it from fulfilling the request.
Please try again later or contact support if the problem persists.
object
URI reference identifying the problem type. When absent, “about:blank” per RFC 9457 Section 3.1.1.
Short, human-readable summary of the problem type (RFC 9457 Section 3.1.3).
HTTP status code for this occurrence (advisory; same as response status) (RFC 9457 Section 3.1.2).
Human-readable explanation specific to this occurrence (RFC 9457 Section 3.1.4).
URI reference identifying the specific occurrence (RFC 9457 Section 3.1.5).
Machine-readable error code for internal server failure.
Example
{ "type": "about:blank", "code": "INTERNAL_ERROR"}Headers
Section titled “Headers”The maximum number of requests per time window.
The number of requests remaining in the current rate limit window.
The time at which the current rate limit window resets.
The number of seconds to wait before retrying the request after receiving a 429 response.
Specifies the allowed origins for CORS.