OnlineCourseHost.com Help Center

API reference

Every endpoint of the API, version 1. To make a key and set up webhooks, see API and webhooks: connect your own tools.

Base URL

https://api.onlinecoursehost.com/api/public/v1

Every path below goes after this base URL. Answers are JSON. Send request bodies as JSON with Content-Type: application/json.

Authentication

Send your key in the Authorization header:

Authorization: Bearer och_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  • A key is och_live_ followed by 32 letters and numbers.
  • Only the header works. A key in the URL or the body is ignored.
  • The school comes from the key. A key never sees another school.
  • A key has the scope read, or read and write (write always includes read). On the screen these are Read and Read and write.

Rate limit

120 requests per minute per key, counted per calendar minute. Above that you get 429 with a RateLimit-Reset header: the number of seconds until the next minute starts.

Errors

An error answer has this body:

{"error": {"code": "invalid_request", "message": "limit must be 1–100"}}

The message is for people; use the code in your code.

StatuscodeWhen
400invalid_requestA wrong parameter or body field. The message says which.
401unauthorizedNo key, a badly formed key, an unknown key or a revoked key. They all look the same.
403insufficient_scopeA write endpoint called with a read-only key.
403plan_requiredPOST /webhooks for a school no longer on the Unlimited plan: new webhook subscriptions need Unlimited; existing ones keep working.
404not_foundThe item doesn't exist in your school, or the path doesn't exist (a typo, or a method the path doesn't take). Also returned while the API is not switched on for your school (a missing or invalid key still gets 401 first).
409already_existsThe course already has a coupon with this code.
409limit_reachedYour school already has 50 active webhook subscriptions made with keys.
429rate_limitedMore than 120 requests in a minute for this key.
500server_errorSomething went wrong on our side. Try again later.

Pagination

Every list endpoint takes:

  • limit: 1 to 100. Left out or empty: 25. Anything else is a 400.
  • cursor: the nextCursor of the previous page. Leave it out for the first page.

A list answer is:

{
  "items": [ … ],
  "nextCursor": "YWJjMTIz"
}

nextCursor is null on the last page. Treat the cursor as opaque text. Use a cursor only with the same list and the same filters it came from; otherwise you may get 400 "invalid cursor".

Without sort, lists are in a fixed order (by id), not by date.

GET /me

Scope: read. Checks the key and shows which school and scopes it has.

{
  "school": {"id": "school123", "name": "Yoga Academy", "subDomain": "yoga"},
  "key": {"id": "key123", "scopes": ["read", "write"]},
  "apiVersion": "v1"
}

school.name and school.subDomain can be null.

Courses

GET /courses

Scope: read. A page of your courses. Query: limit, cursor. No filters.

GET /courses/{id}

Scope: read. One course, or 404.

A course has these fields:

  • id
  • title: text or null
  • url: the course's URL path, or null
  • type: "course" when not set (a regular course), otherwise one of "regular", "scorm", "live-session", "webinar", "digital-download", "product-bundle", "coaching-session", "exam".
  • status: "draft" or "published", or null.
  • price: number or null, in whole units of your school's currency (49.99 means 49.99, not cents).
  • free: true or false
  • private: true or false
  • hidden: true or false
  • createdAt: ISO 8601 date-time, or null

Students

GET /students

Scope: read. A page of your students. Query: limit, cursor, and:

  • email: only the student with this email. It matches the email as you type it, or in lower case.

GET /students/{id}

Scope: read. One student, or 404.

A student has these fields:

  • id
  • email: text or null
  • name: text or null
  • createdAt: ISO 8601 date-time, or null

Enrollments

GET /enrollments

Scope: read. A page of enrollments. Query: limit, cursor, and:

  • studentId: only this student's enrollments.
  • courseId: only this course's enrollments.
  • sort: -enrolledAt (newest enrollment first) or -completedAt (latest completion first). Can't be combined with studentId or courseId.
  • completed: only true. Returns enrollments with progress 100 or more. Can't be combined with studentId, courseId or sort.

studentId and courseId can be used together.

GET /enrollments/{id}

Scope: read. One enrollment, or 404.

An enrollment has these fields:

  • id
  • studentId: text or null
  • courseId: text or null
  • status: text or null, "active" or "inactive".
  • progress: number or null, the percentage of the course completed (0 to 100).
  • enrolledAt: ISO 8601 date-time, or null
  • completedAt: ISO 8601 date-time, or null
  • expiresAt: ISO 8601 date-time, or null

POST /enrollments

Scope: write. Enrolls a student in a course. If no account exists for the email, it creates one and sends the welcome email. An existing student gets the existing-student welcome email.

Body:

FieldRequiredRules
courseIdyesThe course id (letters, numbers, -, _; up to 128 characters).
emailyesA valid email, up to 254 characters.
namenoThe student's name. Longer than 120 characters is cut.
passwordnoFor a new account: at least 6 characters, with an upper-case letter, a lower-case letter and a number. An empty text counts as no password. Without one, we make a strong password and send it in the welcome email. For an existing account it is not used.
curl -X POST https://api.onlinecoursehost.com/api/public/v1/enrollments \
  -H "Authorization: Bearer och_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"courseId": "abc123", "email": "student@example.com", "name": "Sam Student"}'

Answers:

  • 201, enrolled: {"created": true, "studentId": "uid123", "courseId": "abc123", "email": "student@example.com"}
  • 200, already had the course: the same fields with "created": false.
  • 200, the same student and course are being enrolled by another request right now: {"created": false, "inProgress": true, "studentId": null, "courseId": "abc123", "email": "student@example.com"}. Check again later with GET /enrollments?studentId=…&courseId=….

studentId can be null if we could not look the account up.

Errors:

  • 400 invalid_request: "courseId is required"
  • 400 invalid_request: "a valid email is required"
  • 400 invalid_request: "password: at least 6 characters with an upper-case and a lower-case letter and a number"
  • 404 not_found: "Course not found."
  • 403 insufficient_scope: the key is read-only.

Orders

Only completed orders are returned.

GET /orders

Scope: read. A page of completed orders. Query: limit, cursor, and:

  • sort: only -createdAt (newest first).

GET /orders/{id}

Scope: read. One completed order, or 404 (also for an order that isn't completed).

An order has these fields:

  • id
  • studentId: text or null
  • amount: number or null, what the student paid, in whole currency units (not cents).
  • currency: text or null
  • gateway: "stripe", "paypal", or "coupon" for an order made free by a 100% coupon (no payment), or null.
  • courseId: text or null
  • bundleId: text or null
  • plan: for a subscription, its billing period: "month", "quarter", "year" or "lifetime"; null for a one-time purchase.
  • couponCode: the coupon code the student used, or null
  • refundedAmount: number, 0 when nothing was refunded
  • createdAt: ISO 8601 date-time, or null

Coupons

POST /courses/{id}/coupons

Scope: write. Creates a coupon for a course, with the same rules as Price & coupons in the course.

Body:

FieldRequiredRules
codeyes6 to 20 letters, numbers, - or _. Saved in upper case.
freenotrue for a free coupon. Anything else means a paid coupon.
pricewhen not freeThe price the student pays with the coupon (not the discount): a number from 1 to the course price.
remainingyesHow many times it can be used: a whole number from 1 to 100,000,000.
deadlinenoA future date-time, ISO 8601 text. Empty or left out: no deadline.
curl -X POST https://api.onlinecoursehost.com/api/public/v1/courses/abc123/coupons \
  -H "Authorization: Bearer och_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"code": "SPRING25", "price": 25, "remaining": 100, "deadline": "2027-03-31T23:59:00Z"}'

Answer 201:

{
  "id": "cpn123",
  "courseId": "abc123",
  "code": "SPRING25",
  "free": false,
  "remaining": 100,
  "active": true,
  "created": "2026-11-27T10:00:00.000Z",
  "deadline": "2027-03-31T23:59:00.000Z",
  "price": 25
}

price is null for a free coupon. deadline is null when there is none.

Errors:

  • 400 invalid_request: "invalid course id"
  • 400 invalid_request: "code: 6–20 letters, numbers, - or _"
  • 400 invalid_request: "this course has no price: only a free coupon (free: true) is possible"
  • 400 invalid_request: "price: 1 to <course price> (the course price), or free: true"
  • 400 invalid_request: "remaining: the number of uses, 1 to 100,000,000"
  • 400 invalid_request: "deadline: a future date (ISO 8601)"
  • 404 not_found: "Course not found."
  • 409 already_exists: "This course already has a coupon <CODE>."
  • 403 insufficient_scope: the key is read-only.

Webhook subscriptions (with a key)

For tools like Zapier and Make that subscribe and unsubscribe on their own. Endpoints you add on the screen are separate and can't be removed with a key.

POST /webhooks

Scope: read. Body:

  • url (required): https only, the default port 443, no user name or password, a host name (not an IP address), not a local or private address, up to 500 characters.
  • events (required): an array with one or more of order.completed, enrollment.created, course.completed.

Answer 201. The secret is shown only here:

{"id": "ep123", "url": "https://hooks.example.com/och", "events": ["order.completed"], "secret": "whsec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}

Errors: 400 invalid_request with a message starting url: or events:; 403 plan_required when the school is no longer on the Unlimited plan (existing subscriptions keep working); 409 limit_reached when the school already has 50 active subscriptions made with keys.

DELETE /webhooks/{id}

Scope: read. Removes a subscription. Only the key that made it can remove it; for any other id you get 404. Answer 200: {"deleted": "ep123"}.

When a key is revoked, its subscriptions are removed too.

Webhook messages

We send a POST with a JSON body and these headers:

  • Content-Type: application/json
  • User-Agent: OnlineCourseHost-Webhooks/1
  • OCH-Signature: t=<Unix seconds>,v1=<hex HMAC-SHA256>: the HMAC-SHA256 of "<t>.<raw body>", keyed with the endpoint's signing secret.
  • OCH-Event: the event type, for example order.completed.
  • OCH-Delivery: the id of this delivery (one per event and endpoint).

Answer with a 2xx status within 10 seconds. Redirects are not followed and count as a failure. Retries: after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, 12 hours and 24 hours (8 tries in all). An endpoint with no success for 3 days is switched off.

Body

{
  "id": "evt_…",
  "type": "order.completed",
  "createdAt": "2026-11-27T10:00:00.000Z",
  "tenantId": "school123",
  "apiVersion": "v1",
  "data": { … }
}
  • id: the event id. The same on every retry: use it to skip duplicates.
  • type: order.completed, enrollment.created, course.completed or webhook.test.
  • createdAt: when the event was queued, ISO 8601.
  • tenantId: your school's id.
  • apiVersion: "v1".
  • data: depends on the type, below.

order.completed

Sent when an order's status becomes completed. data has the same fields as an order (id, studentId, amount, currency, gateway, courseId, bundleId, plan, couponCode, refundedAmount, createdAt), plus:

  • student: {id, email, name}, only when studentId is set.
  • course: {id, title, url}, only when courseId is set.

enrollment.created

Sent when an enrollment is created, however it was made. data has the same fields as an enrollment (id, studentId, courseId, status, progress, enrolledAt, completedAt, expiresAt), plus student and course as above.

course.completed

Sent once, when an enrollment's progress reaches 100. data is the enrollment (same fields, with the new progress), plus student and course as above.

{
  "id": "evt_…",
  "type": "course.completed",
  "createdAt": "2026-11-27T10:00:00.000Z",
  "tenantId": "school123",
  "apiVersion": "v1",
  "data": {
    "id": "enr123", "studentId": "uid123", "courseId": "abc123", "status": "active", "progress": 100,
    "enrolledAt": "2026-10-01T09:00:00.000Z", "completedAt": null, "expiresAt": null,
    "student": {"id": "uid123", "email": "student@example.com", "name": "Sam Student"},
    "course": {"id": "abc123", "title": "Yoga for beginners", "url": "yoga-for-beginners"}
  }
}

completedAt can be null here: the event follows the progress, which may be saved before a completion date.

webhook.test

Sent by Send test on the screen. data is {"message": "Test event from OnlineCourseHost"}. You can't subscribe to it.

Still need help? Contact Us