[[["容易理解","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-07-25 (世界標準時間)。"],[[["\u003cp\u003eThe Data Portability API allows you to initiate data export jobs, check their status, retry failed jobs, and manage user authorization for data access.\u003c/p\u003e\n"],["\u003cp\u003eTo export data, use \u003ccode\u003eportabilityArchive.initiate\u003c/code\u003e with appropriate resource groups and OAuth scopes, preferably making separate requests for each resource group for faster processing.\u003c/p\u003e\n"],["\u003cp\u003eYou can monitor the job status with \u003ccode\u003earchiveJobs.getPortabilityArchiveState\u003c/code\u003e, which provides download URLs upon completion and allows for checking progress periodically.\u003c/p\u003e\n"],["\u003cp\u003eIf a job fails, \u003ccode\u003earchiveJobs.retryPortabilityArchive\u003c/code\u003e can be used up to three times to retry the export without requiring a new user authorization.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eresetAuthorization\u003c/code\u003e method revokes existing OAuth scopes, enables initiating new exports for previously used resource groups, and removes access to past data archives, with automated cleanup occurring after 14 days.\u003c/p\u003e\n"]]],[],null,["# Call Data Portability API methods\n\nThe Data Portability API consists of these methods:\n\n- `portabilityArchive.initiate`\n- `archiveJobs.getPortabilityArchiveState`\n- `resetAuthorization`\n- `archiveJobs.retryPortabilityArchive`\n- `archiveJobs.cancelPortabilityArchive`\n- `accessType.check`\n\nportabilityArchive.initiate\n---------------------------\n\nYou call the [`portabilityArchive.initiate`](/data-portability/reference/rest/v1/portabilityArchive/initiate) method to start a new data\nexport job.\n\nWhen you start an export job to create a data archive, you must request the\nappropriate resource group and provide an OAuth token with the required\nscopes for that resource group. The OAuth token is used to authorize the\nrequest and to determine which user data is being exported.\n\nFor a list of all resource groups supported by a particular service, see the\n[schema reference page](/data-portability/schema-reference) for that service.\n\nFor example, if you're exporting search activity data, you call\n`InitiatePortabilityArchive(resources = [\"myactivity.search\"])`. The request\nmust have an OAuth token attached with the search OAuth scope:\n`https://www.googleapis.com/auth/dataportability.myactivity.search`.\n\nThough it is possible to include multiple resource groups in a single\n`InitiatePortabilityArchive` call, this is not recommended. You can achieve\nfaster processing by making separate `InitiatePortabilityArchive` requests for\neach resource group. Note that when you request multiple resource groups,\nthe attached OAuth token must have all the appropriate scopes attached.\n\nFor example, instead of calling\n`InitiatePortabilityArchive(resources = [\"myactivity.search\",\"myactivity.youtube\"])`\nto create a data archive for both search and YouTube activity, make these\nseparate calls:\n`InitiatePortabilityArchive(resources = [\"myactivity.search\"])`\nand `InitiatePortabilityArchive(resources = [\"myactivity.youtube\"])`.\n\nThe `InitiatePortabilityArchive` request returns a `job_id`. This job ID is used\nto retrieve the state of the data archive.\n\narchiveJobs.getPortabilityArchiveState\n--------------------------------------\n\nThe [`archiveJobs.getPortabilityArchiveState`](/data-portability/reference/rest/v1/archiveJobs/getPortabilityArchiveState) method is called to retrieve\nthe current [state](/data-portability/reference/rest/v1/archiveJobs/getPortabilityArchiveState#State) of the data archive export job. When you call\n`getPortabilityArchiveState`, you supply the `job_id`:\n`GetPortabilityArchiveState(job_id)`. You must also supply an OAuth token with\nscopes that match the resource groups used in the `initiate` request.\n\nIf the state is `COMPLETE`, signed Cloud Storage URLs are returned that you can\nuse to download the data. The signed URLs expire after six hours, and the data\nis available for 14 days.\n\nAn archive request can take several minutes, several hours, or even several days\nto complete depending on the volume of data. You can check the state of the\narchive every five to 60 minutes.\n| **Important:** You should initiate the portability archive within 24 hours of user authorization.\n\nresetAuthorization\n------------------\n\nThe [`resetAuthorization`](/data-portability/reference/rest/v1/authorization/reset) method does the following:\n\n- Revokes all user-granted OAuth scopes\n- Allows your application to call `InitiatePortabilityArchive` for a resource group that you used previously\n- Removes access to previous data archives\n\nWhen you call `resetAuthorization`, you must supply an attached OAuth token for\nthe user whose authorization you're resetting.\n| **Note:** To automate archive cleanup, an internal `ResetAuthorization` endpoint is called 14 days after the first `InitiatePortabilityArchive` call.\n\narchiveJobs.retryPortabilityArchive\n-----------------------------------\n\nThe [`archiveJobs.retryPortabilityArchive`](/data-portability/reference/rest/v1/archiveJobs/retry) method is called to retry\nfailed jobs where the [`archiveJobs.getPortabilityArchiveState`](/data-portability/reference/rest/v1/archiveJobs/getPortabilityArchiveState) method\nalready returned a [state](/data-portability/reference/rest/v1/archiveJobs/getPortabilityArchiveState#State) of `FAILED`. This may occur due to a transient\nfailure on the backend. In that case you can retry the export without obtaining\na *new* OAuth token from the user. When you call `retryPortabilityArchive` you\nsupply the `job_id` along with a valid OAuth token. The endpoint then tries to\ncreate an export for the same [resource groups](/data-portability/schema-reference) requested in the initial\n`initiatePortabilityArchive` request. If successful, this endpoint returns\na *new* `job_id` that you can use in calls to `getPortabilityArchiveState`. A\nfailed job can be retried up to three times.\n\nFor example:\n\n1. You call `InitiatePortabilityArchive(resources = [\"myactivity.search\"])`,\n and you receive `job_id: 0`.\n\n2. After calling `GetPortabilityArchiveState(0)`, you receive `JobSate: FAILED`.\n\n3. You can then call `RetryPortabilityArchive(0)` to receive `job_id: 1` for\n `resources = [\"myactivity.search\"]`.\n\n4. Then, you can continue to make calls to `GetPortabilityArchiveState(1)`.\n\narchiveJobs.cancelPortabilityArchive\n------------------------------------\n\nThe `archiveJobs.cancelPortabilityArchive` method is called to cancel an\nindividual job without revoking existing tokens when you have ongoing access\nto user data. This is useful when a job or resource is no longer needed and you\nwant to reset your job quota. The job must be `IN_PROGRESS` and have been\ncreated with time-based access to be canceled.\n\nFor example, you could cancel an in-progress, time-based job for\n`myactivity.youtube` and `youtube.public_videos` then start a new job for just\n`myactivity.youtube`.\n\naccessType.check\n----------------\n\nThe `accessType.check` method lets you check whether an OAuth token authorizes\ntime-based or one-time access before starting a job. For example you might\nintend to export a user's entire history if they grant one-time access, or just\nthe last day if they grant time-based access.\n\nThe response contains two fields: lists of one-time and time-based\ndataportability resource group ids authorized by the OAuth token used in the\nrequest. Users can't mix access types in a token grant, but you shouldn't\nnecessarily assume that behavior in the future."]]