Đặt operatingAccount thành sản phẩm và mã nhận dạng của tài khoản sẽ nhận dữ liệu đối tượng.
Chuẩn bị dữ liệu về đối tượng
Hãy xem xét dữ liệu mẫu sau đây trong một tệp được phân tách bằng dấu phẩy. Mỗi dòng trong tệp tương ứng với một thành viên của đối tượng và mỗi thành viên có tối đa 3 địa chỉ email.
Dưới đây là một mẫu AudienceMember cho địa chỉ email đã được định dạng, băm và mã hoá của dana@example.com và danam@example.com từ hàng đầu tiên của dữ liệu đầu vào:
Cập nhật các phần giữ chỗ trong nội dung, chẳng hạn như OPERATING_ACCOUNT_PRODUCT, OPERATING_ACCOUNT_ID và AUDIENCE_ID bằng các giá trị cho tài khoản và đích đến của bạn.
Đặt validateOnly thành true để xác thực yêu cầu mà không áp dụng các thay đổi. Khi bạn đã sẵn sàng áp dụng các thay đổi, hãy đặt validateOnly thành false.
Yêu cầu không thành công sẽ dẫn đến mã trạng thái phản hồi lỗi, chẳng hạn như 400 Bad
Request và phản hồi có thông tin chi tiết về lỗi.
Ví dụ: email_address chứa một chuỗi văn bản thuần tuý thay vì một giá trị được mã hoá hex sẽ tạo ra phản hồi sau:
{"error":{"code":400,"message":"There was a problem with the request.","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"INVALID_ARGUMENT","domain":"datamanager.googleapis.com"},{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"audience_members.audience_members[0].user_data.user_identifiers","description":"Email is not hex encoded.","reason":"INVALID_HEX_ENCODING"}]}]}}
Một email_address không được băm và chỉ được mã hoá theo hệ thập lục phân sẽ tạo ra phản hồi sau:
{"error":{"code":400,"message":"There was a problem with the request.","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"INVALID_ARGUMENT","domain":"datamanager.googleapis.com"},{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"audience_members.audience_members[0]","reason":"INVALID_SHA256_FORMAT"}]}]}}
Các bước tiếp theo
Định cấu hình quy trình xác thực và thiết lập môi trường bằng một thư viện ứng dụng.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-13 UTC."],[],[],null,["# Send audience members\n\nYou can work through this quickstart to get familiar with the Data Manager API.\nChoose the version of the quickstart you want to see:\n\nAdvertiser Data Partner\n\nIn this quickstart, you complete the following steps:\n\n1. Prepare a [`Destination`](/data-manager/api/reference/rest/v1/Destination) to receive audience data.\n2. Prepare audience data to send.\n3. Build an [`IngestionService`](/data-manager/api/reference/rest/v1/audienceMembers/ingest) request for audience members.\n4. Send the request with the Google APIs Explorer.\n5. Understand success and failure responses.\n\nPrepare a destination\n---------------------\n\nBefore you can send data, you need to prepare the destination to send the data\nto. Here's a sample `Destination` for you to use: \n\n {\n \"operatingAccount\": {\n \"product\": \"\u003cvar translate=\"no\"\u003eOPERATING_ACCOUNT_PRODUCT\u003c/var\u003e\",\n \"accountId\": \"\u003cvar translate=\"no\"\u003eOPERATING_ACCOUNT_ID\u003c/var\u003e\"\n },\n\n \"productDestinationId\": \"\u003cvar translate=\"no\"\u003eAUDIENCE_ID\u003c/var\u003e\"\n }\n\n- Set the `operatingAccount` to the product and ID of the account that will\n receive the audience data.\n\nPrepare audience data\n---------------------\n\nConsider the following sample data in a comma-separated file. Each line in the\nfile corresponds to one member of the audience, and each member has up to three\nemail addresses. \n\n #,email_1,email_2,email_3\n 1,dana@example.com,DanaM@example.com,\n 2,ALEXJ@example.com, AlexJ@cymbalgroup.com,alexj@altostrat.com\n 3,quinn@CYMBALGROUP.com,baklavainthebalkans@gmail.com ,\n 4,rosario@example.org,cloudySanFrancisco@GMAIL.com,\n\nEmail addresses have the following [formatting](/data-manager/api/get-started/formatting) and\nhashing requirements:\n\n1. Remove all leading, trailing, and intermediate whitespace.\n2. Convert the email address to lowercase.\n3. Hash the email address using the [SHA-256 algorithm](//en.wikipedia.org/wiki/SHA-2).\n4. Encode the hash bytes using [hexadecimal](//en.wikipedia.org/wiki/Hexadecimal) (hex) or [Base64 encoding](//en.wikipedia.org/wiki/Base64). The examples in this guide use hex encoding.\n\nHere's the formatted data: \n\n #,email_1,email_2,email_3\n 1,dana@example.com,danam@example.com,\n 2,alexj@example.com,alexj@cymbalgroup.com,alexj@altostrat.com\n 3,quinn@cymbalgroup.com,baklavainthebalkans@gmail.com,\n 4,rosario@example.org,cloudysanfrancisco@gmail.com,\n\nAnd here's the data after being hashed and encoded: \n\n #,email_1,email_2,email_3\n 1,07e2f1394b0ea80e2adca010ea8318df697001a005ba7452720edda4b0ce57b3,1df6b43bc68dd38eca94e6a65b4f466ae537b796c81a526918b40ac4a7b906c7\n 2,2ef46c4214c3fc1b277a2d976d55194e12b899aa50d721f28da858c7689756e3,54e410b14fa652a4b49b43aff6eaf92ad680d4d1e5e62ed71b86cd3188385a51,e8bd3f8da6f5af73bec1ab3fbf7beb47482c4766dfdfc94e6bd89e359c139478\n 3,05bb62526f091b45d20e243d194766cca8869137421047dc53fa4876d111a6f0,f1fcde379f31f4d446b76ee8f34860eca2288adc6b6d6c0fdc56d9eee75a2fa5\n 4,83a834cc5327bc4dee7c5408988040dc5813c7662611cd93b707aff72bf7d33f,223ebda6f6889b1494551ba902d9d381daf2f642bae055888e96343d53e9f9c4\n\nHere's a sample `AudienceMember` for the formatted, hashed, and encoded email\naddresses of `dana@example.com` and `danam@example.com` from the first row of\nthe input data: \n\n {\n \"userData\": {\n \"userIdentifiers\": [\n {\n \"emailAddress\": \"07e2f1394b0ea80e2adca010ea8318df697001a005ba7452720edda4b0ce57b3\"\n },\n {\n \"emailAddress\": \"1df6b43bc68dd38eca94e6a65b4f466ae537b796c81a526918b40ac4a7b906c7\"\n }\n ]\n }\n }\n\nBuild the request body\n----------------------\n\nCombine the `Destination` and `userData` for the request body: \n\n {\n \"destinations\": [\n {\n \"operatingAccount\": {\n \"product\": \"\u003cvar translate=\"no\"\u003eOPERATING_ACCOUNT_PRODUCT\u003c/var\u003e\",\n \"accountId\": \"\u003cvar translate=\"no\"\u003eOPERATING_ACCOUNT_ID\u003c/var\u003e\"\n },\n\n \"productDestinationId\": \"\u003cvar translate=\"no\"\u003eAUDIENCE_ID\u003c/var\u003e\"\n }\n ],\n \"audienceMembers\": [\n {\n \"userData\": {\n \"userIdentifiers\": [\n {\n \"emailAddress\": \"07e2f1394b0ea80e2adca010ea8318df697001a005ba7452720edda4b0ce57b3\"\n },\n {\n \"emailAddress\": \"1df6b43bc68dd38eca94e6a65b4f466ae537b796c81a526918b40ac4a7b906c7\"\n }\n ]\n }\n },\n {\n \"userData\": {\n \"userIdentifiers\": [\n {\n \"emailAddress\": \"2ef46c4214c3fc1b277a2d976d55194e12b899aa50d721f28da858c7689756e3\"\n },\n {\n \"emailAddress\": \"54e410b14fa652a4b49b43aff6eaf92ad680d4d1e5e62ed71b86cd3188385a51\"\n },\n {\n \"emailAddress\": \"e8bd3f8da6f5af73bec1ab3fbf7beb47482c4766dfdfc94e6bd89e359c139478\"\n }\n ]\n }\n },\n {\n \"userData\": {\n \"userIdentifiers\": [\n {\n \"emailAddress\": \"05bb62526f091b45d20e243d194766cca8869137421047dc53fa4876d111a6f0\"\n },\n {\n \"emailAddress\": \"f1fcde379f31f4d446b76ee8f34860eca2288adc6b6d6c0fdc56d9eee75a2fa5\"\n }\n ]\n }\n },\n {\n \"userData\": {\n \"userIdentifiers\": [\n {\n \"emailAddress\": \"83a834cc5327bc4dee7c5408988040dc5813c7662611cd93b707aff72bf7d33f\"\n },\n {\n \"emailAddress\": \"223ebda6f6889b1494551ba902d9d381daf2f642bae055888e96343d53e9f9c4\"\n }\n ]\n }\n }\n ],\n \"consent\": {\n \"adUserData\": \"CONSENT_GRANTED\",\n \"adPersonalization\": \"CONSENT_GRANTED\"\n },\n \"encoding\": \"HEX\",\n \"termsOfService\": {\n \"customerMatchTermsOfServiceStatus\": \"ACCEPTED\"\n },\n \"validateOnly\": \u003cvar scope=\"VALIDATE_ONLY\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-kc\"\u003etrue\u003c/span\u003e\u003c/var\u003e\n }\n\n1. Update the placeholders in the body, such as \u003cvar translate=\"no\"\u003eOPERATING_ACCOUNT_PRODUCT\u003c/var\u003e, \u003cvar translate=\"no\"\u003eOPERATING_ACCOUNT_ID\u003c/var\u003e, and \u003cvar translate=\"no\"\u003eAUDIENCE_ID\u003c/var\u003e with the values for your account and destination.\n2. Set `validateOnly` to `true` to validate the request without applying the changes. When you're ready to apply the changes, set `validateOnly` to `false`.\n3. Set `termsOfService` to indicate that the user has accepted the [Customer\n Match terms of service](//support.google.com/adspolicy/answer/6299717).\n4. Note this request indicates that `consent` is granted, and doesn't use encryption.\n\nSend the request\n----------------\n\n1. Copy the request body using the copy button at the top right of the sample.\n2. Click the **API** button in the toolbar.\n3. Paste the copied request body into the **Request body** box.\n4. Click the **Execute** button, complete the authorization prompts, and review the response.\n\nSuccess responses\n-----------------\n\nA successful request returns a response with an object containing a `requestId`. \n\n {\n \"requestId\": \"126365e1-16d0-4c81-9de9-f362711e250a\"\n }\n\nFailure responses\n-----------------\n\nA failed request results in an error response status code such as `400 Bad\nRequest`, and a response with error details.\n\nFor example, an `email_address` containing a plain text string instead of a hex\nencoded value produces the following response: \n\n {\n \"error\": {\n \"code\": 400,\n \"message\": \"There was a problem with the request.\",\n \"status\": \"INVALID_ARGUMENT\",\n \"details\": [\n {\n \"@type\": \"type.googleapis.com/google.rpc.ErrorInfo\",\n \"reason\": \"INVALID_ARGUMENT\",\n \"domain\": \"datamanager.googleapis.com\"\n },\n {\n \"@type\": \"type.googleapis.com/google.rpc.BadRequest\",\n \"fieldViolations\": [\n {\n \"field\": \"audience_members.audience_members[0].user_data.user_identifiers\",\n \"description\": \"Email is not hex encoded.\",\n \"reason\": \"INVALID_HEX_ENCODING\"\n }\n ]\n }\n ]\n }\n }\n\nAn `email_address` that isn't hashed and is only hex encoded produces the\nfollowing response: \n\n {\n \"error\": {\n \"code\": 400,\n \"message\": \"There was a problem with the request.\",\n \"status\": \"INVALID_ARGUMENT\",\n \"details\": [\n {\n \"@type\": \"type.googleapis.com/google.rpc.ErrorInfo\",\n \"reason\": \"INVALID_ARGUMENT\",\n \"domain\": \"datamanager.googleapis.com\"\n },\n {\n \"@type\": \"type.googleapis.com/google.rpc.BadRequest\",\n \"fieldViolations\": [\n {\n \"field\": \"audience_members.audience_members[0]\",\n \"reason\": \"INVALID_SHA256_FORMAT\"\n }\n ]\n }\n ]\n }\n }\n\nNext steps\n----------\n\n- [Configure](/data-manager/api/get-started/set-up-access) authentication and setup your environment with a client library.\n- Learn about the [formatting, hashing, and encoding requirements](/data-manager/api/get-started/formatting) for each type of data.\n- Learn how to [encrypt user data](/data-manager/api/get-started/encryption).\n- Learn about [best practices](/data-manager/api/get-started/best-practices).\n- Learn about [limits and quotas](/data-manager/api/limits)."]]