ReachLMS REST API

Backend API for Canvas LMS sub-account provisioning with Stripe billing integration.

Authentication: Most endpoints require a JWT Bearer token in the Authorization header. Authorization: Bearer <access_token>

Authentication

User registration, login, and verification endpoints.

Register New User

Create a new user account. Sends verification email if is_verified is false.

POST

Endpoint: /api/auth/register

No authentication required

Request Body:

{
    "email": "[email protected]",
    "first_name": "John",
    "last_name": "Doe",
    "password": "securePassword123",
    "is_verified": false,
    "is_new_user": true,
    "stripe_customer_id": null
}

Success Response: 201

{
    "access_token": "eyJhbGciOiJIUzI1NiIs...",
    "refresh_token": "eyJhbGciOiJIUzI1NiIs...",
    "user_id": {
        "id": 1,
        "first_name": "John",
        "last_name": "Doe",
        "user_name": "[email protected]",
        "email": "[email protected]",
        "is_active": true,
        "is_admin": false,
        "is_verified": false,
        "created_at": "2025-01-30T10:00:00",
        "legacy": false,
        "is_new_user": true,
        "has_google_auth": false,
        "stripe_customer_id": null
    },
    "message": "User registered successfully"
}

Error Response: 400

{
    "error": "User already exists"
}

Login

Authenticate with email and password to receive JWT tokens.

POST

Endpoint: /api/auth/login

No authentication required

Request Body:

{
    "email": "[email protected]",
    "password": "securePassword123"
}

Success Response: 200

{
    "access_token": "eyJhbGciOiJIUzI1NiIs...",
    "refresh_token": "eyJhbGciOiJIUzI1NiIs...",
    "user_id": {
        "id": 1,
        "first_name": "John",
        "last_name": "Doe",
        "user_name": "[email protected]",
        "email": "[email protected]",
        "is_active": true,
        "is_admin": false,
        "is_verified": true,
        "created_at": "2025-01-30T10:00:00",
        "legacy": false,
        "is_new_user": false,
        "has_google_auth": false,
        "stripe_customer_id": "cus_abc123"
    },
    "message": "Login successful"
}

Error Response: 401

{
    "error": "Invalid email or password"
}

Google OAuth Login

Authenticate using Google OAuth. Creates account if user doesn't exist.

POST

Endpoint: /api/auth/google

No authentication required

Request Body:

{
    "id_token": "google_oauth_id_token_string"
}

Success Response: 200

{
    "access_token": "eyJhbGciOiJIUzI1NiIs...",
    "refresh_token": "eyJhbGciOiJIUzI1NiIs...",
    "user_id": { ... },
    "is_new_user": false,
    "message": "Login successful"
}

Refresh Access Token

Get a new access token using a valid refresh token.

POST

Endpoint: /api/auth/refresh

Requires refresh token in Authorization header

Request Body: None

Success Response: 200

{
    "access_token": "eyJhbGciOiJIUzI1NiIs..."
}

Get Current User

Retrieve the authenticated user's profile information.

GET

Endpoint: /api/auth/me

Requires JWT access token

Request Body: None

Success Response: 200

{
    "id": 1,
    "username": "[email protected]",
    "email": "[email protected]",
    "first_name": "John",
    "last_name": "Doe",
    "verified": true,
    "is_new_user": false
}

Verify Registration Code

Verify user email using the 6-digit code sent during registration.

POST

Endpoint: /api/auth/verify-code

Requires JWT access token

Request Body: Raw 6-digit code as string

"203134"

Success Response: 200

{
    "status": "success",
    "message": "User verified successfully"
}

Error Response: 401

{
    "error": "Invalid verification code"
}

Check Verification Request

Check if an active verification request exists for a specific email.

POST

Endpoint: /api/auth/check-verification-request

Requires JWT access token

Request Body: Email as raw string

"[email protected]"

Success Response: 200

{
    "status": "found",
    "message": "Verification request found"
}

Not Found Response: 404

{
    "status": "not_found",
    "message": "No verification request found for this user/email"
}

Create User Verification Request

Generate and send a verification code to add a new Canvas user.

POST

Endpoint: /api/auth/create-user-verification-request

Requires JWT access token

Request Body: Email as raw string

"[email protected]"

Success Response: 200

{
    "message": "Request code sent successfully!"
}

Request Password Reset

Send a password reset verification code to the user's email.

POST

Endpoint: /api/auth/password-reset-verification

No authentication required

Request Body: Email as raw string

"[email protected]"

Success Response: 200

{
    "message": "Request code sent successfully!"
}

Already Exists Response: 200

{
    "status": "exists",
    "message": "Request already exists."
}

Complete Password Reset

Verify the reset code and set a new password.

POST

Endpoint: /api/auth/verify-pw-reset

No authentication required

Request Body:

{
    "email": "[email protected]",
    "verificationCode": "203134",
    "new_password": "newSecurePassword123"
}

Success Response: 200

{
    "status": "success",
    "message": "Password reset successfully"
}

Resend Verification Code

Resend a verification code, replacing any existing request.

POST

Endpoint: /api/auth/resend-verification-code

No authentication required

Request Body:

{
    "email": "[email protected]",
    "request_type": "REGR"
}

Request types: REGR (registration), PWRST (password reset), ADUSR (add user)

Success Response: 200

{
    "status": "success",
    "message": "Verification Code resent successfully"
}