Skip to main content

List Photos

curl -X GET https://your-domain.com/api/photos \
  -H "Cookie: your-session-cookies"
Retrieves all photos for the authenticated user, ordered by creation date (most recent first).

Response

photos
array
Array of photo objects

Response Example

[
  {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "user_id": "user-123",
    "album_id": "album-456",
    "blob_url": "https://blob.vercel-storage.com/photos/user-123/1709550000000-vacation.jpg",
    "file_name": "vacation.jpg",
    "file_size": 2458624,
    "file_type": "image/jpeg",
    "width": 1920,
    "height": 1080,
    "created_at": "2026-03-04T10:30:00.000Z"
  }
]

Error Responses

error
object

Upload Photo

curl -X POST https://your-domain.com/api/photos/upload \
  -H "Cookie: your-session-cookies" \
  -F "file=@/path/to/photo.jpg" \
  -F "album_id=album-456"
Uploads a new photo to Vercel Blob storage and creates a database record.

Request Body

Content-Type: multipart/form-data
file
File
required
The image file to upload. Supported formats: JPEG, PNG, GIF, WebP, etc.
album_id
string
Optional. ID of the album to add this photo to. If not provided or null, the photo will not be assigned to any album.

Response

Returns the created photo object:
photo
object

Response Example

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "user_id": "user-123",
  "album_id": "album-456",
  "blob_url": "https://blob.vercel-storage.com/photos/user-123/1709550000000-vacation.jpg",
  "file_name": "vacation.jpg",
  "file_size": 2458624,
  "file_type": "image/jpeg",
  "width": null,
  "height": null,
  "created_at": "2026-03-04T10:30:00.000Z"
}

Error Responses

error
object

Delete Photo

curl -X DELETE https://your-domain.com/api/photos/delete \
  -H "Cookie: your-session-cookies" \
  -H "Content-Type: application/json" \
  -d '{"id": "123e4567-e89b-12d3-a456-426614174000"}'
Deletes a photo from both Vercel Blob storage and the database.

Request Body

id
string
required
The unique identifier of the photo to delete

Request Example

{
  "id": "123e4567-e89b-12d3-a456-426614174000"
}

Response

success
boolean
Returns true when deletion is successful

Response Example

{
  "success": true
}

Error Responses

error
object

Move Photo

curl -X PATCH https://your-domain.com/api/photos/move \
  -H "Cookie: your-session-cookies" \
  -H "Content-Type: application/json" \
  -d '{"id": "123e4567-e89b-12d3-a456-426614174000", "album_id": "album-789"}'
Moves a photo to a different album or removes it from an album.

Request Body

id
string
required
The unique identifier of the photo to move
album_id
string | null
The ID of the destination album. Set to null or omit to remove the photo from all albums.

Request Example

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "album_id": "album-789"
}
To remove from album:
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "album_id": null
}

Response

Returns the updated photo object:
photo
object
The complete photo object with updated album_id

Response Example

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "user_id": "user-123",
  "album_id": "album-789",
  "blob_url": "https://blob.vercel-storage.com/photos/user-123/1709550000000-vacation.jpg",
  "file_name": "vacation.jpg",
  "file_size": 2458624,
  "file_type": "image/jpeg",
  "width": 1920,
  "height": 1080,
  "created_at": "2026-03-04T10:30:00.000Z"
}

Error Responses

error
object

Update Photo Dimensions

curl -X PATCH https://your-domain.com/api/photos/dimensions \
  -H "Cookie: your-session-cookies" \
  -H "Content-Type: application/json" \
  -d '{"id": "123e4567-e89b-12d3-a456-426614174000", "width": 1920, "height": 1080}'
Updates the width and height metadata for a photo.

Request Body

id
string
required
The unique identifier of the photo to update
width
number
Width of the image in pixels
height
number
Height of the image in pixels

Request Example

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "width": 1920,
  "height": 1080
}

Response

Returns the updated photo object:
photo
object
The complete photo object with updated dimensions

Response Example

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "user_id": "user-123",
  "album_id": "album-456",
  "blob_url": "https://blob.vercel-storage.com/photos/user-123/1709550000000-vacation.jpg",
  "file_name": "vacation.jpg",
  "file_size": 2458624,
  "file_type": "image/jpeg",
  "width": 1920,
  "height": 1080,
  "created_at": "2026-03-04T10:30:00.000Z"
}

Error Responses

error
object

Build docs developers (and LLMs) love