Skip to main content

Overview

Wryft Chat uses JWT (JSON Web Tokens) for authentication. All authenticated endpoints require a valid JWT token in the Authorization header.

Register

Create a new user account.

Request Body

Response

Validation Rules

  • Username: 3-32 characters, alphanumeric + underscores
  • Email: Valid email format
  • Password: Minimum 8 characters

Login

Authenticate with existing credentials.

Request Body

Response

Using JWT Tokens

Include the token in the Authorization header for all authenticated requests:

Example with cURL

Example with JavaScript

Token Expiration

JWT tokens expire after 30 days. When a token expires, the user must log in again.

Checking Token Validity

Returns 401 Unauthorized if token is invalid or expired.

Error Responses

400 Bad Request

401 Unauthorized

409 Conflict

Security Best Practices

Store Securely

Store tokens in httpOnly cookies or secure storage

HTTPS Only

Always use HTTPS in production

Token Rotation

Implement token refresh for long sessions

Logout

Clear tokens on logout

Rate Limiting

Authentication endpoints are rate limited:
  • 10 requests per minute per IP
  • Returns 429 Too Many Requests when exceeded

Next Steps

Users API

Manage user profiles

Messages API

Send and receive messages