useAdminAccess is true to use the user's administrator credentials. The
server verifies that the user is an admin with the "Manage Labels" privilege
before allowing access.
This example creates a standard, admin label with a specified title and one
SelectionOptionsField with 2 Choices.
varlabel={'label_type':'ADMIN','properties':{'title':'TITLE'},'fields':[{'properties':{'display_name':'DISPLAY_NAME'},'selection_options':{'list_options':{},'choices':[{'properties':{'display_name':'CHOICE_1'}},{'properties':{'display_name':'CHOICE_2'}}]}}]};service.labels.create({'resource':label,'use_admin_access':true},(err,res)=>{if(err)returnconsole.error('The API returned an error: '+err);console.log(res);});
The label is created in the UNPUBLISHED_DRAFTState. It must be PUBLISHED
for use on files and to be visible to users. For more information, see Label
lifecycle.
Label limits
The following limits apply when creating and applying labels:
Select one or more users from Google Workspace contacts.
Maximum number of user entries for a file is 10 as configured in ListOptions
Publish a label
The Labels API lets you publish a draft label once it's complete.
To publish a label, use the
publish method and specify:
A Label resource
that represents every label. It contains a resource Name and ID, which
is a globally unique identifier for the label.
useAdminAccess is true to use the user's administrator credentials. The
server verifies that the user is an admin with the "Manage Labels" privilege
before allowing access.
This example uses the ID to identify and publish the correct label.
service.labels.publish({'resource':{'use_admin_access':true},'name':'labels/ID'},(err,res)=>{if(err)returnconsole.error('The API returned an error: '+err);console.log(res);});
Once the label is published, the label moves to the PUBLISHEDState and the label's revision
ID is incremented. The label is then visible to users and can be applied to
files. For more information, see Label
lifecycle.
Constraints when publishing labels
Once published, a label cannot return to its original draft state. For more
information, see Label lifecycle.
Publishing a label creates a newly published revision. All previous draft
revisions are deleted. Previously published revisions are kept but are
subject to automated deletion as needed.
Once published, some changes are no longer permitted. Generally, this means
any change that invalidates or triggers new restrictions on existing
metadata related to the label is rejected. For example, the following
changes to a label aren't permitted after the label is published:
The label is directly deleted. (It must be disabled first, then
deleted.)
The Field.FieldType is changed.
Updates to the Field validation options reject something previously
accepted.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Create & publish a label\n\nThis page describes how to create and publish a label.\n\nCreate a label\n--------------\n\nTo create a label, use the\n[`create`](/workspace/drive/labels/reference/rest/v2/labels/create) method on the\n[`labels`](/workspace/drive/labels/reference/rest/v2/labels) collection. Labels can\noptionally contain one or more\n[`Fields`](/workspace/drive/labels/reference/rest/v2/labels#field).\n\nYou also must specify:\n\n- A [`LabelType`](/workspace/drive/labels/reference/rest/v2/labels#labeltype).\n\n- A label `title` through the\n [`property`](/workspace/drive/labels/reference/rest/v2/labels#properties) method.\n\n- `useAdminAccess` is `true` to use the user's administrator credentials. The\n server verifies that the user is an admin with the \"Manage Labels\" privilege\n before allowing access.\n\nThis example creates a standard, admin label with a specified title and one\n[`SelectionOptions`](/workspace/drive/labels/reference/rest/v2/labels#selectionoptions)\n`Field` with 2 [`Choices`](/workspace/drive/labels/reference/rest/v2/labels#choice). \n\n### Python\n\n label_body = {\n 'label_type': 'ADMIN',\n 'properties': {\n 'title': '\u003cvar translate=\"no\"\u003eTITLE\u003c/var\u003e'\n },\n 'fields': [{\n 'properties': {\n 'display_name': '\u003cvar translate=\"no\"\u003eDISPLAY_NAME\u003c/var\u003e'\n },\n 'selection_options': {\n 'list_options': {},\n 'choices': [{\n 'properties': {\n 'display_name': '\u003cvar translate=\"no\"\u003eCHOICE_1\u003c/var\u003e'\n }\n }, {\n 'properties': {\n 'display_name': '\u003cvar translate=\"no\"\u003eCHOICE_2\u003c/var\u003e'\n }\n }]\n }\n }]\n }\n response = service.labels().create(\n body=label_body, useAdminAccess=True).execute()\n\n### Node.js\n\n var label = {\n 'label_type': 'ADMIN',\n 'properties': {\n 'title': '\u003cvar translate=\"no\"\u003eTITLE\u003c/var\u003e'\n },\n 'fields': [{\n 'properties': {\n 'display_name': '\u003cvar translate=\"no\"\u003eDISPLAY_NAME\u003c/var\u003e'\n },\n 'selection_options': {\n 'list_options': {},\n 'choices': [{\n 'properties': {\n 'display_name': '\u003cvar translate=\"no\"\u003eCHOICE_1\u003c/var\u003e'\n }\n }, {\n 'properties': {\n 'display_name': '\u003cvar translate=\"no\"\u003eCHOICE_2\u003c/var\u003e'\n }\n }]\n }\n }]\n };\n\n service.labels.create({\n 'resource': label,\n 'use_admin_access': true\n }, (err, res) =\u003e {\n if (err) return console.error('The API returned an error: ' + err);\n console.log(res);\n });\n\nThe label is created in the `UNPUBLISHED_DRAFT`\n[`State`](/workspace/drive/labels/reference/rest/v2/labels#state). It must be `PUBLISHED`\nfor use on files and to be visible to users. For more information, see [Label\nlifecycle](/workspace/drive/labels/guides/label-lifecycle).\n\n### Label limits\n\nThe following limits apply when creating and applying labels:\n\n- Standard labels---150\n- Fields per label---10\n- User-applied labels per file---5\n\n### Working with fields in labels\n\n\u003cbr /\u003e\n\n| `Field Type` | What users can do | Format considerations and limits |\n|-----------------------------------------------------------------------------------------|----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`SelectionOptions`](/workspace/drive/labels/reference/rest/v2/labels#selectionoptions) | Select one or more options from a list | Maximum number of options supported is 200 Maximum number of selections for a file is 10 as configured in [`ListOptions`](/workspace/drive/labels/reference/rest/v2/labels#listoptions) |\n| [`IntegerOptions`](/workspace/drive/labels/reference/rest/v2/labels#integeroptions) | Enter a numerical value | Only whole numbers are supported |\n| [`DateOptions`](/workspace/drive/labels/reference/rest/v2/labels#dateoptions) | Select a calendar date | (Optional) [`Date format`](/workspace/drive/labels/reference/rest/v2/labels#dateformat) can be set to \"Long: Month DD, YYYY\", or \"Short: MM/DD/YY\" |\n| [`TextOptions`](/workspace/drive/labels/reference/rest/v2/labels#textoptions) | Enter text in a text box | Maximum character count supported is 100 |\n| [`UserOptions`](/workspace/drive/labels/reference/rest/v2/labels#UserOptions) | Select one or more users from Google Workspace contacts. | Maximum number of user entries for a file is 10 as configured in [`ListOptions`](/workspace/drive/labels/reference/rest/v2/labels#listoptions) |\n\n\u003cbr /\u003e\n\nPublish a label\n---------------\n\nThe Labels API lets you publish a draft label once it's complete.\n\nTo publish a label, use the\n[`publish`](/workspace/drive/labels/reference/rest/v2/labels/publish) method and specify:\n\n- A [Label resource](/workspace/drive/labels/reference/rest/v2/labels#resource:-label)\n that represents every label. It contains a resource `Name` and `ID`, which\n is a globally unique identifier for the label.\n\n- `useAdminAccess` is `true` to use the user's administrator credentials. The\n server verifies that the user is an admin with the \"Manage Labels\" privilege\n before allowing access.\n\nThis example uses the `ID` to identify and publish the correct label. \n\n### Python\n\n service.labels().publish(\n name='labels/\u003cvar translate=\"no\"\u003eID\u003c/var\u003e',\n body={\n 'use_admin_access': True\n }).execute()\n\n### Node.js\n\n service.labels.publish({\n 'resource': {\n 'use_admin_access': true\n },\n 'name': 'labels/\u003cvar translate=\"no\"\u003eID\u003c/var\u003e'\n }, (err, res) =\u003e {\n if (err) return console.error('The API returned an error: ' + err);\n console.log(res);\n });\n\nOnce the label is published, the label moves to the `PUBLISHED`\n[`State`](/workspace/drive/labels/reference/rest/v2/labels#state) and the label's revision\nID is incremented. The label is then visible to users and can be applied to\nfiles. For more information, see [Label\nlifecycle](/workspace/drive/labels/guides/label-lifecycle).\n\n### Constraints when publishing labels\n\n- Once published, a label cannot return to its original draft state. For more\n information, see [Label lifecycle](/workspace/drive/labels/guides/label-lifecycle).\n\n- Publishing a label creates a newly published revision. All previous draft\n revisions are deleted. Previously published revisions are kept but are\n subject to automated deletion as needed.\n\n- Once published, some changes are no longer permitted. Generally, this means\n any change that invalidates or triggers new restrictions on existing\n metadata related to the label is rejected. For example, the following\n changes to a label aren't permitted after the label is published:\n\n - The label is directly deleted. (It must be disabled first, then deleted.)\n - The `Field.FieldType` is changed.\n - Updates to the Field validation options reject something previously accepted.\n - A reduction in maximum entries."]]