Skip to content

Sell a course with an agent

An AI agent can do the whole job for you: build the course, set a price, connect payment, and give you the link where people can buy it. Two steps need you, because only a person can do them: approve the agent, and finish the Stripe form for payment. The agent gives you a link for each one.

All the calls below use the API and start with https://www-dev.yoshuko.com/api/v1/agent/.

1. Connect the agent

You do not need to copy a secret key. The agent asks Yoshuko for a connect link. This call needs no key:

curl -sS -X POST "https://www-dev.yoshuko.com/api/v1/agent/connect/" \
  -H "Content-Type: application/json" \
  -d '{"client_name": "My assistant", "preset": "build_and_sell"}'

The answer holds a short user_code, a verification_url_complete link, a secret device_code, and how long to wait between checks (interval).

The agent shows you the link. You open it, sign in, choose your organisation and press Approve. The page lists what the agent will be allowed to do before you agree. The name the agent chose is shown as plain text, and the page says it is not checked.

Meanwhile the agent asks again every few seconds:

curl -sS -X POST "https://www-dev.yoshuko.com/api/v1/agent/connect/token/" \
  -H "Content-Type: application/json" \
  -d '{"device_code": "<the device_code>"}'

Until you approve, the answer is authorization_pending. After you approve, the first answer holds the key (api_key). It is shown once. Every call after that uses it:

-H "Authorization: Bearer $YOSHUKO_API_KEY"

If you say no, the answer is access_denied and no key is made. A link ends after ten minutes; the agent can ask for a new one.

Who can approve

Your organisation must be checked and on a paid plan, or in the alpha. The approve page tells you which one is missing and where to fix it.

2. See what is left to do

curl -sS "https://www-dev.yoshuko.com/api/v1/agent/setup/" -H "Authorization: Bearer $YOSHUKO_API_KEY"

The answer lists every step (profile, branding, payments, first_course, publish). Each step says if it is done, if it is needed to sell, and what to do next. A step that only a person can do comes with a link for that person.

3. Build the course

Create the course, its units and its lessons as in Build a course with the API. A few more calls help:

To do this Call
Put units in a new order POST /courses/{id}/chapters/reorder/ with {"order": [ids]}
Copy a unit or a lesson POST /courses/{id}/chapters/{unit}/duplicate/
Move a lesson POST /courses/{id}/lessons/{lesson}/move/
Show a unit and its lessons to learners POST /courses/{id}/chapters/{unit}/publish/ with {"cascade": true}
Add a video or file POST /courses/{id}/uploads/, send the parts, then .../complete/
Set a picture for the course page POST /courses/{id}/landing/hero/import/ with {"url": "…"}

Units and lessons start as drafts. Learners see a lesson only when its unit and the lesson are published. The launch step (below) warns you if no lesson is published.

4. Set a price

curl -sS -X PUT "https://www-dev.yoshuko.com/api/v1/agent/courses/$COURSE_ID/price/" \
  -H "Authorization: Bearer $YOSHUKO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount": "19.00", "currency": "USD"}'

A price of 0 makes a free course. In the alpha you can only make free courses. A price above zero is refused with free_courses_only, and the answer holds a link where a person can move to a paid plan.

5. Connect payment

curl -sS -X POST "https://www-dev.yoshuko.com/api/v1/agent/payments/onboarding-link/" \
  -H "Authorization: Bearer $YOSHUKO_API_KEY"

The answer holds an onboarding_url. Send it to the person. Stripe asks them for the details it needs to pay them, and an agent cannot fill that in. When they finish, they see a note that says they can go back to the agent.

The agent checks with GET /payments/. When charges_enabled is true, paid courses can sell.

If the organisation needs a paid plan first, ask GET /plans/, then POST /plan/checkout/ with {"plan": "<slug>"}. That answer holds a payment link for a person.

curl -sS "https://www-dev.yoshuko.com/api/v1/agent/courses/$COURSE_ID/launch/" \
  -H "Authorization: Bearer $YOSHUKO_API_KEY"

The answer lists blockers (what stops the launch, with the next step for each) and warnings. When there are no blockers, publish it:

curl -sS -X POST "https://www-dev.yoshuko.com/api/v1/agent/courses/$COURSE_ID/launch/" \
  -H "Authorization: Bearer $YOSHUKO_API_KEY"

The course is now published and public. The answer holds sales_url: give this link to the person. It is the page where people can buy the course. If a blocker is in the way, the answer is 409 launch_blocked, and nothing is changed.

What the agent can also do

With more permissions the agent can set your brand picture and page pictures, make coupons, read sales numbers, add groups of learners, mark work and manage certificates. See Key permissions. The ready-made set Run courses gives all of these.