TheDocumentation 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.
/api/campaign route is the core of the Ad Management System and supports four HTTP methods covering the complete lifecycle of an ad campaign. GET retrieves every campaign stored in MongoDB, POST creates a new campaign and associates it with an existing user, PATCH updates a campaign’s fields by matching on its current title, and DELETE permanently removes a campaign by its MongoDB _id. All four methods share the same endpoint URL and communicate exclusively over JSON.
GET /api/campaign
Returns every campaign document stored in the MongoDBcampaigns collection. No request body is required.
Response 200
cURL Example
POST /api/campaign
Creates a new campaign document in MongoDB and embeds the full user object retrieved byuserId. The new campaign is returned in the response body upon success.
Request Body
The display title of the campaign.
A short description of the campaign’s purpose or messaging.
The marketing objective for the campaign. Must be one of the nine supported values — see Campaign Objectives.
The total allocated budget for the campaign, represented as a string (e.g.
"50000").How long the campaign runs (e.g.
"30 days").The MongoDB
_id of the user creating the campaign. Used to look up and embed the user document.Request Example
Response 200
Error Response
| Status | Body | Cause |
|---|---|---|
500 | Raw error message string | Unexpected server or MongoDB error |
cURL Example
PATCH /api/campaign
Updates one or more fields on an existing campaign. The target document is located by matchingprevTitle against the campaign’s current title field in MongoDB using Campaign.findOneAndUpdate({ title: prevTitle }, ...). Any combination of the remaining fields can be provided to update only those values.
Request Body
The current title of the campaign. Used as the lookup key to find the document to update. This field is always required, even if you are not changing the title.
The new title to set on the campaign.
The updated campaign description.
The updated budget value.
The updated campaign duration.
The updated campaign status.
Request Example
Response 200
Error Response
| Status | Body | Cause |
|---|---|---|
500 | Raw error message string | Unexpected server or MongoDB error |
cURL Example
DELETE /api/campaign
Permanently removes a campaign from MongoDB by its_id. This operation cannot be undone.
Request Body
The MongoDB
_id of the campaign to delete.Request Example
Response 200
Error Response
| Status | Body | Cause |
|---|---|---|
500 | Raw error message string | Unexpected server or MongoDB error |