Get Started with OneLogin APIs

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:

  1. Log in to your OneLogin Admin portal
  2. Navigate to Developers > API Credentials
  3. Click New Credential
  4. Set the following:
    • Name: My First API Credential
    • Scope: Choose the appropriate scope (e.g., “Manage All”)
  5. Click Save
  6. 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:

Users API

Create, update, and manage users programmatically

View Documentation

Apps API

Manage applications and connectors

View Documentation

Roles API

Create and assign roles to users

View Documentation

Error Handling

If you encounter errors, check the HTTP status code and response message:

Status CodeMeaning
200Success
400Bad Request - Check your request syntax
401Unauthorized - Check your access token
403Forbidden - Insufficient permissions
404Not Found - Resource doesn’t exist
422Unprocessable Entity - Invalid data
500Server 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 limit
    • X-RateLimit-Remaining: Requests remaining
    • X-RateLimit-Reset: When the limit resets (Unix timestamp)

Next Steps

Need Help?