Skip to main content

subscribers

Creates, updates, deletes, gets or lists a subscribers resource.

Overview

Namesubscribers
TypeResource
Idgoogle.health.subscribers

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringIdentifier. The resource name of the Subscriber. Format: projects/{project}/subscribers/{subscriber} The {project} ID is a Google Cloud Project ID or Project Number. The {subscriber} ID is user-settable (4-36 characters, matching /a-z/) if provided during creation, or system-generated otherwise (e.g., a UUID). Example (User-settable subscriber ID): projects/my-project/subscribers/my-sub-123 Example (System-generated subscriber ID): projects/my-project/subscribers/a1b2c3d4-e5f6-7890-1234-567890abcdef
createTimestring (google-datetime)Output only. The time at which the subscriber was created.
endpointAuthorizationobjectRequired. Authorization mechanism for a subscriber endpoint. This is required to ensure the endpoint can be verified. (id: EndpointAuthorization)
endpointUristringRequired. The full HTTPS URI where update notifications will be sent. The URI must be a valid URL and use HTTPS as the scheme. This endpoint will be verified during CreateSubscriber and UpdateSubscriber calls. See RPC documentation for verification details.
statestringOutput only. The state of the subscriber. (STATE_UNSPECIFIED, UNVERIFIED, ACTIVE, INACTIVE)
subscriberConfigsarrayOptional. Configuration for the subscriber.
updateTimestring (google-datetime)Output only. The time at which the subscriber was last updated.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectprojectsIdpageSize, pageTokenLists all subscribers registered within the owned Google Cloud Project.
createinsertprojectsIdsubscriberIdRegisters a new subscriber endpoint to receive notifications. A subscriber represents an application or service that wishes to receive data change notifications for users who have granted consent. Endpoint Verification: For a subscriber to be successfully created, the provided endpoint_uri must be a valid HTTPS endpoint and must pass an automated verification check. The backend will send two HTTP POST requests to the endpoint_uri: 1. Verification with Authorization: * Headers: Includes Content-Type: application/json and Authorization (with the exact value from CreateSubscriberPayload.endpoint_authorization.secret). * Body: {"type": "verification"} * Expected Response: HTTP 201 Created. 2. Verification without Authorization: * Headers: Includes Content-Type: application/json. The Authorization header is OMITTED. * Body: {"type": "verification"} * Expected Response: HTTP 401 Unauthorized or 403 Forbidden. Both tests must pass for the subscriber creation to succeed. If verification fails, the operation will not be completed and an error will be returned. This process ensures the endpoint is reachable and correctly validates the Authorization header.
patchupdateprojectsId, subscribersIdupdateMaskUpdates the configuration of an existing subscriber, such as the endpoint URI or the data types it's interested in. Endpoint Verification: If the endpoint_uri or endpoint_authorization field is included in the update_mask, the backend will re-verify the endpoint. The verification process is the same as described in CreateSubscriber: 1. Verification with Authorization: POST to the new or existing endpoint_uri with the new or existing Authorization secret. Expects HTTP 201 Created. 2. Verification without Authorization: POST to the endpoint_uri without the Authorization header. Expects HTTP 401 Unauthorized or 403 Forbidden. Both tests must pass using the potentially updated values for the subscriber update to succeed. If verification fails, the update will not be applied, and an error will be returned.
deletedeleteprojectsId, subscribersIdforceDeletes a subscriber registration. This will stop all notifications to the subscriber's endpoint.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
projectsIdstring
subscribersIdstring
forceboolean
pageSizeinteger (int32)
pageTokenstring
subscriberIdstring
updateMaskstring (google-fieldmask)

SELECT examples

Lists all subscribers registered within the owned Google Cloud Project.

SELECT
name,
createTime,
endpointAuthorization,
endpointUri,
state,
subscriberConfigs,
updateTime
FROM google.health.subscribers
WHERE projectsId = '{{ projectsId }}' -- required
AND pageSize = '{{ pageSize }}'
AND pageToken = '{{ pageToken }}'
;

INSERT examples

Registers a new subscriber endpoint to receive notifications. A subscriber represents an application or service that wishes to receive data change notifications for users who have granted consent. Endpoint Verification: For a subscriber to be successfully created, the provided endpoint_uri must be a valid HTTPS endpoint and must pass an automated verification check. The backend will send two HTTP POST requests to the endpoint_uri: 1. Verification with Authorization: * Headers: Includes Content-Type: application/json and Authorization (with the exact value from CreateSubscriberPayload.endpoint_authorization.secret). * Body: {"type": "verification"} * Expected Response: HTTP 201 Created. 2. Verification without Authorization: * Headers: Includes Content-Type: application/json. The Authorization header is OMITTED. * Body: {"type": "verification"} * Expected Response: HTTP 401 Unauthorized or 403 Forbidden. Both tests must pass for the subscriber creation to succeed. If verification fails, the operation will not be completed and an error will be returned. This process ensures the endpoint is reachable and correctly validates the Authorization header.

INSERT INTO google.health.subscribers (
data__endpointAuthorization,
data__endpointUri,
data__subscriberConfigs,
projectsId,
subscriberId
)
SELECT
'{{ endpointAuthorization }}',
'{{ endpointUri }}',
'{{ subscriberConfigs }}',
'{{ projectsId }}',
'{{ subscriberId }}'
RETURNING
name,
done,
error,
metadata,
response
;

UPDATE examples

Updates the configuration of an existing subscriber, such as the endpoint URI or the data types it's interested in. Endpoint Verification: If the endpoint_uri or endpoint_authorization field is included in the update_mask, the backend will re-verify the endpoint. The verification process is the same as described in CreateSubscriber: 1. Verification with Authorization: POST to the new or existing endpoint_uri with the new or existing Authorization secret. Expects HTTP 201 Created. 2. Verification without Authorization: POST to the endpoint_uri without the Authorization header. Expects HTTP 401 Unauthorized or 403 Forbidden. Both tests must pass using the potentially updated values for the subscriber update to succeed. If verification fails, the update will not be applied, and an error will be returned.

UPDATE google.health.subscribers
SET
data__endpointAuthorization = '{{ endpointAuthorization }}',
data__name = '{{ name }}',
data__endpointUri = '{{ endpointUri }}',
data__subscriberConfigs = '{{ subscriberConfigs }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND subscribersId = '{{ subscribersId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
done,
error,
metadata,
response;

DELETE examples

Deletes a subscriber registration. This will stop all notifications to the subscriber's endpoint.

DELETE FROM google.health.subscribers
WHERE projectsId = '{{ projectsId }}' --required
AND subscribersId = '{{ subscribersId }}' --required
AND force = '{{ force }}'
;