Manage Images
Upload, annotate, inspect, tag, and delete individual images through the REST API and Python SDK.
About
Roboflow lets you upload, annotate, inspect, tag, and delete individual images in a project through the REST API and the Python SDK. Use these operations when you need finer control than the bulk dataset upload flow provides - for example, uploading one image at a time from a stream, attaching annotations after the fact, or updating image metadata and tags. To bulk-import a whole labeled dataset at once, see Upload a Dataset.
HTTP API
The REST API exposes per-image operations for uploading images and annotations, fetching image details, deleting images, and managing image tags and metadata.
Upload an Image
Use the REST API to upload an image from a local file or URL.
When you pass image=, Roboflow fetches the URL from its own servers. If it cannot fetch the URL (bad URL, private address, or the host answers with a 4xx status), the response is a 400 with a message that starts with "Could not fetch image URL". If the host answers with a 5xx status or the connection fails, the response is a 502 with retryable: true, so you can send the same request again later.
Parameters
Querystring parameters accepted by the API:
api_key: Obtain from https://app.roboflow.com/account/api image: [Optional] URL of the image to add. Use if your image is hosted elsewhere (Required when you don't POST a base64 encoded image in the request body). name: [Optional] The filename of the image (if not set, we will try to infer it). batch: [Optional] Group images under a batch with this name tag: [Optional] Can be specified multiple times. Add tags to uploaded image. split: [Optional] One of: train, valid, or test (defaults to train). sequence_number: [Optional] If you want to keep the order of your images in the dataset, you can uploaded images increasing sequence numbers. sequence_size: [Optional] The total number of images in the sequence. Defaults to 100,000 if not set. inference_id: [Optional] The inference ID passed returned from a roboflow inference detection. This inference_id allows the image to be correlated with a roboflow detection in Model Monitoring (enterprise feature).
Linux or macOS
Uploading a local file called YOUR_IMAGE.jpg using multipart/form-data (recommended):
curl -F name=YOUR_IMAGE.jpg -F split=train \
-F file=@YOUR_IMAGE.jpg \
"https://api.roboflow.com/dataset/YOUR_DATASET_NAME/upload?\
api_key=$ROBOFLOW_API_KEY"Alternatively, uploading a base64 encoded image:
base64 -i YOUR_IMAGE.jpg | curl -d @- \
"https://api.roboflow.com/dataset/your-dataset/upload?\
api_key=$ROBOFLOW_API_KEY&\
name=YOUR_IMAGE.jpg&\
split=train&\
batch=BATCH_NAME_FOR_UPLOAD"Uploading an image hosted on the web via its URL (don't forget to URL encode it):
curl -X POST "https://api.roboflow.com/dataset/your-dataset/upload?\
api_key=$ROBOFLOW_API_KEY&\
image=https%3A%2F%2Fi.imgur.com%2FPEEvqPN.png&\
name=201-956-1246.png&\
split=train"Windows
You will need to install curl for Windows and GNU's base64 tool for Windows. The easiest way to do this is to use the git for Windows installer which also includes the curl and base64 command line tools when you select "Use Git and optional Unix tools from the Command Prompt" during installation.
Then you can use the same commands as above.
Node.js
We're using axios and form-data to perform the POST request in this example so first run npm install axios form-data to install the dependency.
Uploading with multipart/form-data (recommended):
Uploading with base64 encoded image (not recommended):
Adding an Image Hosted Elsewhere via URL
Web
We are currently beta testing roboflow.js, a browser-based JavaScript library which, among other things, includes safe client-side uploads without exposing your secret API Key to the web. If you'd like early access, please contact us.
View Uploaded Images in Roboflow
Images uploaded via the API can be found in the Annotate tab, under the unassigned column and marked as uploaded via API.
If you specify a batch upload parameter, your image will still be found in the Annotate tab but instead of going to the uploaded via API batch it will be found in the batch you specified.
Upload an Annotation
If you already have existing annotations, along with your images, you can upload them to Roboflow.
This works with any of our supported annotation formats that use an annotation file that references the file name of the uploaded image.
Add prediction=true to save the annotation as a model prediction instead of ground truth. If the image is still in an upload batch and is not in an annotation job yet, Roboflow moves it into a Review job for that batch.
Add predictionRouting=unassigned to skip that move. The annotation still saves and the image is still marked as annotated, but it stays in its batch and stays unassigned. Use predictionRouting=review to ask for the default routing. Both values need prediction=true, and you cannot use them with jobName.
Example
Attaching a VOC XML annotation to an image with ID abc123 in the your-dataset dataset called YOUR_ANNOTATION.xml:
Attaching a Darknet TXT annotation to an image with ID abc123 in the your-dataset dataset called YOUR_ANNOTATION.txt using a json labelmap - in this case we need to send the contents of the annotation file in a json instead of just sending it as the body.
We're using axios to perform the POST request in this example so first run npm install axios to install the dependency.
Uploading a Local Image
Get Details About an Image
You can fetch details of a specific image using the REST API.
To fetch details of a specific image, make a GET request to the following API endpoint.
Here is an example request to the API to fetch the details of an image
This endpoint returns a JSON object containing the following information about the image:
Delete an Image from a Dataset
You can remove images from a Dataset using the REST API.
To remove images from a Dataset, make a DELETE request to the following API endpoint, passing the image IDs in the endpoint.
Here is an example request to the API to remove images
This endpoint returns a 204 status if the operation was successful.
List, Add, and Remove Image Tags
You can assign tags to specific images on Roboflow using the REST API
To add, remove, and set tags to images hosted on Roboflow, make POST request to the following API endpoint. Use the Search API to retrieve the image ID associated with the image name:
Here is an example request to the API (can "add", "remove", or "set" a tag):
This endpoint accepts the following values in the POST body:
The API will add the tag to the specified image in Roboflow (remember to pass in the image ID to the post request and not the image name).
Update Image Metadata and Tags
You can write custom metadata and tags to images in your workspace using the REST API. There are two endpoints: one for updating a single image synchronously, and one for updating up to 1,000 images in a batch.
Both endpoints require an API key with the image:tag scope.
Request Body
Both endpoints accept the same fields (the batch endpoint wraps them in an updates array):
You must include at least one of these fields. You cannot set and remove the same metadata key or tag in the same request. Metadata keys that start with _rf_internal_ are reserved for Roboflow and are rejected.
Single Image
Update metadata and tags for a single image.
Example
Response
Batch Update
Update metadata and tags for multiple images asynchronously. Accepts up to 1,000 images per request.
Example
Response
Returns 202 with a task ID. Poll the task URL to check progress.
See Async Tasks for how to poll the task status.
Errors
Python SDK
Project exposes the per-image operations that complement the bulk upload_dataset flow. Use these when you need finer control over single-image uploads, want to attach annotations after the fact, or are ingesting images one-at-a-time from a stream.
Upload an image (with optional annotation)
Project.upload() is the high-level "do the right thing" helper. It accepts a single image plus an optional matching annotation file and ships both to the project in one call.
single_upload() is a lower-level variant that takes the same arguments and returns the raw API responses for both the image and (if provided) the annotation.
Upload an image only
Useful when annotations don't exist yet and the image goes straight to a labeler.
Validate an image before uploading
check_valid_image() runs Roboflow's local size / format checks without hitting the API:
Attach an annotation to an existing image
save_annotation() posts an annotation against an image that's already in the project. Useful for adding labels created elsewhere, or for promoting a model prediction to ground truth.
Pass annotation_labelmap="./labelmap.yaml" to map class indices into class names if your annotation format requires it.
Saving with is_prediction=True can move the image into a review job. See where predictions land.
Fetch an image's metadata
Returns image metadata, current split, and annotation status.
Delete images
Project-level (only deletes images that belong to this project):
Workspace-level (removes images regardless of which projects reference them - use with care):
A note on uploads in v1.3.6+
As of roboflow 1.3.6, the SDK uploads the original image bytes rather than re-encoding via Pillow. This restores parity with the web uploader and lets the Roboflow server deduplicate uploads by SHA-256. If you have automation that uploads the same image twice (e.g. to add it to multiple batches), you'll see the second upload succeed without consuming additional storage credits.
CLI
Use the CLI to upload one image and its optional annotation, tags, or metadata.
Options
-p, --project
Project ID (required)
-a, --annotation
Path to an annotation file
-m, --labelmap
Path to a label map file
-s, --split
Dataset split: train, valid, or test. The default is train.
-t, --tag
Comma-separated tag names
-M, --metadata
Metadata as a JSON string
--is-prediction
Mark the upload as a prediction
-b, --batch
Batch name
Examples
Upload an image with an annotation:
Upload an image with tags and metadata:
To upload a directory or .zip archive, see Upload a Dataset.
MCP Server
Connect your AI agent to the MCP Server and it can find and update images with these tools:
images_search
Search for images inside a project.
images_update_metadata
Update metadata and tags on a single image.
images_batch_update_metadata
Batch-update metadata and tags on multiple images.
annotations_save
Save an annotation for an existing image.
Last updated
Was this helpful?