Homeland Security’s Trusted Travelers API and PowerShell – Getting a Better Global Entry Interview Using PowerShell
Table of Contents
I am flying out of the country in February and I recently decided to enroll in TSA Pre-Check as well as Global Entry. With Global Entry you automatically get TSA Pre-Check, but Global Entry works for international flights as well and is only a few extra dollars more than TSA Pre-Check.
Once you get your application approved, the next step is to schedule an interview, which is essentially a 15-minute appointment where a customs officer ask you a few questions (like where you are going, when and why) and then take bio-metrics (fingerprint scans). The interview must be done in person at one of relatively few U.S. Customs and Border Protection locations, like an international airport, and you must schedule your interview within 30 days of getting your application approved (otherwise you have to resubmit your entire application). You are allowed to drop and pick up appointments if you find another one that is sooner, but the moment you drop an appointment anyone can grab it immediately. When I first looked for an interview around Chicago (Illinois, Iowa, Wisconsin, and Indiana) the soonest appointment was at O’Hare airport in mid-march (over 3 months from when I was looking). When there are no appointments available at your location the website doesn’t give much information at all:
And if there is an appointment available it will only show you the first available and not all options:
So, I booked my appointment several months out in March and figured I would check several times a day to see if someone dropped a sooner appointment. Then I was interested to see if anybody found a way to automate and notify of a better appointment which lead me to this python project (which worked great but I could only find a way to monitor one site at a time). But it lead me to the discovery of the Trusted Travelers API by Homeland Security which the website uses itself to get interview openings.
Trusted Traveler Program API
The Trusted Traveler Program (TTP) API is a undocumented, public API that the Global Entry interview website uses to know which sites are available for Global Entry and when interview appointments are available. Responses are formatted as JSON
Playing in the API its much much MUCH quicker than going through the website because you do not need to authenticate, enter your MFA token (required), remember the browser and then manually search each site one by one.
By using Invoke-RestMethod against the endpoint
https://ttp.cbp.dhs.gov/schedulerapi/locations/?temporary=false&inviteOnly=false&operational=true&serviceName=Global%20Entry
I get Global Entry locations returned as well as all of the locations properties.
PSGlobalEntry PowerShell Module
So in the end I was able to create a PowerShell module that achieved the following:
- Show Global Entry locations and all properties
- Show Global Entry locations in 1 or more state(s)
- Get available Global Entry interview appointments in 1 or more state(s)
- Filter the amount of available appointments shown per interview site
- Parse available interview appointments in between date ranges
- Get available Global Entry interview appointments based on site(s) ID
By allowing me to query sites in multiple states, as well as between specific date ranges, I could know when a earlier appointment opened up for different locations that were too far from me. In the end I was able to grab a appointment that was closer and about 3 months sooner (it was 2 days later from when it became available).
If you want to just download the module and start playing with it you can download it from the PowerShell gallery
Install-Module PSGlobalEntry
Get-GELocation
The function Get-GELocation will get all locations per state or states. You can specify states by the abbreviation or full name. Each Global Entry site will return the following 36 properties for that site:
Once you secure an interview appointment this function is a great way to get the address, phone and directions as not all offices are attached to airports.
-State
The function only has one parameter, State. Which will show you all Global Entry interview locations for 1 or more states. You can specify the state by the abbreviation or full name.
Get-GESchedule
The function Get-GESchedule will return open interview appointments in all sites in one or more state. You must supply a value for the parameter State or ID. You can specify the state by either the abbreviation or full name.
-State
The State parameter will show you all available interviews for all sites in 1 or more states. You can specify the state by the abbreviation or full name.
-ID
The ID parameter is the location ID which can be found by either running Get-GELocation or Get-GESchedule -State and viewing the ID property for the interview location.
-ResultsPerSite
The ResultsPerSite parameter filters the available appointments shown per site. By entering -ResultsPerSite 2, you will only be shown a max of 2 appointments per site.
-StartDate
The StartDate Parameter specifies when it should begin looking for available appointments. It will return the max amount the API will allow if you do not specify an end-date by using the EndDate param. StartDate will start will a time of 00:00:00.
-EndDate
The EndDate parameter specifies the last date it should return results for. If you specify a beginning date by using the StartDate parameter it will return all results in between the 2 dates. When using the EndDate parameter it will return all appointment until 23:59:59.
Source / Download
The module is published on PowerShell Gallery and can be downloaded by running
Install-Module PSGlobalEntry
As always, the code is completely open-source and anyone can review and improve it on GitHub!
My name is Bradley Wyatt; I am a 4x Microsoft Most Valuable Professional in Cloud and Datacenter Management. I have given talks at many different conferences, user groups, and companies throughout the United States ranging from PowerShell to DevOps Security best practices and am the 2022 North American Outstanding Contribution to the Microsoft Community winner.
2 thoughts on “Homeland Security’s Trusted Travelers API and PowerShell – Getting a Better Global Entry Interview Using PowerShell”
AMAZING. Thanks so much!!!