Attachments are media you can attach to a Data Row to provide labelers with contextual information about the asset to be labeled.

📘

Note

In an effort to make the Labelbox terminology more accurate, we have renamed asset metadata to attachments in this context. Please use the updated queries and mutations below going forward.

Add attachments

To add attachments to a Data Row, use the createDataRowAttachment mutation (previously createAssetMetadata).

To attach more than one image, video, or text string, you will need to run the createAssetAttachment mutation multiple times which will append the attachment to the existing attachments on that Data Row.

Field

Type

Description

data.dataRowId

ID

ID of the Data Row to add the attachments to

data.value

String

Accepts an https URL to an external file OR a string of text

data.type

AttachmentType

Values are:
IMAGE, VIDEO, TEXT, IMAGE_OVERLAY

mutation AddAttachment {
    createDataRowAttachment (
        data:{
            dataRowId:"<DATAROW_ID>",
            value:"https://firebasestorage.googleapis.com/v0/b/labelbox-193903.appspot.com/o/cjhk4p9dyf5va0702liitudpz%2Fd3ffab29-d6be-4d69-b006-89a828679d29%2Fleft_small-pen-test-site_1_1537524039648.jpg?alt=media&token=66e84e55-97e8-46a6-9ab8-685f1e950581",
            type: IMAGE
        }
    ) {
        id
    }
}

Get attachments

Use this query to get the list of attachments (previously called asset metadata).

Field

Type

Description

attachments.id

ID

ID of the Attachment on the Data Row.

attachments.type

AttachmentType

Attachment type. Should be IMAGE, VIDEO, TEXT, or IMAGE_OVERLAY.

attachments.value

String

An https URL to an external file or a string of text.

query GetAttachmentByDataRowId {
    dataRow (where: {id: "<DATAROW_ID>"}) {
        attachments {
            id
            type
            value
        }
    }
}
# metadata in this context will soon be deprecated
query GetAttachmentByDataRowId {
    dataRow (where: {id: "<DATAROW_ID>"}) {
        metadata {
            id
            metaValue
            metaType
        }
    }
}

Edit attachments

First, use this query to get the ID for the attachments (previously referred to as metadata).

Then, use updateDataRowAttachment (previously updateAssetMetadata) to update an attachment on a Data Row.

Field

Type

Description

data.value

String

Accepts an https URL to an external file OR a string of text

data.type

AttachmentType

Values are:
IMAGE, VIDEO, TEXT, or IMAGE_OVERLAY.

query GetAttachmentId {
    dataRow (where: {id: "<DATAROW_ID>"}) {
        id
        attachments {
            id
        }
    }
}
mutation UpdateAttachment {
    updateDataRowAttachment (
        where: {
            id:"<ATTACHMENT_ID>"
        },
        data:{
            value:"https://storage.googleapis.com/labelbox-sample-datasets/nlp/lorem-ipsum.txt",
            type: TEXT
        }
    ){
        id
    }
}

Remove attachments

Then, use the deleteDataRowAttachment (previously deleteAssetMetadata) mutation to remove the attachments.

mutation RemoveAttachment {
  deleteDataRowAttachment (
    where: {
      id:"<ATTACHMENT_ID>"
    }
  ){
    id
    type
  }
}