Skip to main content

Authentication API

All API requests (except signup and login) require a Bearer token in the Authorization header.

Base URL

https://neurohash-api-production.up.railway.app

Endpoints

Sign Up

Create a new account. Sends an OTP code to the provided email.

POST /auth/signup

Request Body:

{
"email": "user@example.com"
}

Response:

{
"message": "OTP sent to your email. Please verify to complete registration."
}

Verify OTP

Verify your email with the OTP code received.

POST /auth/verify-otp

Request Body:

{
"email": "user@example.com",
"otp": "123456"
}

Response:

{
"id": 1,
"email": "user@example.com",
"token": "eyJhbGciOiJIUzI1NiIs...",
"isVerified": true,
"wallet": {
"publicKey": "0x..."
}
}
tip

Save the token from the response. Use it as Bearer <token> in the Authorization header for all subsequent requests.


Login (OTP)

Request an OTP code for an existing account.

POST /auth/initiate-otp-login

Request Body:

{
"email": "user@example.com"
}

Response:

{
"message": "OTP sent to your email. Please verify to login."
}

Verify OTP Login

Complete OTP login flow.

POST /auth/verify-otp-login

Request Body:

{
"email": "user@example.com",
"otp": "123456"
}

Response: Returns user object with token.


Get Current User

Retrieve the authenticated user's profile and wallet info.

GET /auth/me

Headers:

Authorization: Bearer <token>

Response:

{
"id": 1,
"email": "user@example.com",
"username": "johndoe",
"token": "eyJhbGciOiJIUzI1NiIs...",
"isVerified": true,
"wallet": {
"publicKey": "0x1234...abcd"
}
}

Check Username Availability

POST /auth/check-username

Headers:

Authorization: Bearer <token>

Request Body:

{
"username": "johndoe",
"email": "user@example.com"
}

Response:

{
"available": true,
"message": "Username is available"
}

Error Responses

StatusMeaning
401Invalid credentials or expired token
409Email already registered
400Invalid request body