<aside> <img src="/icons/snippet_gray.svg" alt="/icons/snippet_gray.svg" width="40px" />

Table of Contents

</aside>

/v2/queue

Overview

The /queue endpoint allows users to upload an image, validate authorization, and enqueue the image for processing. The image is stored in Supabase storage, and the request is added to a queue for further processing.

Functionality

  1. Validates required fields and authorization.
  2. Ensures the file type is supported and within size limits.
  3. Uploads the image to Supabase storage.
  4. Adds the image request to the processing queue.
  5. Returns a success response if all operations complete successfully.

Usage Example

Request:

POST /queue
Authorization: Bearer <API_KEY>
Content-Type: multipart/form-data

--boundary
Content-Disposition: form-data; name="file"; filename="image.jpg"
Content-Type: image/jpeg

(binary image data)
--boundary
Content-Disposition: form-data; name="platform_id"

"12345"
--boundary
Content-Disposition: form-data; name="platform_url"

"<https://example.com>"
--boundary--

Response:

{
  "success": true,
  "message": "Image has been added to the queue."
}

HTTP Method

POST

Request

Headers

Form Data Parameters

Parameter Type Required Description
file file Yes The image file (PNG, JPG, JPEG). Max size 4MB.
platform_id string Yes The platform identifier.
platform_url string Yes The URL associated with the platform.

Response

Success Response

Status Code: 200 OK

{
  "success": true,
  "message": "Image has been added to the queue."
}

Error Responses

Missing Authorization HeaderStatus Code: 401 Unauthorized

{
  "error": "Missing Authorization header"
}

Missing Required FieldStatus Code: 400 Bad Request

{
  "error": "Missing required field: <field_name>"
}

File Size ExceededStatus Code: 400 Bad Request

{
  "error": "File size exceeds 4MB limit."
}

Invalid API KeyStatus Code: 401 Unauthorized

{
  "error": "Invalid or missing license key"
}

Unsupported File TypeStatus Code: 400 Bad Request

{
  "error": "Unsupported file type. Only PNG, JPG, and JPEG are allowed."
}

File Upload FailureStatus Code: 500 Internal Server Error

{
  "error": "File upload failed."
}

Queue Processing FailureStatus Code: 500 Internal Server Error

{
  "error": "Failed to enqueue image."
}


/v2/queue/process

Overview

The /v1/queue/process endpoint is responsible for processing image analysis tasks from a queue. It retrieves pending messages from the queue, analyzes the images using an AI service, stores the results, and deletes processed messages from the queue.

Functionality

  1. Fetches up to 20 messages from the images queue.
  2. For each message, extracts the user ID, image URL, and platform ID.
  3. Sends the image to the AI analysis service.
  4. If analysis is successful:
  5. Logs success or failure for each image processed.

Error Handling

Usage Example

Request:

GET /v1/queue/process

Response:

{
  "message": "Processing completed"
}

HTTP Method

GET

Request

Headers

Query Parameters

None.

Response

Success Response

Status Code: 200 OK

{
  "message": "Processing completed"
}

Error Responses

Queue Fetch Error:Status Code: 400 Bad Request

{
  "error": "Queue fetch error: <error details>"
}

Processing Error:Status Code: 400 Bad Request

{
  "error": "Request error: <error details>"
}

<aside> <img src="/icons/thought-dialogue_gray.svg" alt="/icons/thought-dialogue_gray.svg" width="40px" />

</aside>