You are on page 1of 4

API Route Documentation : Create campaign

Route (POST)

/api/v1/campaign/create/

Headers

- “Content-Type: application/json”
- “Authorization: {token}”

Body

The request body should be a JSON object with the following properties:

Field Type Description

title String Title of the campaign

description String Description of the campaign

imageLink String Link of the campaign image after


uploading to cloudinary

cloudinaryID String Identifier of the image in cloudinary

filters Array of JSON objects List of filter types and their values of
the campaign

segments Array of JSON objects List of notifications segments of the


campaign

Example Body (JSON)

{
"title": "Test Campaign",
"description": "Test Description",
"imageLink": "Link",
"cloudinaryID": "Identifier",
"filters": [
{
"type": "gender",
"value": "male"
},
{
"type": "gender",
"value": "female"
},
{
"type": "city",
"value": "Inde By"
},
{
"type": "passion",
"value": "hairstyles"
}
],
"segments": [
{
"date": "2024-03-15",
"time": "17:00:00",
"tokensCount": 2
},
{
"date": "2024-03-17",
"time": "17:00:00",
"tokensCount": 2
},
{
"date": "2024-03-18",
"time": "17:00:00",
"tokensCount": 2
}
]
}
Responses

Success Response

● Status Code: 200 Created


● Content Type: application/json

json
{
"token":
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NTcsInRpbWVzdGFtcCI6MTcwOTU4MjIwOTQxN
iwiaWF0IjoxNzA5NTgyMjA5fQ.KCfp3DP-XNKVSZQPjB80nFFcFaGloOoTK88vSfwnFRY",
"reachCount": 500
}

Error Responses

Invalid Authorization

● Status Code: 404 Bad Request


● Content Type: application/json

json
{
"success": false,
"error": "Authorization Error",
"message": "You are not authorized to perform this action"
}
Expired session

● Status Code: 405 Bad Request


● Content Type: application/json

json
{
"success": false,
"error": "Authorization Error",
"message": "Your session has expired"
}

Internal Server Error

● Status Code: 500 Internal Server Error


● Content Type: application/json

json
{
"success": false,
"error": "Internal Server Error",
"message": "An unexpected error occurred"
}

Notes
● The user needs to be authenticated.
● Handle error responses the same as previous calls.

You might also like