Skip to main content

Endpoint

POST /api/projects

Authentication

Required: Admin role This endpoint requires a valid JWT token with the Admin role. Include the token in the Authorization header:
Authorization: Bearer YOUR_JWT_TOKEN

Description

Creates a new photography project with optional detail images. Returns the created project with a generated ID.

Request Body

title
string
required
Project title. Maximum length: 200 characters.
description
string
Project description. Maximum length: 1000 characters. Optional.
imageUrl
string
required
URL of the main project cover image. Maximum length: 500 characters.
bannerClickTitle
string
Title displayed when the project banner is clicked. Maximum length: 200 characters. Optional.
bannerClickDescription
string
Description displayed when the project banner is clicked. Maximum length: 1000 characters. Optional.
isActive
boolean
default:"true"
Whether the project is active and visible. Defaults to true.
details
array
default:"[]"
Array of detail objects containing additional project images.

Response

id
string (GUID)
Unique identifier for the created project.
title
string
Project title.
description
string
Project description.
imageUrl
string
URL of the main project image.
isActive
boolean
Indicates if the project is active.
createDate
string (datetime)
ISO 8601 timestamp when the project was created.
details
array
Array of created project detail objects.

Example Request

curl -X POST http://localhost:5000/api/projects \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "title": "Summer Beach Photography",
    "description": "Beautiful coastal landscapes and beach portraits from summer 2024",
    "imageUrl": "https://example.com/images/summer-beach-cover.jpg",
    "bannerClickTitle": "Explore Summer Collection",
    "bannerClickDescription": "Dive into our stunning summer beach photography collection",
    "isActive": true,
    "details": [
      {
        "imageUrl": "https://example.com/images/beach-1.jpg",
        "isActive": true
      },
      {
        "imageUrl": "https://example.com/images/beach-2.jpg",
        "isActive": true
      },
      {
        "imageUrl": "https://example.com/images/beach-3.jpg",
        "isActive": true
      }
    ]
  }'

Example Response

Success (201 Created)

{
  "id": "5hc07h86-7939-6784-d5he-4e185h88chc8",
  "title": "Summer Beach Photography",
  "description": "Beautiful coastal landscapes and beach portraits from summer 2024",
  "imageUrl": "https://example.com/images/summer-beach-cover.jpg",
  "isActive": true,
  "createDate": "2024-10-16T14:30:00Z",
  "details": [
    {
      "id": "af2g9802-a758-73hg-c77e-h3aj4i4j23dh0",
      "imageUrl": "https://example.com/images/beach-1.jpg",
      "isActive": true
    },
    {
      "id": "bg3h0913-b869-84ih-d88f-i4bk5j5k34ei1",
      "imageUrl": "https://example.com/images/beach-2.jpg",
      "isActive": true
    },
    {
      "id": "ch4i1a24-c97a-95ji-e99g-j5cl6k6l45fj2",
      "imageUrl": "https://example.com/images/beach-3.jpg",
      "isActive": true
    }
  ]
}
The response includes a Location header:
Location: /api/projects

Error (400 Bad Request)

Returned when validation fails:
{
  "errors": {
    "Title": [
      "The Title field is required."
    ],
    "ImageUrl": [
      "The ImageUrl field is required."
    ],
    "Details[0].ImageUrl": [
      "The ImageUrl field is required."
    ]
  },
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400
}

Error (401 Unauthorized)

Returned when no authentication token is provided:
{
  "type": "https://tools.ietf.org/html/rfc7235#section-3.1",
  "title": "Unauthorized",
  "status": 401
}

Error (403 Forbidden)

Returned when the authenticated user does not have the Admin role:
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.3",
  "title": "Forbidden",
  "status": 403
}

Notes

  • Admin role required - obtain token via /api/auth/login
  • The id for the project and all details are auto-generated
  • The createDate is automatically set to the current UTC time
  • Creation is logged with the project title for audit purposes
  • Both bannerClickTitle and bannerClickDescription are optional fields for enhanced UI interactions
  • The details array can be empty if no additional images are needed

Build docs developers (and LLMs) love