Skip to content

Generate JWT Token 🌐

Generates a JWT token using email and password (alternative login method).

Endpoint

POST /api/Token/generate

🌐 Anonymous
Content-Type: application/jsonAccept: application/json

Authentication Type

🌐 Anonymous - No API key or JWT token required

Request Example

bash
curl -X POST https://shipyo.it/api/Token/generate \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "password123"
  }'

Request Body

json
{
  "email": "user@example.com",
  "password": "password123"
}

Fields:

  • email (string, required): User's email address
  • password (string, required): User's password

Success Response

json
{
  "success": true,
  "data": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "message": "Token generated successfully"
}

Error Responses

400 Bad Request

Request is missing required fields or contains invalid data

Example Response:

{
  "success": false,
  "message": "Validation failed",
  "errors": [
    "Email is required",
    "Password is required"
  ]
}

Common scenarios:

  • Missing email or password fields
  • Empty or null values in required fields
  • Invalid JSON format in request body
  • Malformed email address

401 Unauthorized

Invalid login credentials provided

Example Response:

{
  "success": false,
  "message": "Invalid credentials",
  "errors": [
    "Invalid email or password"
  ]
}

Common scenarios:

  • Incorrect email or password combination
  • User account does not exist
  • Account is locked or suspended
  • Password has been changed recently

422 Unprocessable Entity

Account exists but requires password reset before login

Example Response:

{
  "success": false,
  "message": "Password reset required",
  "errors": [
    "Account is inactive and requires password reset"
  ]
}

When this occurs:

  • User account is marked as inactive
  • System requires password reset before allowing login
  • Account has been flagged for security reasons

Next steps: User must complete password reset flow

500 Internal Server Error

Unexpected server error during token generation

Example Response:

{
  "success": false,
  "message": "Internal server error",
  "errors": [
    "Token generation failed"
  ]
}

Possible causes:

  • Authentication service unavailable
  • Token signing service errors
  • Database connection issues

Client action: Retry after a brief delay

Usage Notes

  • This endpoint does not require authentication
  • Alternative to the main login endpoint
  • Returns only the JWT token (no user details)
  • Token should be used for subsequent authenticated requests
  • Simpler response format compared to /api/User/login