Authentication
All requests to the Udacity Public API must be authenticated using an API token. Use client credentials to generate short-lived tokens programmatically.
Client credentials
For backend services, data pipelines, and LMS integrations, use a client credential pair to programmatically generate short-lived tokens.
- A company admin creates a client credential in the Management Portal, yielding a
clientIdandclientSecret. - Your service calls
generateTokenon the Tokens API to exchange the credential pair for a short-lived token. - Use the returned token in the
Authorizationheader for all data API requests. Tokens expire after 1 hour.
If your credential covers multiple companies, include "companyId" in the input to scope the token.
See Generate API Credentials for instructions.
curl -X POST https://api.udacity.com/api/public/api/v1/tokens/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "mutation($input: GenerateTokenInput!) { generateToken(input: $input) { unredactedToken expiresIn } }",
"variables": {
"input": {
"clientId": "udcl_YOUR_CLIENT_ID",
"clientSecret": "udcs_YOUR_CLIENT_SECRET"
}
}
}'Using a token
Include your token in the Authorization header using the Token scheme (not Bearer).
Your bearer token. Store it securely — it grants full API access.
Token lifetime — 3600 by default (1 hour).
Authorization: Token YOUR_TOKENcurl -X POST https://api.udacity.com/api/public/api/v1/catalog/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Token YOUR_TOKEN" \
-d '{"query": "{ catalog { companyId programs { key title } } }"}'const response = await fetch(
'https://api.udacity.com/api/public/api/v1/catalog/graphql',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Token YOUR_TOKEN',
},
body: JSON.stringify({
query: `{
catalog {
companyId
programs { key title type }
assessments { id title }
learningPlans { id title }
}
}`,
}),
}
);
const data = await response.json();
console.log(data);Token scopes
A token must carry scopes that grant access to specific API domains. If your token lacks the required scope, the API returns a 403 Forbidden error.
Tokens generated via client credentials automatically include a COMPANY scope for the target company. No manual scope configuration is needed.
Error responses
Missing, invalid, or expired token.
Token is valid but lacks the required scope.
Rate limit exceeded — see Rate Limits. The generateToken endpoint has an additional per-credential limit of 50 requests/minute.
{
"errors": [{
"message": "not authorized",
"extensions": { "code": "UNAUTHORIZED" }
}]
}Security recommendations
- Never hardcode credentials or tokens in source code. Use environment variables or a secrets manager.
- Prefer client credentials for production. Tokens are short-lived, credentials are company-owned, and rotation is programmatic.
- Refresh tokens proactively. Check
expiresInand schedule a refresh before expiry. - Use
revokeExisting: truewhen rotating. This atomically revokes overlapping credentials. - Revoke credentials you no longer use. Tokens from a revoked credential continue working until they expire.
See Best Practices for more.