Skip to main content

Authentication

Magne uses JWT (JSON Web Tokens) for API authentication with a refresh token rotation scheme.

Auth Flow

1

Register or Login

Call POST /v1/auth/register or POST /v1/auth/login to receive an initial token pair.
{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "refreshToken": "550e8400-e29b-41d4...",
  "user": {
    "id": "...",
    "username": "example"
  }
}
2

Use the Access Token

Include the token in the Authorization header for all authenticated requests:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
3

Refresh When Expired

Access tokens are short-lived. When expired, use the refresh token:
POST /v1/auth/refresh
Content-Type: application/json

{
  "refreshToken": "550e8400-e29b-41d4..."
}
This returns a new access token AND a new refresh token (rotation). The old refresh token is invalidated.

Token Lifetime

TokenLifetimeStorage
Access TokenShort-lived (minutes)Memory only
Refresh Token30 daysSecure storage, hashed in DB

Unauthenticated Endpoints

These endpoints do not require a Bearer token:
EndpointPurpose
POST /v1/auth/registerAccount registration
POST /v1/auth/loginLogin
POST /v1/auth/verify-emailEmail verification
POST /v1/auth/resend-codeResend verification code
POST /v1/auth/forgot-passwordPassword reset request
POST /v1/auth/reset-passwordPassword reset execution
POST /v1/auth/refreshToken refresh
POST /v1/webhooks/:id/:tokenWebhook execution (token in URL)
GET /v1/invites/:code/previewInvite preview
GET /v1/healthHealth check