API methods

GetReader

GetReader allows for a publisher to validate if one of their readers with a known PPID has linked their subscription to Google. Using a GET request, the publisher queries for a PPID belonging to a particular Publication ID.

Request

//GET /v1/publications/dailybugle.com/readers/6789

Response

The endpoint will return either a 200 with a JSON body containing the created_time of the linked subscription, or an error if no PPID is found for the publication. See the errors section for more information.

{
  "name": "publications/gtech-demo.appspot.com/readers/81112",  
  "create_time": "2022-04-19T04:53:40+00:00"
}

GetReaderEntitlements

GetReaderEntitlements allows a publisher to query for entitlements for a PPID that the publisher previously provided. Using a GET request, the publisher requests the entitlements by providing a PPID and Publication ID.

Request

//GET /v1/publications/dailybugle.com/readers/6789/entitlements

Response

For a successful request, the return format is identical to the format used to store entitlements with the UpdateReaderEntitlements PATCH request.

{ 
  "name": "publications/dailybugle.com/readers/6789/entitlements",
  "entitlements": [  
      {
        "product_id": "dailybugle.com:basic",
        "subscription_token": "dnabhdufbwinkjanvejskenfw",
        "detail": "This is our basic plan",
        "expire_time": "2022-08-19T04:53:40+00:00"
      },
      {
        "product_id": "dailybugle.com:premium",
        "subscription_token": "wfwhddgdgnkhngfw",
        "detail": "This is our premium plan",
        "expire_time": "2022-07-19T04:53:40+00:00"
      },
      {
        "product_id": "dailybugle.com:deluxe",
        "subscription_token": "fefcbwinkjanvejfefw",
        "detail": "This is our deluxe plan",
        "expire_time": "2022-08-20T04:53:40+00:00"
      }
  ]
}

For users who do not have entitlements, but do have a linked PPID (for example, an entitlement that has expired and been purged), an entitlements request will return an empty entitlements array as part of the standard entitlements object.

{ 
  "name": "publications/dailybugle.com/readers/6789/entitlements",
  "createTime": "2023-02-07T17:38:57.425577Z"
}

UpdateReaderEntitlements

UpdateReaderEntitlements is used for creating and updating entitlements for a reader, based on their PPID.

This sample payload grants the reader with PPID 6789 entitlements to three Product IDs for The Daily Bugle: dailybugle.com:basic, dailybugle.com:premium, and dailybugle.com:deluxe. When reader 6789 subsequently uses Google surfaces for Search and Discover, the “From your subscriptions” list will feature any relevant results from dailybugle.com articles tagged with any of these Product IDs.

Request

//PATCH /v1/publications/dailybugle.com/readers/6789/entitlements

{
  "name": "publications/dailybugle.com/readers/6789/entitlements",
  "entitlements": [  
      {
        "product_id": "dailybugle.com:basic",
        "subscription_token": "dnabhdufbwinkjanvejskenfw",
        "detail": "This is our basic plan",
        "expire_time": "2022-08-19T04:53:40+00:00"
      },
      {
        "product_id": "dailybugle.com:premium",
        "subscription_token": "wfwhddgdgnkhngfw",
        "detail": "This is our premium plan",
        "expire_time": "2022-07-19T04:53:40+00:00"
      },
      {
        "product_id": "dailybugle.com:deluxe",
        "subscription_token": "fefcbwinkjanvejfefw",
        "detail": "This is our deluxe plan",
        "expire_time": "2022-08-20T04:53:40+00:00"
      }
  ]
}

Response

Upon a successful PATCH operation, the saved entitlements object will be returned, in the same format as GetReaderEntitlements.

DeleteReader

DeleteReader allows for a publisher to manually delete a reader’s linked subscription. Using a DELETE request, the publisher submits a PPID for a Publication ID to be deleted.

Request

//DELETE /v1/publications/dailybugle.com/readers/6789

Response

A successful delete returns a 200 with an empty JSON object {}.

{}