Authentication
The YBH Pulse Content API uses JWT (JSON Web Token) authentication with HTTP-only cookies for secure session management.Authentication Flow
- Login - Exchange email/password for JWT token
- Session - Token stored in secure HTTP-only cookie
- Requests - Cookie automatically included in subsequent requests
- Logout - Clear cookie to end session
Login
Authenticate and receive a session cookie.Request
User email address (must be
@youvebeenheard.com domain)User password
Response
Authenticated user information
Set-Cookie header with the JWT token:
Error Responses
| Status | Error | Description |
|---|---|---|
400 | Missing required fields | Email or password not provided |
401 | Invalid credentials | Email not found or password incorrect |
429 | Too many attempts | Rate limit exceeded (5 attempts per 15 minutes) |
500 | Authentication failed | Server error during authentication |
Email Domain Restriction: Only
@youvebeenheard.com email addresses are permitted. This is enforced server-side to prevent unauthorized access.Get Current User
Retrieve information about the currently authenticated user.Response
Error Responses
| Status | Error | Description |
|---|---|---|
401 | Unauthorized | No token provided or token expired |
401 | Session expired | Token no longer valid |
Logout
End the current session by clearing the authentication cookie.Response
Set-Cookie header that clears the token:
Forgot Password
Request a password reset email.Email address for password reset
Response
Rate Limit: 3 password reset requests per hour per IP address.
Reset Password
Reset password using a token from the reset email.Reset token from email
New password (minimum 8 characters)
Response
JWT Token Structure
The JWT token contains:User ID for database lookups
User email address
User role for RBAC:
admin, designer, or userIssued at timestamp (Unix)
Expiration timestamp (Unix) - 7 days from issuance
Cookie Settings
| Attribute | Value | Description |
|---|---|---|
| HttpOnly | true | Prevents JavaScript access (XSS protection) |
| Secure | true | Only sent over HTTPS (production) |
| SameSite | Strict | CSRF protection |
| Path | / | Available site-wide |
| Max-Age | 604800 | 7 days (1 week) |
Using Authentication in Requests
Once authenticated, the cookie is automatically included in all requests:User Roles
The API supports role-based access control (RBAC):| Role | Permissions |
|---|---|
| admin | Full access to all endpoints |
| designer | Read/write episodes, generate content, manage images |
| user | Read-only access to episodes |
Role enforcement is implemented at the application level. The JWT token includes the user’s role for authorization checks.