> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.driver.olycab.in/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.driver.olycab.in/_mcp/server.

# Upload Single Image (Cloudinary)

GET https://driver/#get4

# Upload Single Image (Cloudinary)

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

| Header         | Type     | Required | Description                   |
| -------------- | -------- | -------- | ----------------------------- |
| `Content-Type` | `string` | **Yes**  | Must be `multipart/form-data` |

***

### Request Body Schema (`multipart/form-data`)

| Form Field | Data Type       | Required | Default     | Allowed Values / Constraints                                                             | Description                   |
| ---------- | --------------- | -------- | ----------- | ---------------------------------------------------------------------------------------- | ----------------------------- |
| `image`    | `File (Binary)` | **Yes**  | —           | Max: 10MB.  Allowed: `.jpg`, `.jpeg`, `.png`, `.webp`, `.gif`, `.avif`, `.heic`, `.heif` | The image file to upload      |
| `folder`   | `text`          | No       | `"uploads"` | e.g. `"drivers/kyc"`, `"drivers/avatars"`                                                | Cloudinary destination folder |

***

### Response Body Schema (`201 Created`)

| Top-Level Key | Data Type | Description                                 |
| ------------- | --------- | ------------------------------------------- |
| `success`     | `boolean` | Indicates whether upload succeeded (`true`) |
| `image`       | `object`  | Uploaded image metadata and URLs            |

#### `image` Object Fields

| Field      | Data Type | Description                                             |
| ---------- | --------- | ------------------------------------------------------- |
| `url`      | `string`  | Publicly accessible HTTPS Cloudinary URL                |
| `publicId` | `string`  | Unique Cloudinary public ID (used for deletions)        |
| `width`    | `integer` | Image width in pixels                                   |
| `height`   | `integer` | Image height in pixels                                  |
| `format`   | `string`  | File format extension (e.g. `"jpg"`, `"png"`, `"webp"`) |
| `bytes`    | `integer` | File size in bytes                                      |

***

### Response Examples

#### 1. `201 Created` — Image Uploaded Successfully

```json
{
  "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:

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

```

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

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

```

#### 4. `400 Bad Request` — Unsupported MIME Type

```json
{
  "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

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

```

***

### Status Codes Reference

| HTTP Status Code      | Condition                                                             |
| --------------------- | --------------------------------------------------------------------- |
| **`201 Created`**     | File uploaded and stored on Cloudinary; image details returned.       |
| **`400 Bad Request`** | Missing file, file size exceeded 10MB, or unsupported file extension. |
| **`502 Bad Gateway`** | Third-party Cloudinary API error or failure.                          |

Reference: https://docs.driver.olycab.in/oly-driver/utils/upload-single-image-cloudinary

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Examples

**SDK Code**

```python
import requests

url = "https://driver/#get4"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://driver/#get4';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://driver/#get4"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://driver/#get4")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://driver/#get4")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://driver/#get4', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://driver/#get4");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://driver/#get4")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```