TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dev0302/nextjs-project-1/llms.txt
Use this file to discover all available pages before exploring further.
/api/accept-messages endpoint lets authenticated users control whether their inbox is open to new anonymous messages. A POST request flips the isAcceptingMessages boolean on the user’s document; a GET request reads the current value back. When isAcceptingMessages is false, any call to POST /api/send-message targeting that user will be rejected with a 403 — no messages enter the inbox until the flag is re-enabled.
POST /api/accept-messages
Update whether the authenticated user is currently accepting new anonymous messages.Method and URL
Authentication
Required. The server resolves the caller’s identity throughgetServerSession(NEXT_AUTH_CONFIG). Requests without a valid session cookie are rejected with 401.
Request Body
Pass
true to open the inbox and allow new messages. Pass false to close the inbox and block incoming messages. Any non-boolean value is rejected by the Zod acceptMessageSchema validation with a 400 error.Example Request
curl Example
Responses
200 — Status Updated
400 — Validation Failed
TheacceptMessage field was missing or not a boolean. The error message is taken directly from the Zod issue.
401 — Not Authenticated
404 — User Not Found
The session was valid but no matching user document was found in the database.500 — Server Error
GET /api/accept-messages
Read the currentisAcceptingMessages status for the authenticated user.
Method and URL
Authentication
Required. The server verifies the caller’s session withgetServerSession(NEXT_AUTH_CONFIG). Unauthenticated requests receive a 401.
Request Parameters
No query parameters and no request body.curl Example
Responses
200 — Success
401 — Not Authenticated
404 — User Not Found
500 — Server Error
Response Fields
POST response fields
true when the flag was updated successfully; false on any error.Human-readable outcome description, or a Zod validation error message on a 400.
GET response fields
true when the status was fetched successfully; false on any error.The user’s current acceptance setting.
true means their inbox is open; false means new messages are blocked. Present only on a 200 response.Common Error Codes
| Status | Meaning |
|---|---|
| 400 | Zod validation failed — acceptMessage was not a boolean |
| 401 | No valid NextAuth session cookie |
| 404 | Authenticated but user document not found in MongoDB |
| 500 | Unexpected server or database error |
Notes
Zod validation for the POST body is handled by
acceptMessageSchema (src/app/schemas/acceptMessageSchema.ts), which expects exactly { acceptMessage: z.boolean() }. The schema uses .safeParse() so validation errors never throw — instead the route returns a 400 with the first Zod issue message as the message field.