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:
| Function | Base URL | Time limit | Memory |
|---|---|---|---|
api | https://europe-west1-<projectId>.cloudfunctions.net/api | 60 s | 1 GB |
usapi | https://us-central1-<projectId>.cloudfunctions.net/usapi | 3600 s | 4 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:
POST /usapi/dataset/rp-obj-bottles/delete HTTP/1.1
Host: us-central1-<projectId>.cloudfunctions.net
Authorization: Bearer <ID token>
Content-Type: application/jsonAn 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:
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.
| Routes | Who can call them |
|---|---|
/ping | Anyone, 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 |
/mcp | Whoever holds the MCP token of the project, which is not an ID token: see Connecting a client |
| Every other route | Any 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:
{ "images": ["Qm3xZ0aT9kLw2VbN7cYd"], "change": { "set": "TEST" } }{ "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:
{ "data": { "id": "rp-obj-bottles", "updated": 128 } }A failed call answers with a 4xx or 5xx status and a message:
{ "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.
| Status | Meaning |
|---|---|
200 | Done. Operations over many images may still list the ones that failed: see below |
400 | A field is missing or has a value the route does not accept |
401 | Missing or invalid ID token |
403 | The user cannot manage users (/user/*) |
404 | The dataset, tag, group, image, model or share token does not exist, or the route does not |
409 | The operation conflicts with the current state: a tag with the new id already exists, or the model is training |
410 | The share link has expired |
499 | The ZIP export was cancelled while it ran |
500 | The 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
| Term | Meaning |
|---|---|
| Dataset type | MULTICLASS (classification), MULTILABEL (segmentation), ANOMALY (anomaly detection), imageObjectDetection (detection), imageObjectDetectionOBB (oriented boxes) or OCR |
| Division | The set an image belongs to: PREDETERMINED (not assigned), TRAIN, VALIDATION, TEST or REVIEW (waiting for review) |
| Tag | A 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 tag | A 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 |
| Group | A named set of images inside a dataset. An image can be in several groups |
| Labeled | Flag of an image whose annotation work is finished |