OnlineCourseHost.com Help Center

API and webhooks: connect your own tools

The API lets your own tools read your academy's courses, students, enrollments and orders, enroll students and create coupons. Webhooks send a signed message to your server when something happens, for example when an order is completed.

The API is part of the Unlimited plan. You find it in Settings, then API & webhooks. Only the admins of your school see this page.

Only your school's owner and admins see this page (team members with a custom role don't). To make a key or an endpoint you need to have signed in within the last 10 minutes: if it's been longer, the page asks you to sign in again first.

The full list of endpoints and fields is in the API reference.

Make a key

Give each tool its own key. Then you can revoke one key without breaking your other tools.

  1. Open Settings, then API & webhooks.
  2. Under API keys, type a name: what will use the key, for example "Zapier" or "Monthly report".
  3. Pick the access: Read or Read and write.
  4. Click Create key. Copy the key now.

What each access allows:

  • Read: read your courses, students, enrollments and orders, check the key itself, and subscribe a URL to webhook events.
  • Read and write: everything Read does, plus two actions: enroll a student in a course (this creates the student's account if needed and sends the welcome email) and create a coupon for a course. Nothing else can be changed through the API.

A key looks like och_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: och_live_ and then 32 letters and numbers.

Keep your key secret

  • You see the key once, when you create it. We only keep a fingerprint of it, so nobody can show it again, not even us. The list shows only its last 4 characters.
  • Treat it like a password. Don't put it in a web page, an email or a public code repository.
  • A key only ever sees your school.

If a key may have leaked, or a tool no longer needs it, click Revoke. The key stops working at once. This works on every plan: after a downgrade from Unlimited your keys keep working, and the page still lists them under the plan card so you can revoke them. Webhook subscriptions that a tool made with this key (for example a Zap) are removed with it. Endpoints you added on the screen stay.

Lost the key? You can't see it again. Create a new key and revoke the old one.

Call the API

Send the key in the Authorization header. Every answer is JSON. Lists come in pages.

curl https://api.onlinecoursehost.com/api/public/v1/courses \
  -H "Authorization: Bearer och_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

The answer looks like this:

{
  "items": [
    {"id": "abc123", "title": "Yoga for beginners", "url": "yoga-for-beginners", "type": "course", "status": "…",
     "price": 49, "free": false, "private": false, "hidden": false, "createdAt": "2026-01-15T10:00:00.000Z"}
  ],
  "nextCursor": null
}

To check that a key works, call GET https://api.onlinecoursehost.com/api/public/v1/me. It shows your school and the key's access.

The key only goes in the header. A key in the URL doesn't work.

Add a webhook endpoint

An endpoint is a URL on your server (or in a tool like Zapier or Make) where we send events.

  1. Under Webhooks, paste the URL. It must start with https://.
  2. Tick the events you want.
  3. Click Add endpoint. Copy the signing secret now: you see it once. It starts with whsec_.

The events:

  • order.completed: an order for a course, bundle or plan was completed (paid, or free with a 100% coupon).
  • enrollment.created: a student got access to a course (paid, free, or added by you or by the API).
  • course.completed: a student's progress in a course reached 100%.

Each message also includes the student's id, email and name and the course's id, title and URL, so you don't need a second call.

The URL must use the normal https port, have no user name or password in it, and use a host name, not an IP address. Local and private addresses are refused. We check the address again each time we send a message: if your host name later points to a private address, we stop sending to it.

Send test sends a webhook.test event to that endpoint, so you can check your server receives and verifies it. Recent deliveries shows the last messages, their result and the attempt number.

Check the signature

Every message has an OCH-Signature header, like this:

OCH-Signature: t=1764230400,v1=5f2b…

t is the time we sent it (Unix seconds). v1 is an HMAC-SHA256, in hex, of t, a dot, and the raw body, made with your signing secret. Check it before you trust a message. Use the raw body exactly as received: if you parse the JSON and turn it back into text, the check fails.

An example with Node.js and Express:

const crypto = require('crypto');
const express = require('express');

const app = express();
const SECRET = process.env.OCH_WEBHOOK_SECRET; // whsec_…

app.post('/och-events', express.raw({type: 'application/json'}), (req, res) => {
  const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(req.get('OCH-Signature') || '');
  if (!m) return res.status(400).send('No signature');

  const t = Number(m[1]);
  if (Math.abs(Date.now() / 1000 - t) > 300) return res.status(400).send('Too old');

  const raw = req.body.toString('utf8');
  const expected = crypto.createHmac('sha256', SECRET).update(`${t}.${raw}`, 'utf8').digest();
  const received = Buffer.from(m[2], 'hex');
  if (expected.length !== received.length || !crypto.timingSafeEqual(expected, received)) {
    return res.status(400).send('Bad signature');
  }

  const event = JSON.parse(raw);
  // event.id is the same on every retry: skip an id you have already handled
  console.log(event.type, event.data);
  res.sendStatus(200);
});

app.listen(3000);

The example refuses messages more than 5 minutes (300 seconds) old. Our own check uses the same 5 minutes. We sign each attempt again, so a retried message has a fresh t.

Retries and failures

A message counts as delivered when your server answers with a 2xx status within 10 seconds. Anything else is a failure: another status, a redirect, a timeout, or no connection.

After a failure we try again. The first try is right away, then we wait:

  • 1 minute,
  • 5 minutes,
  • 30 minutes,
  • 2 hours,
  • 6 hours,
  • 12 hours,
  • 24 hours.

That's 8 tries in all, over about 45 hours. After the 8th failure we stop trying that message.

The same event can reach you more than once. Its id stays the same on every try, so use it to skip duplicates.

If an endpoint keeps failing for 3 days with no success at all, we switch it off. Messages still waiting for it are cancelled. One success resets the clock.

A switched-off endpoint can't be switched back on: remove it and add it again. You then get a new signing secret, so update it in your tool. Messages that failed are not sent again.

Limits

  • 10 active keys per school. Revoked keys don't count.
  • 120 requests a minute per key. Above that you get status 429; the RateLimit-Reset header says how many seconds to wait.
  • 5 webhook endpoints per school, added on the screen.
  • Tools that subscribe with a key (for example Zapier or Make) have their own limit: 50 active subscriptions per school.
  • Lists return up to 100 items a page (25 if you don't say).

If your school moves to a plan below Unlimited, your existing keys and webhooks keep working. You can't create new keys or endpoints, or change them, until you're back on Unlimited (or its free trial).

Still need help? Contact Us