Shared API: These endpoints are available for all product APIs. All endpoints begin with: /api/v1/auth/member/

Check Member Existence

POST Check Member
No scope required
/api/v1/auth/member/check

Check if a member account exists before showing the appropriate form (login or registration).

Request Body

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

email (string, required without phone) - Email address
phone (string, required without email) - Phone number

Response (Member Exists)

{
  "success": true,
  "data": {
    "exists": true,
    "is_active": true,
    "member": {
      "email": "us**@ex*****.com",
      "phone": null
    }
  }
}

Response (Member Not Found)

{
  "success": true,
  "data": {
    "exists": false,
    "registration_endpoint": "/auth/member/register"
  }
}

Register

POST Create Account
No scope required
/api/v1/auth/member/register

Create a new member account. An OTP code is automatically sent via email after registration.

Request Body

{
  "name": "John Doe",
  "email": "john@example.com",
  "phone": "12345678",
  "accepts_emails": true
}

name (string, required) - Full name
email (string, required) - Email address (unique)
phone (string, required) - Phone number (unique)
accepts_emails (boolean, optional) - Accepts marketing emails

Response

{
  "success": true,
  "data": {
    "message": "Account created successfully. Please verify your email with the OTP code sent.",
    "member": {
      "id": 456,
      "name": "John Doe",
      "email": "jo**@ex*****.com",
      "phone": "12****78"
    },
    "otp_expires_in_minutes": 10,
    "otp_code": "123456"  // Only in test mode
  }
}

Request OTP Code

POST Request OTP
No scope required
/api/v1/auth/member/request-otp

Request an OTP code for authenticating an existing member.

Important: Member must exist. If member doesn't exist, a member_not_found error is returned with requires_registration: true.

Request Body

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

Response (Success)

{
  "success": true,
  "data": {
    "message": "OTP code sent successfully",
    "expires_in_minutes": 10,
    "member": {
      "email": "jo**@ex*****.com",
      "phone": null
    },
    "otp_code": "123456"  // Only in test mode
  }
}

Response (Member Not Found)

{
  "success": false,
  "error": {
    "code": "member_not_found",
    "message": "No account found with this email address. Please register first.",
    "requires_registration": true,
    "registration_endpoint": "/auth/member/register"
  }
}

Verify OTP Code

POST Verify OTP
No scope required
/api/v1/auth/member/verify-otp

Verify the OTP code and get a member authentication token.

Request Body

{
  "email": "john@example.com",
  "code": "123456"
}

Response

{
  "success": true,
  "data": {
    "member_token": "dmt_abc123xyz...",
    "expires_at": "2025-01-20T15:30:00Z",
    "expires_in_minutes": 60,
    "member": {
      "id": 456,
      "email": "jo**@ex*****.com",
      "phone": "12****78",
      "name": "John Doe"
    }
  }
}

Refresh Token

POST Refresh Token
Valid member token required X-Member-Token
/api/v1/auth/member/refresh

Refresh an expiring member token.

Headers

X-App-Id: app_abc123...
X-Api-Key: test_xyz789...
X-Member-Token: dmt_abc123xyz...

Response

{
  "success": true,
  "data": {
    "member_token": "dmt_new_token...",
    "expires_at": "2025-01-20T16:30:00Z",
    "expires_in_minutes": 60
  }
}

Logout

POST Logout
Valid member token required X-Member-Token
/api/v1/auth/member/logout

Invalidate the current member token.

Response

{
  "success": true,
  "data": {
    "message": "Successfully logged out"
  }
}
ESC