Skip to navigation

Upload Single Image (Cloudinary)

View as Markdown

Uploads a single image to Cloudinary storage and returns its secure URL, public ID, dimensions, and metadata. Used by the driver and user mobile apps to upload avatar images and KYC verification documents before passing URLs to profile or document endpoints.


Endpoint Overview

  • Method: POST

  • Route: /api/v1/upload/single

  • Authentication: None (Public)

  • Content-Type: multipart/form-data


Request Headers

HeaderTypeRequiredDescription
Content-TypestringYesMust be multipart/form-data

Request Body Schema (multipart/form-data)

Form FieldData TypeRequiredDefaultAllowed Values / ConstraintsDescription
imageFile (Binary)Yes—Max: 10MB.
Allowed: .jpg, .jpeg, .png, .webp, .gif, .avif, .heic, .heif
The image file to upload
foldertextNo"uploads"e.g. "drivers/kyc", "drivers/avatars"Cloudinary destination folder

Response Body Schema (201 Created)

Top-Level KeyData TypeDescription
successbooleanIndicates whether upload succeeded (true)
imageobjectUploaded image metadata and URLs

image Object Fields

FieldData TypeDescription
urlstringPublicly accessible HTTPS Cloudinary URL
publicIdstringUnique Cloudinary public ID (used for deletions)
widthintegerImage width in pixels
heightintegerImage height in pixels
formatstringFile format extension (e.g. "jpg", "png", "webp")
bytesintegerFile size in bytes

Response Examples

1. 201 Created — Image Uploaded Successfully

{
"success": true,
"image": {
"url": "https://res.cloudinary.com/goride/image/upload/v1758429900/drivers/kyc/drv_dl_sample.jpg",
"publicId": "drivers/kyc/drv_dl_sample",
"width": 1280,
"height": 720,
"format": "jpg",
"bytes": 245360
}
}

2. 400 Bad Request — Missing File Field

When the form-data field image is not provided:

{
"success": false,
"error": "No file provided (field name: 'image')"
}

3. 400 Bad Request — File Exceeds Size Limit (Max 10MB)

{
"success": false,
"error": "File too large."
}

4. 400 Bad Request — Unsupported MIME Type

{
"success": false,
"error": "Unsupported file type \"application/pdf\". Allowed: image/jpeg, image/png, image/webp, image/gif, image/avif, image/heic, image/heif"
}

5. 502 Bad Gateway — Cloudinary Upload Failure

{
"success": false,
"error": "Cloudinary connection timed out or rejected file"
}

Status Codes Reference

HTTP Status CodeCondition
201 CreatedFile uploaded and stored on Cloudinary; image details returned.
400 Bad RequestMissing file, file size exceeded 10MB, or unsupported file extension.
502 Bad GatewayThird-party Cloudinary API error or failure.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.