Skip to content

Google: Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified

Google driveFiles.driveFilesModifyLabels: arguments, response, policy and SDK examples.

← Drive files operations · Get started

Operation google.drive_files_modifylabels

Provider route: POST /drive/v3/files/{fileId}/modifyLabels. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/google with npm, or alter-sdk-google with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { GoogleIntegration } from "@alter-ai/google";
async function execute(input: Parameters<GoogleIntegration["driveFiles"]["driveFilesModifyLabels"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new GoogleIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.driveFiles.driveFilesModifyLabels(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_google import GoogleIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = GoogleIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.drive_files.drive_files_modify_labels(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.fileIdstringRequired within parentThe ID of the file to which the labels belong.
queryobjectOptionalAdditional keys: not allowed
query.fieldsstringOptionalSelector specifying which fields to include in a partial response.
query.prettyPrintbooleanOptionalReturns response with indentations and line breaks.
Default: true
query.quotaUserstringOptionalAvailable to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
bodyModelRequired within parentExpand Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — request body — body

Referenced models: Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — request body — body

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — response body

Referenced models: Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — response body

Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — response body
FieldTypePresenceDescription and constraints
$objectRootResponse to a `ModifyLabels` request. This contains only those labels which were added or updated by the request.
kindstringOptionalThis is always `"drive#modifyLabelsResponse"`.
modifiedLabelsarrayOptionalThe list of labels which were added or updated by the request.
modifiedLabels[]ModelEach itemExpand Lists the labels on a file For more information, see List labels on a file (https: developers google com workspace drive api guides list-labels) — response body — labels item

Referenced models: Lists the labels on a file For more information, see List labels on a file (https: developers google com workspace drive api guides list-labels) — response body — labels item

Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — request body — body
FieldTypePresenceDescription and constraints
$objectRootA request to modify the set of labels on a file. This request may contain many modifications that will either all succeed or all fail atomically.
kindstringOptionalThis is always `"drive#modifyLabelsRequest"`.
labelModificationsarrayOptionalThe list of modifications to apply to the labels on the file.
labelModifications[]ModelEach itemExpand Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — request body — body label Modifications item

Referenced models: Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — request body — body label Modifications item

Lists the labels on a file For more information, see List labels on a file (https: developers google com workspace drive api guides list-labels) — response body — labels item
FieldTypePresenceDescription and constraints
$objectRootRepresentation of label and label fields.
fieldsobjectOptionalA map of the fields on the label, keyed by the field's ID.
Additional keys: see wildcard field
fields.*ModelAdditional keysExpand Lists the labels on a file For more information, see List labels on a file (https: developers google com workspace drive api guides list-labels) — response body — labels item fields value
idstringOptionalThe ID of the label.
kindstringOptionalThis is always drive#label
revisionIdstringOptionalThe revision ID of the label.

Referenced models: Lists the labels on a file For more information, see List labels on a file (https: developers google com workspace drive api guides list-labels) — response body — labels item fields value

Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — request body — body label Modifications item
FieldTypePresenceDescription and constraints
$objectRootA modification to a label on a file. A `LabelModification` can be used to apply a label to a file, update an existing label on a file, or remove a label from a file.
fieldModificationsarrayOptionalThe list of modifications to this label's fields.
fieldModifications[]ModelEach itemExpand Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — request body — body label Modifications item field Modifications item
kindstringOptionalThis is always `"drive#labelModification"`.
labelIdstringRequired within parentThe ID of the label to modify.
removeLabelbooleanOptionalIf true, the label will be removed from the file.

Referenced models: Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — request body — body label Modifications item field Modifications item

Lists the labels on a file For more information, see List labels on a file (https: developers google com workspace drive api guides list-labels) — response body — labels item fields value
FieldTypePresenceDescription and constraints
$objectRootRepresentation of field, which is a typed key-value pair.
dateStringarrayOptionalOnly present if valueType is dateString. RFC 3339 formatted date: YYYY-MM-DD.
dateString[]stringEach itemFormat: date
idstringOptionalThe identifier of this label field.
integerarrayOptionalOnly present if `valueType` is `integer`.
integer[]stringEach itemFormat: int64
kindstringOptionalThis is always drive#labelField.
selectionarrayOptionalOnly present if `valueType` is `selection`
selection[]stringEach item
textarrayOptionalOnly present if `valueType` is `text`.
text[]stringEach item
userarrayOptionalOnly present if `valueType` is `user`.
user[]ModelEach itemExpand Gets information about the user, the user's Drive, and system capabilities. For more information, see [Return user info](https://developers.google.com/workspace/drive/api/guides/user-info). Required: The `fields` parameter must be set To return the exact fields you need, see Return specific fields (https: developers google com workspace drive api guides fields-parameter) — response body — user
valueTypestringOptionalThe field type. While new values may be supported in the future, the following are currently allowed: * `dateString` * `integer` * `selection` * `text` * `user`

Referenced models: Gets information about the user, the user's Drive, and system capabilities. For more information, see [Return user info](https://developers.google.com/workspace/drive/api/guides/user-info). Required: The `fields` parameter must be set To return the exact fields you need, see Return specific fields (https: developers google com workspace drive api guides fields-parameter) — response body — user

Modifies the set of labels applied to a file For more information, see Set a label field on a file (https: developers google com workspace drive api guides set-label) Returns a list of the labels that were added or modified — request body — body label Modifications item field Modifications item
FieldTypePresenceDescription and constraints
$objectRootA modification to a label's field.
fieldIdstringOptionalThe ID of the field to be modified.
kindstringOptionalThis is always `"drive#labelFieldModification"`.
setDateValuesarrayOptionalReplaces the value of a dateString Field with these new values. The string must be in the RFC 3339 full-date format: YYYY-MM-DD.
setDateValues[]stringEach itemFormat: date
setIntegerValuesarrayOptionalReplaces the value of an `integer` field with these new values.
setIntegerValues[]stringEach itemFormat: int64
setSelectionValuesarrayOptionalReplaces a `selection` field with these new values.
setSelectionValues[]stringEach item
setTextValuesarrayOptionalSets the value of a `text` field.
setTextValues[]stringEach item
setUserValuesarrayOptionalReplaces a `user` field with these new values. The values must be a valid email addresses.
setUserValues[]stringEach item
unsetValuesbooleanOptionalUnsets the values for this field.
Gets information about the user, the user's Drive, and system capabilities. For more information, see [Return user info](https://developers.google.com/workspace/drive/api/guides/user-info). Required: The `fields` parameter must be set To return the exact fields you need, see Return specific fields (https: developers google com workspace drive api guides fields-parameter) — response body — user
FieldTypePresenceDescription and constraints
$objectRootInformation about a Drive user.
displayNamestringOptionalOutput only. A plain text displayable name for this user.
Read only: true
emailAddressstringOptionalOutput only. The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.
Read only: true
kindstringOptionalOutput only. Identifies what kind of resource this is. Value: the fixed string `drive#user`.
Default: drive#user
Read only: true
mebooleanOptionalOutput only. Whether this user is the requesting user.
Read only: true
permissionIdstringOptionalOutput only. The user's ID as visible in Permission resources.
Read only: true
photoLinkstringOptionalOutput only. A link to the user's profile photo, if available.
Read only: true

SDK function policy ID: google.drive_files_modifylabels. Catalog operation: drive.files.modifyLabels. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Required provider scopes: ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive.metadata"]

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.