Authentication API

Authenticate against the SpireStock API with an API key or a session token. Covers the X-API-Key header, JWT sign-in, OTP, magic links and the desktop code exchange.

4 endpoints. Every request needs an API key or a session token — see Authentication. To send one of these calls from the browser, use the interactive reference.

POSThttps://api.spirestock.com/api/v1/auth/login

Authenticate with email and password. Returns a JWT token, user profile, navigation modules, and workspace details.

Request body

  • email (string)requiredUser email address
  • password (string)requiredAccount password

Example request

curl -X POST https://api.spirestock.com/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "your-password"
  }'

Example response

{
  "response_code": 200,
  "message": "Login successful",
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "user": {
    "id": 1,
    "first_name": "John",
    "last_name": "Doe",
    "official_email": "[email protected]",
    "role_id": 1,
    "role_name": "Admin",
    "user_type": 0,
    "organization_id": 5,
    "organization_name": "Acme Dairy",
    "status": 1
  },
  "modules": [
    {
      "id": 1,
      "name": "Orders",
      "icon": "shopping-cart",
      "link": "/orders",
      "subModules": [
        { "id": 10, "name": "All Orders", "link": "/orders/all", "icon": "list" }
      ]
    }
  ],
  "workspace": {
    "workspace_id": "ws_abc123",
    "slug": "acme-dairy",
    "display_name": "Acme Dairy",
    "domain": null,
    "plan": "professional",
    "status": 1,
    "logo": null,
    "primary_color": "#1e40af",
    "secondary_color": "#f59e0b"
  }
}
POSThttps://api.spirestock.com/api/v1/auth/otp/request

Request a one-time password sent via SMS for passwordless login.

Request body

  • phone (string)requiredPhone number to receive OTP

Example request

curl -X POST https://api.spirestock.com/api/v1/auth/otp/request \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "+919876543210"
  }'

Example response

{
  "response_code": 200,
  "message": "OTP sent successfully"
}
POSThttps://api.spirestock.com/api/v1/auth/otp/verify

Verify the OTP and receive a JWT token. Completes passwordless authentication.

Request body

  • phone (string)requiredPhone number used in OTP request
  • otp (string)requiredThe OTP code received via SMS

Example request

curl -X POST https://api.spirestock.com/api/v1/auth/otp/verify \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "+919876543210",
    "otp": "482910"
  }'

Example response

{
  "response_code": 200,
  "message": "Login successful",
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "user": {
    "id": 42,
    "first_name": "Ravi",
    "last_name": "Kumar",
    "primary_contact_number": "+919876543210",
    "role_name": "Distributor",
    "user_type": 2,
    "organization_id": 5,
    "status": 1
  },
  "workspace": {
    "workspace_id": "ws_abc123",
    "slug": "acme-dairy",
    "display_name": "Acme Dairy",
    "plan": "professional",
    "status": 1
  }
}
GEThttps://api.spirestock.com/api/v1/auth/me

Retrieve the authenticated user’s profile, role, and organization context.

Example request

curl https://api.spirestock.com/api/v1/auth/me \
  -H "Authorization: Bearer YOUR_TOKEN"

Example response

{
  "response_code": 200,
  "data": {
    "id": 1,
    "first_name": "John",
    "last_name": "Doe",
    "official_email": "[email protected]",
    "primary_contact_number": "+919876543210",
    "role_id": 1,
    "role_name": "Admin",
    "user_type": 0,
    "organization_id": 5,
    "organization_name": "Acme Dairy",
    "profile_image": null,
    "status": 1
  }
}