Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Priyanshu471/ad-management/llms.txt

Use this file to discover all available pages before exploring further.

The Ad Management System provides two authentication endpoints for identity management. POST /api/login validates an existing user’s credentials against MongoDB and returns the full user document on success. POST /api/register creates a brand-new account after verifying that the provided email address is not already in use. Both endpoints accept a JSON body and return the resulting user object directly in the response. Error responses from both endpoints are plain text strings, not JSON.

POST /api/login

Validates the provided email and password against the MongoDB users collection. If a matching document is found, the full user object is returned with a 200 status. No session or token is issued — the caller is responsible for persisting the returned user data client-side.

Request Body

email
string
required
The email address associated with the user’s account.
password
string
required
The user’s password in plain text.

Request Example

{
  "email": "jane@example.com",
  "password": "secret123"
}

Response 200

{
  "user": {
    "_id": "65f1a2b3c4d5e6f7a8b9c0d1",
    "name": "jane doe",
    "email": "jane@example.com",
    "password": "secret123",
    "role": "advertiser",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z"
  }
}

Error Responses

StatusBodyCause
400Email or password is incorrectNo user document matched the provided credentials
500Raw error message stringUnexpected server or database error
Error responses from this endpoint are plain text strings, not JSON objects. Do not attempt to parse them with res.json().

cURL Example

curl -X POST http://localhost:3000/api/login \
  -H "Content-Type: application/json" \
  -d '{"email":"jane@example.com","password":"secret123"}'

POST /api/register

Creates a new user account. The handler first checks whether a document with the provided email already exists in MongoDB. If the email is taken, it returns a 400 plain text error immediately. Otherwise it creates and saves a new User document and returns it in the response body.

Request Body

name
string
required
The display name for the new user account.
email
string
required
The email address for the account. Must be unique across all registered users.
password
string
required
The account password in plain text.
role
string
required
The user’s role in the system (e.g. advertiser, creator, or admin). This field accepts any string — no server-side validation of the value is performed.

Request Example

{
  "name": "john doe",
  "email": "john@example.com",
  "password": "secret123",
  "role": "advertiser"
}

Response 200

{
  "newUser": {
    "_id": "65f1a2b3c4d5e6f7a8b9c0d2",
    "name": "john doe",
    "email": "john@example.com",
    "password": "secret123",
    "role": "advertiser",
    "createdAt": "2024-01-15T10:35:00.000Z",
    "updatedAt": "2024-01-15T10:35:00.000Z"
  }
}

Error Responses

StatusBodyCause
400Email is already in useA user with the provided email already exists
500Raw error message stringUnexpected server or database error
Error responses from this endpoint are plain text strings, not JSON objects. Do not attempt to parse them with res.json().

cURL Example

curl -X POST http://localhost:3000/api/register \
  -H "Content-Type: application/json" \
  -d '{"name":"john doe","email":"john@example.com","password":"secret123","role":"advertiser"}'
Passwords are currently stored and compared in plain text. Before going to production, hash passwords at rest using a library such as bcrypt and compare hashes during login — never store or transmit raw passwords in a real application.

Build docs developers (and LLMs) love