Authenticating with the Robot API
To begin, Polymath must have issued you a:
- Client ID
- Client Secret
- One or more Device IDs
If you do not have these, please reach out to your Polymath contact or email [email protected].
Generate a Bearer Token
Before calling the Robot API, you'll need to generate a Bearer Token. First set environment variables:
export CLIENT_ID={your_client_id}
export CLIENT_SECRET={your_client_secret}
export DEVICE_ID={your_device_id}
Then call the auth endpoint to retrieve your bearer token:
curl --request POST \
--url https://polyglot.polymathrobotics.dev/oauth/token \
--header 'content-type: application/json' \
--data '{"client_id": "'"${CLIENT_ID}"'", "client_secret": "'"${CLIENT_SECRET}"'", "audience": "https://api.polymathrobotics.dev/", "grant_type": "client_credentials"}'
The JSON response provides the key access_token.
This is your bearer token, which you will use to authenticate for all API calls.
This example one-liner uses jq to extract the access_token to an environment variable:
export BEARER_TOKEN=$(curl --silent --request POST \
--url https://polyglot.polymathrobotics.dev/oauth/token \
--header 'content-type: application/json' \
--data '{"client_id": "'"${CLIENT_ID}"'", "client_secret": "'"${CLIENT_SECRET}"'", "audience": "https://api.polymathrobotics.dev/", "grant_type": "client_credentials"}' \
| jq -r '.access_token')
Test access
Test access to the API by listing your robots:
curl https://polyglot.polymathrobotics.dev/api/robots \
--header "authorization: Bearer $BEARER_TOKEN"
Grab one of those device IDs, and check if the robot is healthy:
curl "https://polyglot.polymathrobotics.dev/api/synapse/$DEVICE_ID/v2/health" \
--header "Authorization: Bearer $BEARER_TOKEN"