Integrating Webhook Data into Label Studio as Metadata


How can we send back webhook info to label studio and show the data along with the image as a metadata data table? I worked with Webhook to receive task-created action, worked with the image related to the task created, and created a table of data based on the image. I then want to send back the table of data and place it in the label studio interface to help labelers label the image, but not sure how to do this. Any help is appreciated!


To add metadata to a task in Label Studio and display it alongside the image, follow these steps:

  1. Send Processed Data Back to Label Studio:
    Use the Label Studio API to update the task with the metadata by employing the PATCH /api/tasks/{id} endpoint.
  2. Display Metadata in Label Studio Interface:
    Adjust the labeling configuration XML to include components capable of showing the metadata as a data table.

Step-by-Step Guide

Here is a concise example of the required steps:

  1. Updating Task with Metadata:
import requests

label_studio_url = "https://your-label-studio-instance/api"
api_token = "your_api_token"
task_id = 123  # replace with your actual task ID

# Your metadata structured as a dictionary
metadata = {
    "metadata_table": [{"column1": "value1"}, {"column1": "value2"}]

response = requests.patch(
    headers={"Authorization": f"Token {api_token}"},
    json={"data": metadata}

if response.status_code == 200:
    print("Task updated successfully.")
    print("Failed to update task:", response.content)
  1. Labeling Configuration for Displaying Data Table:

To display the metadata in the interface, use either the HyperText or Table tags in your labeling configuration XML:

<!-- If using Static HTML -->
  <Image name="image" value="$image"/>
  <HyperText name="metadata" value="$metadata_table"/>

<!-- If using Dynamic JSON Table -->
  <Image name="image" value="$image"/>
  <Table name="metadata_table" value="$metadata_table"/>

Let me know if this is helpful!