필드 마스크는 API 호출자가 요청에서 반환하거나 업데이트해야 하는 필드를 나열하는 방법입니다. FieldMask를 사용하면 API가 불필요한 작업을 방지하고 성능을 개선할 수 있습니다. 필드 마스크는 Google Slides API의 읽기 및 업데이트 메서드 모두에 사용됩니다.
필드 마스크를 사용하지 않는 경우와 사용하는 경우 응답 본문에 반환되는 항목을 비교하려면 부분 리소스 작업을 참고하세요.
필드 마스크로 읽기
프레젠테이션은 클 수 있으며 읽기 요청에서 반환된 presentations 리소스의 모든 부분이 필요하지 않은 경우가 많습니다. fields URL 매개변수를 사용하여 Slides API 응답에서 반환되는 항목을 제한할 수 있습니다. 최적의 성능을 위해 답장에서 필요한 필드만 명시적으로 나열하세요.
fields 매개변수의 형식은 FieldMask의 JSON 인코딩과 동일합니다.
간단히 말해 여러 필드는 쉼표로 구분되고 하위 필드는 점으로 구분됩니다. 필드 이름은 camelCase 또는 separated_by_underscores로 지정할 수 있습니다. 편의를 위해 동일한 유형의 여러 하위 필드를 괄호 안에 나열할 수 있습니다.
다음 presentations.get 메서드 요청 예에서는 slides.pageElements(objectId,size,transform) 필드 마스크를 사용하여 프레젠테이션의 모든 슬라이드에서 pageElement 객체의 객체 ID(Size)와 변환만 가져옵니다.
GET https://slides.googleapis.com/v1/presentations/presentationId?fields=slides.pageElements(objectId,size,transform)
이 메서드 호출에 대한 응답은 필드 마스크에 요청된 구성요소가 포함된 presentations 객체입니다.
다른 필드는 변경하지 않고 객체의 특정 필드만 업데이트해야 하는 경우가 있습니다. presentations.batchUpdate 메서드 내의 업데이트 요청은 필드 마스크를 사용하여 변경되는 필드를 API에 알려줍니다. 업데이트 요청은 필드 마스크에 지정되지 않은 모든 필드를 무시하고 현재 값을 그대로 둡니다.
업데이트된 메시지에서 필드를 지정하지 않고 마스크에 필드를 추가하여 필드를 설정 해제할 수도 있습니다. 이렇게 하면 필드에 이전에 있던 값이 지워집니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-29(UTC)"],[],[],null,["# Use field masks\n\nField masks are a way for API callers to list fields that a request should\nreturn or update. Using a\n[FieldMask](https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask)\nallows the API to avoid unnecessary work and improves performance. A field mask\nis used for both the read and update methods in the Google Slides API.\n\nFor a comparison of what's returned in a response body when you don't use a\nfield mask versus when you do, see [Working with partial\nresources](/workspace/slides/api/guides/performance#partial).\n\nRead with a field mask\n----------------------\n\nPresentations can be large, and often you don't need every part of the\n[`presentations`](/workspace/slides/api/reference/rest/v1/presentations)\nresource returned by a read request. You can limit what's returned in a\nSlides API response, using the `fields` URL parameter. For best\nperformance, [explicitly list only the fields you\nneed](/workspace/slides/how-tos/performance#partial) in the reply.\n\nThe format of the fields parameter is the same as the [JSON encoding of a\nFieldMask](https://protobuf.dev/reference/protobuf/google.protobuf/#json-encoding-field-masks).\nStated briefly, multiple different fields are comma-separated and subfields are\ndot-separated. Field names can be specified in **camelCase** or\n**separated_by_underscores**. For convenience, multiple subfields from the same\ntype can be listed within parentheses.\n\nThe following\n[`presentations.get`](/workspace/slides/api/reference/rest/v1/presentations/get)\nmethod request example uses a field mask of\n`slides.pageElements(objectId,size,transform)` to fetch only the object ID,\n[`Size`](/workspace/slides/api/reference/rest/v1/Size), and\n[transform](/workspace/slides/api/reference/rest/v1/presentations.pages/other#affinetransform)\nof a\n[`pageElement`](/workspace/slides/api/reference/rest/v1/presentations.pages#pageelement)\nobject on all slides in a presentation: \n\n```\nGET https://slides.googleapis.com/v1/presentations/presentationId?fields=slides.pageElements(objectId,size,transform)\n```\n\nThe response to this method call is a\n[`presentations`](/workspace/slides/api/reference/rest/v1/presentations) object\ncontaining the components requested in the field mask: \n\n {\n \"slides\": [\n {\n \"pageElements\": [\n {\n \"objectId\": \"\u003cvar translate=\"no\"\u003eOBJECT_ID\u003c/var\u003e\",\n \"size\": {\n \"width\": {\n \"magnitude\": 3000000,\n \"unit\": \"EMU\"\n },\n \"height\": {\n \"magnitude\": 3000000,\n \"unit\": \"EMU\"\n }\n },\n \"transform\": {\n \"scaleX\": 1,\n \"scaleY\": 1\n \"translateX\": 311708,\n \"translateY\": 744575,\n \"unit\": \"EMU\"\n }\n },\n {\n \"objectId\": \"\u003cvar translate=\"no\"\u003eOBJECT_ID\u003c/var\u003e\",\n \"size\": {\n \"width\": {\n \"magnitude\": 3000000,\n \"unit\": \"EMU\"\n },\n \"height\": {\n \"magnitude\": 3000000,\n \"unit\": \"EMU\"\n }\n },\n \"transform\": {\n \"scaleX\": 1,\n \"scaleY\": 1\n \"translateX\": 311700,\n \"translateY\": 2834125,\n \"unit\": \"EMU\"\n }\n }\n ]\n }\n ]\n }\n\nUpdate with a field mask\n------------------------\n\nSometimes you need to update only certain fields in an object while leaving the\nother fields unchanged. Update requests inside a\n[`presentations.batchUpdate`](/workspace/slides/api/reference/rest/v1/presentations/batchUpdate)\nmethod use field masks to tell the API which fields are being changed. The\nupdate request ignores any fields that aren't specified in the field mask,\nleaving them with their current values.\n\nYou can also unset a field by not specifying it in the updated message, but\nadding the field to the mask. This clears whatever value the field previously\nhad.\n\nThe syntax for update field masks is the same as read field masks.\n| A field mask of `*` is treated like a wildcard and is shorthand for specifying every field in a message. The wildcard syntax can produce unwanted results if the API is updated in the future, as read-only fields and newly added fields may cause errors. For production applications, always list the specific fields being updated in field masks and avoid using `*` wildcards.\n\nThe following example uses the\n[`UpdateShapePropertiesRequest`](/workspace/slides/api/reference/rest/v1/presentations/request#updateshapepropertiesrequest)\nmethod to change a shape's color fill to the `DARK1` theme color and unset the\nshape's outline: \n\n```\nPOST https://slides.googleapis.com/v1/presentations/presentationId:batchUpdate\n``` \n\n {\n \"requests\": [\n {\n \"updateShapeProperties\": {\n \"objectId\": \u003cvar translate=\"no\"\u003eOBJECT_ID\u003c/var\u003e,\n \"shapeProperties\": {\n \"shapeBackgroundFill\": {\n \"solidFill\": {\n \"color\": {\n \"themeColor\": \"DARK1\"\n }\n }\n }\n },\n \"fields\": \"shapeBackgroundFill.solidFill.color,outline\"\n }\n }\n ]\n }"]]