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, orreadandwrite(writealways includesread). 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.
| Status | code | When |
|---|---|---|
| 400 | invalid_request | A wrong parameter or body field. The message says which. |
| 401 | unauthorized | No key, a badly formed key, an unknown key or a revoked key. They all look the same. |
| 403 | insufficient_scope | A write endpoint called with a read-only key. |
| 403 | plan_required | POST /webhooks for a school no longer on the Unlimited plan: new webhook subscriptions need Unlimited; existing ones keep working. |
| 404 | not_found | The 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). |
| 409 | already_exists | The course already has a coupon with this code. |
| 409 | limit_reached | Your school already has 50 active webhook subscriptions made with keys. |
| 429 | rate_limited | More than 120 requests in a minute for this key. |
| 500 | server_error | Something 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 a400.cursor: thenextCursorof 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:
idtitle: text ornullurl: the course's URL path, ornulltype:"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", ornull.price: number ornull, in whole units of your school's currency (49.99means 49.99, not cents).free: true or falseprivate: true or falsehidden: true or falsecreatedAt: ISO 8601 date-time, ornull
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:
idemail: text ornullname: text ornullcreatedAt: ISO 8601 date-time, ornull
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 withstudentIdorcourseId.completed: onlytrue. Returns enrollments with progress 100 or more. Can't be combined withstudentId,courseIdorsort.
studentId and courseId can be used together.
GET /enrollments/{id}
Scope: read. One enrollment, or 404.
An enrollment has these fields:
idstudentId: text ornullcourseId: text ornullstatus: text ornull,"active"or"inactive".progress: number ornull, the percentage of the course completed (0 to 100).enrolledAt: ISO 8601 date-time, ornullcompletedAt: ISO 8601 date-time, ornullexpiresAt: ISO 8601 date-time, ornull
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:
| Field | Required | Rules |
|---|---|---|
courseId | yes | The course id (letters, numbers, -, _; up to 128 characters). |
email | yes | A valid email, up to 254 characters. |
name | no | The student's name. Longer than 120 characters is cut. |
password | no | For 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 withGET /enrollments?studentId=…&courseId=….
studentId can be null if we could not look the account up.
Errors:
400invalid_request: "courseId is required"400invalid_request: "a valid email is required"400invalid_request: "password: at least 6 characters with an upper-case and a lower-case letter and a number"404not_found: "Course not found."403insufficient_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:
idstudentId: text ornullamount: number ornull, what the student paid, in whole currency units (not cents).currency: text ornullgateway:"stripe","paypal", or"coupon"for an order made free by a 100% coupon (no payment), ornull.courseId: text ornullbundleId: text ornullplan: for a subscription, its billing period:"month","quarter","year"or"lifetime";nullfor a one-time purchase.couponCode: the coupon code the student used, ornullrefundedAmount: number,0when nothing was refundedcreatedAt: ISO 8601 date-time, ornull
Coupons
POST /courses/{id}/coupons
Scope: write. Creates a coupon for a course, with the same rules as Price & coupons in the course.
Body:
| Field | Required | Rules |
|---|---|---|
code | yes | 6 to 20 letters, numbers, - or _. Saved in upper case. |
free | no | true for a free coupon. Anything else means a paid coupon. |
price | when not free | The price the student pays with the coupon (not the discount): a number from 1 to the course price. |
remaining | yes | How many times it can be used: a whole number from 1 to 100,000,000. |
deadline | no | A 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:
400invalid_request: "invalid course id"400invalid_request: "code: 6–20 letters, numbers, - or _"400invalid_request: "this course has no price: only a free coupon (free: true) is possible"400invalid_request: "price: 1 to <course price> (the course price), or free: true"400invalid_request: "remaining: the number of uses, 1 to 100,000,000"400invalid_request: "deadline: a future date (ISO 8601)"404not_found: "Course not found."409already_exists: "This course already has a coupon <CODE>."403insufficient_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 oforder.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/jsonUser-Agent: OnlineCourseHost-Webhooks/1OCH-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 exampleorder.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.completedorwebhook.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 whenstudentIdis set.course:{id, title, url}, only whencourseIdis 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.