Skip to main content
The Ingestion API is used to send new device data to Edge Impulse. It’s available on both HTTP and HTTPS endpoints and requires an API key to authenticate. The API is available at:

Supported file types

With the Ingestion API, you can upload the following types of files: *Video files can be split into individual frames after uploading to Studio.

Endpoints

Files endpoint

These are the endpoints available for the Ingestion API:
  • POST /api/training/files - for adding data samples to the training set
  • POST /api/validation/files - for adding data samples to the validation set
  • POST /api/testing/files - for adding data samples to the test set
  • POST /api/post-processing/files - for adding data samples to the post-processing set
  • POST /api/split/files - for adding samples automatically split across the training, validation, and test sets
Notes:
  • The maximum number of files you can upload in a single request is 1000
  • The maximum size of a single file is 100 MB
  • The validation endpoint is only available if the explicit validation set advanced setting is enabled in your project
  • The split endpoint splits the files into training, validation, and test sets based on the split percentages defined in your project
  • If you have the ‘Live classification’ page open in your browser while uploading to the testing endpoint, the file will automatically be classified against the current impulse.
The minimal request to the api/training/files endpoint is the following:
The request body is presented using Python notation for binary strings for readability purposes. Normally it is a stream of bytes.

Data endpoint (legacy)

Because the files endpoints expect Content-Type to be multipart/form-data, there are also available legacy endpoints that require simpler requests:
  • POST /api/training/data
  • POST /api/testing/data
  • POST /api/anomaly/data
The minimal request to the api/training/data endpoint is the following:
The request body is presented using Python notation for binary strings for readability purposes. Normally it is a stream of bytes.

Header Parameters

  • x-api-key - API Key (required).
  • x-label - Label (optional). If this header is not provided a label is automatically inferred from the filename through the following regex: ^[a-zA-Z0-9\s-_]+ - For example: idle.01 will yield the label idle. If you don’t want to assign the label nor derive it from the file name, provide an x-no-label header with the value 1.
  • x-disallow-duplicates - When set, the server checks the hash of the message against your current dataset (optional). We’d recommend setting this header but haven’t enabled it by default for backward compatibility.
  • x-add-date-id: 1 - to add a date ID to the filename. For example: if you upload with filename test.wav the file name will be test - set this option and we’ll add a unique ID to the end (this is what we use on the daemon to create unique names).
  • x-metadata - JSON-encoded string of key/value pairs to attach as metadata to the uploaded sample(s) (optional). For example: {"site":"Paris","source":"field-trial-2"}. Metadata can be used to control train/validation splits, drive data pipeline synchronisation, and slice model performance by attribute.
  • x-bounding-boxes - JSON-encoded array of bounding boxes to attach to the uploaded image(s) (optional, object detection projects only). See Bounding boxes below.
  • Content-type - format of data used. Can be application/cbor, application/json, or multipart/form-data.

Bounding boxes

For object detection projects you can label images at upload time by passing an x-bounding-boxes header. The value is a JSON-encoded array of objects, each requiring all five of the following properties: Coordinates are absolute pixel values relative to the top-left corner of the image, not normalized 0..1 values. For example, to send two boxes:
Your project must be in object detection labeling modeIf the project’s labeling method is set to One label per data item (the default for a new project), bounding boxes sent in the x-bounding-boxes header are silently discarded. The upload still succeeds, but the sample is stored with an empty list of bounding boxes.Set the labeling method to Bounding boxes (object detection) in your project’s dashboard, under Project info > Labeling method, before uploading. You can also set it through the API:
The header applies to every file in the requestWhen you upload multiple files in a single multipart/form-data request, the same x-bounding-boxes value is applied to all of them. To label each file individually, either send one request per image, or include a bounding_boxes.labels file in the request, which takes precedence over the header on a per-file basis.

Validation errors

If the header cannot be parsed, or a box is missing a required property, the affected file is rejected and not stored. Note that the files endpoints still return HTTP 200 in this case. The per-file outcome is reported in the response body, so you must inspect files[].success rather than relying on the status code alone:
The possible errors are x-bounding-boxes is not valid json, x-bounding-boxes is not a valid array, and x-bounding-boxes <property> is required for each of label, x, y, width and height. A property is also reported as missing when it has the wrong type. For example, a string "120" instead of the number 120.

Responses

All responses are sent with content type text/plain. The following response codes may be returned:
  • 200 - Stored the file, file name is in the body.
  • 400 - Invalid message, e.g. fields are missing, or are invalid. See body for more information.
  • 401 - Missing x-api-key header, or invalid API key.
  • 421 - Missing header, see body for more information.
  • 500 - Internal server error, see body for more information.
A 200 does not always mean every file was storedThe files endpoints reply with a JSON body containing a per-file result, and a file that fails validation is reported there rather than through the status code. Always iterate over files[] and check each success flag:

Examples

Uploading an image with bounding boxes

Object detection projects need bounding boxes alongside the image. Send one image per request so each image gets its own boxes:

Raw requests

On the embedded devices, usually, there are no high-level libraries available to perform HTTP requests. In this case, you can use the following example to prepare an HTTP request to the Ingestion API: The ingestion service accepts raw requests with data formatted as JSON or CBOR. We will use the following JSON structure as an example sample: