資料
Whiteboards over the Content API

Whiteboards over the Content API

Create and update classroom whiteboards, publish a snapshot, and link it to a course lesson.

このページの内容

Use /v1/content/classrooms/{classroomId}/whiteboards to work with the same boards educators see in TutorFlow. Authenticate with a classroom-authorized tf_content_ API key. Reads require content:read. Creating, saving, publishing, and linking boards require content:write and use no generation credits.

The Whiteboards editor offers optional AI creation and editing. Content API clients supply their own cards. For other API credit costs, see Content API Pricing.

Find a board

HTTP
GET /v1/content/classrooms/{classroomId}/whiteboards?page=1&limit=50&search=retro&publishedOnly=true
Authorization: Bearer tf_content_...

The list returns { "items", "totalCount" }. Items contain id, the current draft title, isPublished, and up to 20 lightweight previewCards. Results sort by creation time, newest first, then by ID. page starts at 1. limit defaults to 50 and is capped at 100. search matches a literal, case-insensitive substring of the draft title. Set publishedOnly=true to list boards that have a published snapshot.

Use GET /whiteboards/{id} under the same classroom path to read the complete draft. It returns id, title, cards, revision, isPublished, and isCurrentPublished.

Create a draft

Generate a UUID for each new board. Store it in your system and reuse it when retrying the create. A retry with the same ID returns the latest state of the existing board without replacing its contents. Use the environment variables from the Quickstart.

bash
curl -X POST "$TUTORFLOW_API_BASE_URL/v1/content/classrooms/$CLASSROOM_ID/whiteboards" \
  -H "Authorization: Bearer $TUTORFLOW_CONTENT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "6b7dc281-b57e-4bc8-939d-a55281885267",
    "title": "Team retrospective",
    "cards": [
      {
        "id": "677b3538-868f-4490-bbd8-e249bc44b446",
        "kind": "note",
        "color": "mint",
        "x": 40,
        "y": 40,
        "w": 320,
        "h": 200,
        "text": "What should we keep doing?"
      }
    ]
  }'

A new board returns 201 with revision: 1, isPublished: false, and isCurrentPublished: false. Titles must contain non-whitespace text and can be up to 200 characters. A blank board uses cards: [].

Save or publish

PATCH replaces the entire draft. Read or retain the current revision, then send that value with the complete title, cards, and publish flag. The response carries the next revision. On 409 content_conflict, read the current draft, reconcile any edits, and retry with its revision.

bash
curl -X PATCH "$TUTORFLOW_API_BASE_URL/v1/content/classrooms/$CLASSROOM_ID/whiteboards/$BOARD_ID" \
  -H "Authorization: Bearer $TUTORFLOW_CONTENT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Team retrospective",
    "revision": 1,
    "publish": true,
    "cards": [
      {
        "id": "677b3538-868f-4490-bbd8-e249bc44b446",
        "kind": "note",
        "color": "mint",
        "x": 40,
        "y": 40,
        "w": 320,
        "h": 200,
        "text": "What should we keep doing?"
      }
    ]
  }'

publish: true updates the snapshot used by every lesson linked to the board. publish: false saves the draft while linked lessons continue showing the previous snapshot. isPublished tells you whether any snapshot exists, and isCurrentPublished tells you whether it matches the current draft. Whiteboards use the body revision for concurrency and the client-generated id for create retries.

Publish the board first, then create a lesson in the same classroom with type: "whiteboard". The content field is a string containing a JSON object with the board ID in assetId. Use the course and chapter IDs from the course curriculum routes.

bash
curl -X POST "$TUTORFLOW_API_BASE_URL/v1/content/classrooms/$CLASSROOM_ID/courses/$COURSE_ID/chapters/$CHAPTER_ID/lessons" \
  -H "Authorization: Bearer $TUTORFLOW_CONTENT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: lesson:team-retrospective:v1" \
  -d '{
    "title": "Team retrospective",
    "type": "whiteboard",
    "isPublic": true,
    "content": "{\"assetId\":\"6b7dc281-b57e-4bc8-939d-a55281885267\"}"
  }'

isPublic makes the lesson visible to learners who can access the course. If you omit it, the lesson starts hidden. To replace the board on an existing whiteboard lesson, send a new content value with PATCH /courses/{courseId}/lessons/{lessonId}. A board that has no published snapshot or belongs to another classroom returns 404 when linked.

Card format

The cards array is ordered from back to front and accepts up to 150 cards. Each card needs a distinct UUID in id, a kind, text up to 2,000 characters, and integer x, y, w, and h in canvas units. Coordinates run from -100,000 to 100,000. Width and height run from 1 to 10,000.

FieldValues
kindnote, source, heading, ink, rectangle, ellipse, coordinatePlane, numberLine, graphPaper, ruledPaper, scene, or equation.
coloryellow, mint, blue, or pink.
previewOptional inline WebP data URL, up to 65,000 characters. Use this for previews of source files.
pointsOptional ink coordinates, alternating local x and y, at most 1,024 integers from 0 to 10,000.
strokeWidth, inkStyleInk width 1, 3, 6, 10, 18, or 30. Set inkStyle to marker for highlighter strokes.
connectionsUp to 32 outgoing links. Each has a distinct destination card to, a style (straight, elbow, or curve), optional heads (end, both, or none), and a label of up to 80 characters.
groupId, pinnedOptional UUID for grouped cards and boolean pin state.

POST and PATCH accept JSON bodies up to 12 MiB. The OpenAPI document contains the complete request and response schemas.

このページは役に立ちましたか?