Code Samples for the Chrome Management Enrollment Tokens API

Visit Chrome Management Enrollment Tokens API for an overview of API features.

All the requests shown in this page use the following variables:

  • $TOKEN - OAuth 2.0 token
  • $CUSTOMER - ID of the customer or literal my_customer

Create an Enrollment Token

To create a new enrollment token for a browser device, use the /enrollmentTokens endpoint with HTTP POST. You can optionally specify an enrollmentTokenId query parameter to assign a custom token ID.

Request

  curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enrollmentTokens" \
  -d '{
    "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER",
    "orgUnitId": "03ph8a2z3v"
  }'

Response

{
  "name": "customers/<customerId>/enrollmentTokens/<tokenPermanentId>",
  "tokenPermanentId": "<tokenPermanentId>",
  "token": "<tokenValue>",
  "customerId": "<customerId>",
  "orgUnitId": "03ph8a2z3v",
  "state": "ENROLLMENT_TOKEN_STATE_ACTIVE",
  "createTime": "2024-04-23T22:00:00.000Z",
  "creatorId": "user@example.com",
  "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER"
}

Retrieve an Enrollment Token

To retrieve a single enrollment token, use the /enrollmentTokens/{token_permanent_id} endpoint with HTTP GET.

Request

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enrollmentTokens/<tokenPermanentId>"

Response

{
  "name": "customers/<customerId>/enrollmentTokens/<tokenPermanentId>",
  "tokenPermanentId": "<tokenPermanentId>",
  "token": "<tokenValue>",
  "customerId": "<customerId>",
  "orgUnitId": "03ph8a2z3v",
  "state": "ENROLLMENT_TOKEN_STATE_ACTIVE",
  "createTime": "2024-04-23T22:00:00.000Z",
  "creatorId": "user@example.com",
  "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER"
}

List Enrollment Tokens

To list enrollment tokens, use the /enrollmentTokens endpoint with HTTP GET. You can control pagination using pageSize (maximum and default 100) and pageToken parameters. Specify a filter to narrow down results.

Example filter queries

# Filter by token state
filter=token_state=ACTIVE

# Filter by Organizational Unit path
filter=org_unit_path=/Marketing

# Filter by Organizational Unit path containing spaces
filter=org_unit_path='/Browser Management'

# Filter by Organizational Unit ID
filter=org_unit_id=03ph8a2z3v

# Filter by token state, Organizational Unit path, and device type
filter=token_state=ACTIVE AND org_unit_path=/Marketing AND device_type=CHROME_BROWSER

Request

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enrollmentTokens?pageSize=2&filter=token_state=ACTIVE"

Response

{
  "enrollmentTokens": [
    {
      "name": "customers/<customerId>/enrollmentTokens/<tokenPermanentId1>",
      "tokenPermanentId": "<tokenPermanentId1>",
      "token": "<tokenValue1>",
      "customerId": "<customerId>",
      "orgUnitId": "03ph8a2z3v",
      "state": "ENROLLMENT_TOKEN_STATE_ACTIVE",
      "createTime": "2024-04-23T22:00:00.000Z",
      "creatorId": "user1@example.com",
      "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER"
    },
    {
      "name": "customers/<customerId>/enrollmentTokens/<tokenPermanentId2>",
      "tokenPermanentId": "<tokenPermanentId2>",
      "token": "<tokenValue2>",
      "customerId": "<customerId>",
      "orgUnitId": "03ph8a2z3v",
      "state": "ENROLLMENT_TOKEN_STATE_ACTIVE",
      "createTime": "2024-04-23T21:30:00.000Z",
      "creatorId": "user2@example.com",
      "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER"
    }
  ],
  "nextPageToken": "<nextPageToken>"
}

Revoke an Enrollment Token

To revoke an enrollment token, use the /enrollmentTokens/{token_permanent_id}:revoke endpoint with HTTP POST.

Request

  curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enrollmentTokens/<tokenPermanentId>:revoke" \
  -d '{}'

Response

{
  "name": "customers/<customerId>/enrollmentTokens/<tokenPermanentId>",
  "tokenPermanentId": "<tokenPermanentId>",
  "token": "<tokenValue>",
  "customerId": "<customerId>",
  "orgUnitId": "03ph8a2z3v",
  "state": "ENROLLMENT_TOKEN_STATE_REVOKED",
  "createTime": "2024-04-23T22:00:00.000Z",
  "revokeTime": "2024-04-24T10:15:00.000Z",
  "creatorId": "user@example.com",
  "revokerId": "admin@example.com",
  "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER"
}