HTTP200OK{"results":[{"apns_token":"368dde283db539abc4a6419b1795b6131194703b816e4f624ffa12","status":"OK","registration_token":"nKctODamlM4:CKrh_PC8kIb7O...clJONHoA"},{"apns_token":"76b39c2b2ceaadee8400b8868c2f45325ab9831c1998ed70859d86","status":"Internal Server Error"},]}
錯誤回應
呼叫 Instance ID 伺服器 API 時,會傳回下列 HTTP 錯誤代碼:
HTTP status 400 (Bad request) - 缺少要求參數或參數無效。
請查看錯誤訊息瞭解詳細資訊。
HTTP status 401 (Unauthorized) - 授權標頭無效。
HTTP status 403 (Forbidden) - 授權標頭與 authorizedEntity 不符。
HTTP status 404 (Not found) - HTTP 路徑無效或找不到 IID 權杖。請查看錯誤訊息瞭解詳細資訊。
HTTP status 503 (Service unavailable) - 服務無法使用。以指數輪詢方式重試要求。
[[["容易理解","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-09-04 (世界標準時間)。"],[[["\u003cp\u003eThe Instance ID service allows server-side management of app instances, including retrieving information, creating relationship maps, and managing APNs tokens.\u003c/p\u003e\n"],["\u003cp\u003eYou can get information about an app instance, such as its package name, authorized project ID, application version, and platform, by calling the Instance ID service with the app instance's token.\u003c/p\u003e\n"],["\u003cp\u003eRelationship maps, like subscribing an app instance to an FCM topic, can be created and managed individually or in bulk using the Instance ID service.\u003c/p\u003e\n"],["\u003cp\u003eExisting iOS APNs tokens can be bulk imported to Firebase Cloud Messaging and mapped to valid registration tokens using the \u003ccode\u003ebatchImport\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThe Instance ID server API returns standard HTTP error codes for issues like bad requests, unauthorized access, forbidden actions, not found resources, and service unavailability.\u003c/p\u003e\n"]]],[],null,["# Server Reference\n\nServer implementation is optional. Use the Instance ID service if you want\nto perform these operations:\n\n- [Get information about app instances](/instance-id/reference/server#get_information_about_app_instances). Verify app tokens or get more information about the app instance that created the token.\n- [Create relationship maps for app instances](/instance-id/reference/server#create_relationship_maps_for_app_instances). Create relationships between app instances and entities.\n- [Create registration tokens for APNs tokens](/instance-id/reference/server#create_registration_tokens_for_apns_tokens). This API lets you bulk import existing APNs tokens, mapping them to valid registration tokens for FCM.\n\nGet information about app instances\n-----------------------------------\n\nTo get information about an app instance, call the Instance ID service at\nthis endpoint, providing the app instance's token as shown: \n\n https://iid.googleapis.com/iid/info/IID_TOKEN\n\n### Parameters\n\n- `Authorization: Bearer \u003caccess_token\u003e`. Set this parameter in the header. Add a short-lived OAuth2 token as the value of the `Authorization` header. For more information on obtaining this token, see [Provide credentials manually](https://firebase.google.com/docs/cloud-messaging/auth-server#provide-credentials-manually).\n- `access_token_auth: true`. Set this parameter in the header.\n- \\[optional\\] boolean `details`: set this query parameter to `true` to get FCM topic subscription information (if any) associated with this token. When not specified, defaults to `false`.\n\n### Results\n\nOn success the call returns HTTP status 200 and a JSON object containing:\n\n- `application` - package name associated with the token.\n- `authorizedEntity` - projectId authorized to send to the token.\n- `applicationVersion` - version of the application.\n- `platform` - returns `ANDROID`, `IOS`, or `CHROME` to indicate the device platform to which the token belongs.\n\nIf the `details` flag is set:\n\n- `rel` - relations associated with the token. For example, a list of topic subscriptions.\n\n### Example `GET` request\n\n https://iid.googleapis.com/iid/info/nKctODamlM4:CKrh_PC8kIb7O...clJONHoA\n Content-Type:application/json\n Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA\n access_token_auth: true\n\nExample result\n--------------\n\n HTTP 200 OK\n {\n \"application\":\"com.iid.example\",\n \"authorizedEntity\":\"123456782354\",\n \"platform\":\"Android\",\n \"rel\":{\n \"topics\":{\n \"topicname1\":{\"addDate\":\"2015-07-30\"},\n \"topicname2\":{\"addDate\":\"2015-07-30\"},\n \"topicname3\":{\"addDate\":\"2015-07-30\"},\n \"topicname4\":{\"addDate\":\"2015-07-30\"}\n }\n }\n }\n\nCreate relationship maps for app instances\n------------------------------------------\n\nThe Instance ID API lets you create relationship maps for app instances.\nFor example, you can map a registration token to an FCM topic,\nsubscribing the app instance to the topic. The API provides methods for creating\nsuch relationships both individually, and in bulk.\n\n### Create a relation mapping for an app instance\n\nGiven a registration token and a supported relationship, you can create\na mapping. For example, you can subscribe an app instance to an FCM topic\nby calling the Instance ID service at\nthis endpoint, providing the app instance's token as shown: \n\n https://iid.googleapis.com/iid/v1/IID_TOKEN/rel/topics/TOPIC_NAME\n\n#### Parameters\n\n- `Authorization: Bearer \u003caccess_token\u003e`. Set this parameter in the header. Add a short-lived OAuth2 token as the value of the `Authorization` header. For more information on obtaining this token, see [Provide credentials manually](https://firebase.google.com/docs/cloud-messaging/auth-server#provide-credentials-manually).\n- `access_token_auth: true`. Set this parameter in the header.\n\n#### Results\n\nOn success the call returns HTTP status 200.\n\n#### Example `POST` request\n\n https://iid.googleapis.com/iid/v1/nKctODamlM4:CKrh_PC8kIb7O...clJONHoA/rel/topics/movies\n Content-Type:application/json\n Content-Length: 0\n Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA\n access_token_auth: true\n\n#### Example result\n\n HTTP 200 OK\n {}\n\n### Manage relationship maps for multiple app instances\n\nUsing the Instance ID service's batch methods, you can perform batch\nmanagement of app instances. For example, you can perform bulk\naddition or removal of app instances to an FCM topic.\nTo update up to 1000 app instances per API call, call the Instance ID\nservice at this endpoint, providing the app instance tokens in the JSON body: \n\n https://iid.googleapis.com/iid/v1:batchAdd\n\n https://iid.googleapis.com/iid/v1:batchRemove\n\n#### Parameters\n\n- `Authorization: Bearer \u003caccess_token\u003e`. Set this parameter in the header. Add a short-lived OAuth2 token as the value of the `Authorization` header. For more information on obtaining this token, see [Provide credentials manually](https://firebase.google.com/docs/cloud-messaging/auth-server#provide-credentials-manually).\n- `access_token_auth: true`. Set this parameter in the header.\n- `to` : The topic name.\n- `registration_tokens` : The array of IID tokens for the app instances you want to add or remove.\n\n#### Results\n\nOn success the call returns HTTP status 200. Empty results indicate successful\nsubscription for the token. For failed subscriptions, the result contains one\nof these error codes:\n\n- NOT_FOUND --- The registration token has been deleted or the app has been uninstalled.\n- INVALID_ARGUMENT --- The registration token provided is not valid for the Sender ID.\n- INTERNAL --- The backend server failed for unknown reasons. Retry the request.\n- TOO_MANY_TOPICS --- Excessive number of topics per app instance.\n- RESOURCE_EXHAUSTED --- Too many subscription or unsubscription requests in a short period of time. Retry with exponential backoff.\n\n#### Example `POST` request\n\n https://iid.googleapis.com/iid/v1:batchAdd\n Content-Type:application/json\n Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA\n access_token_auth: true\n {\n \"to\": \"/topics/movies\",\n \"registration_tokens\": [\"nKctODamlM4:CKrh_PC8kIb7O...\", \"1uoasi24:9jsjwuw...\", \"798aywu:cba420...\"],\n }\n\n#### Example result\n\n HTTP 200 OK\n {\n \"results\":[\n {},\n {\"error\":\"NOT_FOUND\"},\n {},\n ]\n }\n\nCreate registration tokens for APNs tokens\n------------------------------------------\n\nUsing the Instance ID service's `batchImport` method, you can bulk import\nexisting iOS APNs tokens to Firebase Cloud Messaging, mapping them\nto valid registration tokens. Call the Instance ID service at\nthis endpoint, providing a list of APNs tokens in the JSON body: \n\n https://iid.googleapis.com/iid/v1:batchImport\n\nThe response body contains an array of Instance ID registration tokens ready\nto be used for sending FCM messages to the corresponding APNs device token.\n| **Note:** The list of APNs tokens in each request cannot exceed 100.\n\n### Parameters\n\n- `Authorization: Bearer \u003caccess_token\u003e`. Set this parameter in the header. Add a short-lived OAuth2 token as the value of the `Authorization` header. For more information on obtaining this token, see [Provide credentials manually](https://firebase.google.com/docs/cloud-messaging/auth-server#provide-credentials-manually).\n- `access_token_auth: true`. Set this parameter in the header.\n- `application` : Bundle id of the app.\n- `sandbox` : Boolean to indicate sandbox environment (TRUE) or production (FALSE)\n- `apns_tokens` : The array of APNs tokens for the app instances you want to add or remove. Maximum 100 tokens per request.\n\n### Results\n\nOn success the call returns HTTP status 200 and a JSON result body. For each\nAPNs token provided in the request, the results list includes:\n\n- The APNs token.\n- Status. Either OK, or an error message describing the failure.\n- For successful results, the registration token that FCM maps to the APNs token.\n\n### Example `POST` request\n\n https://iid.googleapis.com/iid/v1:batchImport\n Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA\n access_token_auth:true\n {\n \"application\": \"com.google.FCMTestApp\",\n \"sandbox\":false,\n \"apns_tokens\":[\n \"368dde283db539abc4a6419b1795b6131194703b816e4f624ffa12\",\n \"76b39c2b2ceaadee8400b8868c2f45325ab9831c1998ed70859d86\"\n ]\n }\n\n### Example result\n\n HTTP 200 OK\n {\n \"results\":[\n {\n \"apns_token\": \"368dde283db539abc4a6419b1795b6131194703b816e4f624ffa12\",\n \"status\": \"OK\",\n \"registration_token\":\"nKctODamlM4:CKrh_PC8kIb7O...clJONHoA\"\n },\n {\n \"apns_token\": \"76b39c2b2ceaadee8400b8868c2f45325ab9831c1998ed70859d86\",\n \"status\":\"Internal Server Error\"\n },\n ]\n }\n\nError responses\n---------------\n\nCalls to the Instance ID server API return\nthe following HTTP error codes:\n\n- `HTTP status 400 (Bad request)` - request parameters are missing or invalid. Check error messages for detailed information.\n- `HTTP status 401 (Unauthorized)` - authorization header is invalid.\n- `HTTP status 403 (Forbidden)` - authorization header doesn't match the `authorizedEntity`.\n- `HTTP status 404 (Not found)` - Invalid HTTP path or IID token not found. Check error messages for detailed information.\n- `HTTP status 503 (Service unavailable)` - service is unavailable. Retry the request with exponential backoff."]]