Attachments

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, text string, or HTML file, you will need to run the createAssetAttachment mutation multiple times which will append the attachment to the existing attachments on that Data Row.

FieldTypeDescription
data.dataRowIdIDID of the Data Row to add the attachments to
data.valueStringAccepts an https URL to an external file OR a string of text
data.typeAttachmentTypeValues are:
IMAGE, VIDEO, TEXT, HTML
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).

FieldTypeDescription
attachments.idIDID of the Attachment on the Data Row.
attachments.typeAttachmentTypeAttachment type. Should be IMAGE, VIDEO, TEXT, or HTML.
attachments.valueStringAn 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.

FieldTypeDescription
data.valueStringAccepts an https URL to an external file OR a string of text
data.typeAttachmentTypeValues are:
IMAGE, VIDEO, TEXT, or HTML.
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
  }
}