GET /api/nurses
Retrieve all nurse records from the database.Request
No parameters required.Response
Returns an array of nurse objects sorted alphabetically by name.Array of nurse objects, each containing:
Response Example
POST /api/nurses/create-accounts
Create Supabase Auth accounts for nurses that exist in the database but don’t have authentication accounts yet. This is an administrative operation typically run during initial setup or when onboarding new nurses.How It Works
For each nurse in the database:- Checks if nurse already has
auth_user_id→ skips if yes - Searches for existing Supabase Auth user with matching email
- Links to existing auth account if found, OR
- Creates new auth account with temporary password
- Updates nurse record with
auth_user_id
Request
No request body required. Processes all nurses automatically.Response
Whether the operation completed successfully
Summary message (e.g., “Processed 5 nurses”)
Array of result objects for each nurse
Response Example
Status Types
skipped
skipped
Nurse already has an
auth_user_id linked. No action taken.linked
linked
Found existing Supabase Auth user with matching email. Linked the auth user ID to the nurse record.
created
created
Created new Supabase Auth account for the nurse. Returns a temporary password.Important: Save the Temporary password format:
tempPassword securely and share it with the nurse through a secure channel.Temp{nurse_id}{timestamp}error
error
An error occurred while processing this nurse.
Created Account Details
When a new account is created:- Email: Nurse’s email from database
- Password: Temporary password (format:
Temp{nurse_id}{timestamp}) - Email Confirmed: Yes (auto-confirmed)
- User Metadata: Includes nurse name and database ID
Error Responses
Service role key not configured
Failed to create accounts
Integration Example
Use Cases
Initial Setup
Run once during system deployment to create auth accounts for all nurses in the database.
Onboarding
Run after adding new nurse records to the database to create their auth accounts.
Account Recovery
Link existing auth accounts to nurse records if the connection was lost.
Audit
Check which nurses have auth accounts and which need accounts created.
Best Practices
Environment Setup
Environment Setup
Ensure Never commit this key to version control!
SUPABASE_SERVICE_KEY is set in your .env file:Password Management
Password Management
- Parse and store temporary passwords from the response
- Use a secure password manager or vault
- Implement a password delivery system (secure email, SMS, or portal)
- Force password change on first login
- Set expiration for temporary passwords
Error Handling
Error Handling
Check the
status field for each result:Automation
Automation
Consider integrating this endpoint into your onboarding workflow:
- Add nurse to database
- Call
/api/nurses/create-accounts - Extract temporary password from response
- Send welcome email with password
- Log account creation for audit trail
