Welcome to the OneLogin API! This guide will walk you through the basics of authenticating and making your first API call.
Prerequisites
Before you begin, make sure you have:
- A OneLogin account with administrator access
- Access to the OneLogin Admin portal
- Basic knowledge of REST APIs and HTTP requests
Step 1: Generate API Credentials
To use the OneLogin API, you first need to generate API credentials:
- Log in to your OneLogin Admin portal
- Navigate to Developers > API Credentials
- Click New Credential
- Set the following:
- Name: My First API Credential
- Scope: Choose the appropriate scope (e.g., “Manage All”)
- Click Save
- Copy the Client ID and Client Secret - you’ll need these for authentication
Important: Store your Client Secret securely. It will only be displayed once!
Step 2: Generate an Access Token
All API requests require an access token. Use your Client ID and Client Secret to generate one:
curl -X POST https://api.us.onelogin.com/auth/oauth2/v2/token \
-H "Content-Type: application/json" \
-d '{
"grant_type": "client_credentials"
}' \
-u "your_client_id:your_client_secret"Response:
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"token_type": "bearer",
"expires_in": 36000
}Copy the access_token value - you’ll use it in subsequent API calls.
Step 3: Make Your First API Call
Now that you have an access token, let’s retrieve a list of users from your OneLogin account:
curl -X GET https://api.us.onelogin.com/api/2/users \
-H "Authorization: bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json"Response:
[
{
"id": 1234567,
"username": "john.doe@example.com",
"email": "john.doe@example.com",
"firstname": "John",
"lastname": "Doe",
"status": 1
}
]Congratulations! You’ve successfully made your first OneLogin API call! 🎉
Step 4: Explore the API
Now that you’ve completed the basics, explore what else you can do:
Error Handling
If you encounter errors, check the HTTP status code and response message:
| Status Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad Request - Check your request syntax |
| 401 | Unauthorized - Check your access token |
| 403 | Forbidden - Insufficient permissions |
| 404 | Not Found - Resource doesn’t exist |
| 422 | Unprocessable Entity - Invalid data |
| 500 | Server Error - Contact support |
Rate Limits
The OneLogin API has rate limits to ensure fair usage:
- 5,000 requests per hour per IP address
- Rate limit headers are included in all responses:
X-RateLimit-Limit: Your rate limitX-RateLimit-Remaining: Requests remainingX-RateLimit-Reset: When the limit resets (Unix timestamp)
Next Steps
Explore our comprehensive documentation to learn more:
- SAML - Implement enterprise SSO with SAML 2.0
- OpenID Connect - Modern authentication with OIDC
- SCIM - Automated user provisioning
- Smart Hooks - Customize authentication workflows
- Mobile SDKs - Native mobile integration
- API Authorization - Secure your APIs with OAuth 2.0
Need Help?
Have a Question?
Found a problem or a bug? Submit a support ticket (opens in new tab).
Looking for walkthroughs or how-to guides? Check out our Knowledge Base (opens in new tab).
Have a product idea or request? Share it in our Ideas Portal (opens in new tab).
Have a Question?
Found a problem or a bug? Submit a support ticket.
Looking for walkthroughs or how-to guides? Check out our Knowledge Base.
Have a product idea or request? Share it in our Ideas Portal.