Skip to content

Requests and responses ​

Everything on this page applies to every route of the HTTP API. The routes themselves are described in Datasets, Tags, Images, Models and Users.

Choosing the function ​

The API is deployed twice, with the same routes:

FunctionBase URLTime limitMemory
apihttps://europe-west1-<projectId>.cloudfunctions.net/api60 s1 GB
usapihttps://us-central1-<projectId>.cloudfunctions.net/usapi3600 s4 GiB

A request has to finish within the time limit of the function that receives it. Use usapi for anything that walks over many images: ZIP exports, moving or copying images, deleting images, datasets or models, tag rewrites, bulk updates, review actions and group deletion. Use api for the rest. The training CSV of a large dataset may not fit in 60 seconds either: send it to usapi in that case.

Methods ​

Every route is a POST, except GET /ping, GET /model/share/{token} and GET /user/list. A path or method that does not exist is answered with 404 and the message Cannot <METHOD> <path>.

Browsers can call the API from any origin (CORS allows GET and POST).

Authentication ​

Send the Firebase ID token of a signed-in user of the project in the Authorization header:

http
POST /usapi/dataset/rp-obj-bottles/delete HTTP/1.1
Host: us-central1-<projectId>.cloudfunctions.net
Authorization: Bearer <ID token>
Content-Type: application/json

An ID token is what Firebase Authentication gives a user who signs in to the project. In a web page that already uses the Firebase SDK it is await user.getIdToken(). From a script, an account with email and password can sign in through the Firebase Auth REST API with the web API key of the project:

bash
curl -s "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=<webApiKey>" \
  -H "Content-Type: application/json" \
  -d '{"email":"<email>","password":"<password>","returnSecureToken":true}'

The answer carries the token in idToken. It is valid for one hour; sign in again, or exchange the refreshToken of the same answer, to get a new one.

RoutesWho can call them
/pingAnyone, without a token
GET /model/share/{token}Anyone who has the share token
/user/*A signed-in user who can manage users: one whose profile includes the Settings view or, when the user has no stored profile, one with the role admin or superadmin
/mcpWhoever holds the MCP token of the project, which is not an ID token: see Connecting a client
Every other routeAny signed-in user of the project

A missing or invalid token is answered with 401 (missing ID token, invalid ID token); a user who cannot manage users, with 403.

Request bodies ​

Bodies are JSON (Content-Type: application/json). Some routes read their fields at the top level of the body and others inside a data object:

json
{ "images": ["Qm3xZ0aT9kLw2VbN7cYd"], "change": { "set": "TEST" } }
json
{ "data": { "id": "scratch", "color": "#e11d48" } }

Each route's page shows the form it expects. The tag routes and the user routes use data.

Responses ​

A successful call answers with a 2xx status and the result in data:

json
{ "data": { "id": "rp-obj-bottles", "updated": 128 } }

A failed call answers with a 4xx or 5xx status and a message:

json
{ "error": { "message": "dataset rp-obj-bottles not found" } }

The two exceptions are the ZIP export without storage, which answers with the ZIP file itself, and /mcp, which speaks JSON-RPC.

StatusMeaning
200Done. Operations over many images may still list the ones that failed: see below
400A field is missing or has a value the route does not accept
401Missing or invalid ID token
403The user cannot manage users (/user/*)
404The dataset, tag, group, image, model or share token does not exist, or the route does not
409The operation conflicts with the current state: a tag with the new id already exists, or the model is training
410The share link has expired
499The ZIP export was cancelled while it ran
500The operation failed. The message says how far it got when part of the work was done

Partial results ​

Most routes that work through many images go on when one image fails. Their answers count what was done and list what was not (failed, failedFiles, skipped, missing), so check those fields even on a 200.

When images could not be rewritten, the tag, review and group routes answer 500 with N images could not be updated; run it again. These operations can be repeated safely: running them again finishes the work.

Vocabulary ​

TermMeaning
Dataset typeMULTICLASS (classification), MULTILABEL (segmentation), ANOMALY (anomaly detection), imageObjectDetection (detection), imageObjectDetectionOBB (oriented boxes) or OCR
DivisionThe set an image belongs to: PREDETERMINED (not assigned), TRAIN, VALIDATION, TEST or REVIEW (waiting for review)
TagA class of a dataset, identified by its id. The id is normally the name; a renamed tag gets the id of its new name, with / replaced by _
System tagA tag the platform creates and relies on: 0 (unclassified), OK and NOK in any letter case, and any tag flagged as unclassified, anomaly or normal. System tags cannot be deleted or merged into another tag, and they keep their name
GroupA named set of images inside a dataset. An image can be in several groups
LabeledFlag of an image whose annotation work is finished