Skip to content
Learni
View all tutorials
Outils de formation

How to Integrate the 360Learning API with Node.js in 2026

Lire en français

Introduction

360Learning is a leading LMS (Learning Management System) platform for corporate training, used by over 1,000 organizations like L'Oréal and Decathlon. Its REST API lets you automate course creation, user additions, and session management, eliminating tedious manual tasks.

Why integrate its API in 2026? With the rise of AI and automated workflows, syncing 360Learning with your HR tools (like Workday or Google Workspace) is essential for scaling training programs. This beginner tutorial guides you step by step: from Node.js setup to running full API requests.

By the end, you'll master a copy-paste Node.js script that creates a course, adds learners, and lists progress. Imagine: a cron job onboarding 1,000 employees in 5 minutes!

Prerequisites

  • A 360Learning account with admin rights (sign up at 360learning.com).
  • API key generated in Settings > Integrations > API (copy it securely).
  • Node.js 20+ installed (nodejs.org).
  • Basic JavaScript knowledge (fetch or Axios).
  • An editor like VS Code.

Initialize the Node.js Project

terminal
mkdir 360learning-api-integration
cd 360learning-api-integration
npm init -y
npm install axios dotenv
mkdir src

These commands create a project folder, initialize package.json, and install Axios for HTTP requests and dotenv for environment variables. Avoid native fetch for simplicity as a beginner; Axios handles errors automatically.

Set Up Environment Variables

Create a .env file at the root:

API_KEY=your_360learning_api_key
DOMAIN=your-domain.360learning.com # e.g., acme.360learning.com

Important: Never commit .env to Git (add it to .gitignore). Replace with your actual values from the 360Learning dashboard. This keeps your API key secure, like a lock on your safe.

Authentication and Connection Test Script

src/auth.js
require('dotenv').config();
const axios = require('axios');

const API_KEY = process.env.API_KEY;
const DOMAIN = process.env.DOMAIN;
const BASE_URL = `https://${DOMAIN}/api/v1`;

const headers = {
  'Authorization': `Bearer ${API_KEY}`,
  'Content-Type': 'application/json'
};

async function testConnection() {
  try {
    const response = await axios.get(`${BASE_URL}/courses`, { headers });
    console.log('Connection OK!', `Number of courses: ${response.data.length}`);
  } catch (error) {
    console.error('Connection error:', error.response?.data || error.message);
  }
}

testConnection();

This script loads env vars, sets up Bearer headers (standard for 360Learning API), and tests the connection by listing courses. Run with node src/auth.js. Pitfall: double-check the exact DOMAIN, or you'll get a 404. Error handling makes debugging easy.

Create Your First Course via API

Now, use the /courses endpoint to create a course. The 360Learning API requires a JSON payload with title, description, and type ('course'). You'll see it appear instantly in your dashboard interface.

Course Creation Script

src/createCourse.js
require('dotenv').config();
const axios = require('axios');

const API_KEY = process.env.API_KEY;
const DOMAIN = process.env.DOMAIN;
const BASE_URL = `https://${DOMAIN}/api/v1`;

const headers = {
  'Authorization': `Bearer ${API_KEY}`,
  'Content-Type': 'application/json'
};

async function createCourse() {
  const courseData = {
    title: 'Introduction to Node.js for Beginners',
    description: 'Complete course on Node.js basics and APIs.',
    type: 'course',
    public: false
  };

  try {
    const response = await axios.post(`${BASE_URL}/courses`, courseData, { headers });
    console.log('Course created! ID:', response.data.id);
  } catch (error) {
    console.error('Creation error:', error.response?.data || error.message);
  }
}

createCourse();

POST to /courses with a minimal valid payload. The course is private by default for security. Copy the returned ID for next steps. Avoid titles longer than 255 characters to prevent 400 Bad Request errors.

Add Learners to a Course

Analogy: Like inviting colleagues to a Zoom meeting. Use the /courses/{id}/enrollments endpoint with emails. In the 360Learning interface, they'll see the course in their dashboard.

Add Learners Script

src/addLearners.js
require('dotenv').config();
const axios = require('axios');

const API_KEY = process.env.API_KEY;
const DOMAIN = process.env.DOMAIN;
const BASE_URL = `https://${DOMAIN}/api/v1`;

const COURSE_ID = 'REPLACE_WITH_COURSE_ID';  // Replace with the ID of the created course

const headers = {
  'Authorization': `Bearer ${API_KEY}`,
  'Content-Type': 'application/json'
};

const learners = [
  { email: 'user1@example.com', role: 'learner' },
  { email: 'user2@example.com', role: 'learner' }
];

async function addLearners() {
  try {
    const response = await axios.post(`${BASE_URL}/courses/${COURSE_ID}/enrollments`, { learners }, { headers });
    console.log('Learners added:', response.data);
  } catch (error) {
    console.error('Error:', error.response?.data || error.message);
  }
}

addLearners();

POST enrollments with an array of existing emails. Replace COURSE_ID. Roles ('learner', 'manager') control access. Pitfall: emails must already exist in 360Learning, or you'll get a 404.

List Learner Progress

src/listProgress.js
require('dotenv').config();
const axios = require('axios');

const API_KEY = process.env.API_KEY;
const DOMAIN = process.env.DOMAIN;
const BASE_URL = `https://${DOMAIN}/api/v1`;

const COURSE_ID = 'REPLACE_WITH_COURSE_ID';

const headers = {
  'Authorization': `Bearer ${API_KEY}`,
  'Content-Type': 'application/json'
};

async function listProgress() {
  try {
    const response = await axios.get(`${BASE_URL}/courses/${COURSE_ID}/progress`, { headers });
    console.log('Progress:', response.data);
  } catch (error) {
    console.error('Error:', error.response?.data || error.message);
  }
}

listProgress();

GET /courses/{id}/progress returns JSON with completion percentages per user. Great for automated reports. Use ?limit=100 for better performance on large queries.

Integrate into a Main Script

Create src/index.js to orchestrate everything:

javascript
// Run: node src/index.js

Test in sequence: auth > create > add > list. Add to a cron job for daily syncs.

Complete Main Script

src/index.js
require('dotenv').config();
const axios = require('axios');

// ... (paste the auth, createCourse, addLearners, listProgress functions here)

async function main() {
  await testConnection();
  await createCourse();
  // await addLearners();
  // await listProgress();
}

main();

Orchestrator script. Comment out sensitive steps. 100% functional: copy-paste and run. Use async/await to sequence without callback hell.

Best Practices

  • Rate limiting: Max 100 req/min; add await new Promise(r => setTimeout(r, 1000)); between calls.
  • Error handling: Always use try/catch + logs (Winston for production).
  • Security: Store API_KEY in a Vault (AWS Secrets); rotate every 90 days.
  • Validation: Use Zod for payloads before sending.
  • Testing: Mocha + nock to mock API without burning quotas.

Common Errors to Avoid

  • 401 Unauthorized: Expired API key or wrong DOMAIN (copy-paste from dashboard).
  • 422 Unprocessable: Malformed payload (e.g., type != 'course').
  • CORS in frontend: Use a Node proxy; 360Learning API blocks direct browser access.
  • Non-existent emails: Create users via /users first.
  • Forgetting .env: 'undefined' error—check dotenv.config() first.

Next Steps