Skip to main content
Grading an answer sheet or writing a worksheet takes the AI longer than a normal web request allows. So the API accepts the work, gives you a job ID, and finishes it in the background. It works like ordering at a counter: you get an order number and collect your order when it’s ready.

How does a background job work?

  1. A POST or PATCH request starts the job and returns right away with an ID.
  2. The job runs in the background.
  3. You find out it finished in one of two ways:
    • Polling: your server checks the job’s status every few seconds. See Poll for results.
    • Webhooks: CrazyGoldFish calls your server as soon as the job finishes. See Receive webhooks.
  4. You fetch the result with a GET request.

Job status values

Partial means the plan was built, but some questions failed. Treat it as a result worth showing, not an error.

Poll for results

  • Poll every 5 seconds. Faster polling doesn’t make jobs finish sooner.
  • Expect a short 404 at the start. Right after you start a Lesson Plan or Worksheet job, its GET endpoint returns 404 with a step not found message until a worker picks the job up. Keep polling.
  • A failed job usually returns 400, with "status": "Failed" and a msg explaining why. Action Plans, ClassTrack, and Get lesson plan content return 200 with "status": "Failed" instead, so check status on every 200 too.
  • Set a timeout. Some failures leave a job In Progress. If a job hasn’t completed after 10 minutes, stop polling, start a new job, and contact CrazyGoldFish with the job ID.
Each product guide includes a ready-to-use polling helper. For example, see Generate a worksheet.

Receive webhooks

A webhook is a message CrazyGoldFish sends to your server when a job completes or fails, so you don’t need to keep checking. Technically, it’s a POST request to an HTTPS address you register.

Register a webhook

1

Find the event's template ID

Response
The real response lists every event. See List webhook event templates.
2

Register your endpoint

Send the template id, your HTTPS URL, and a secret that you generate:
Register one webhook for each event you want.
Register webhooks with the same API user that starts the jobs. A webhook only fires for jobs started by the API user who registered it. Webhooks registered by a different user are ignored.
Other rules:
  • endpoint_url must start with https://. A successful registration returns 201.
  • Each API user can register one webhook per event. A second one returns 400 Webhook already exists.
  • To change the URL, send PATCH /webhooks/v1/webhook/{id}/. It requires endpoint_url and replaces the stored one, and if you leave out secret_hash, the saved secret is removed. Send both fields every time.
  • There is no endpoint to delete a webhook. Contact CrazyGoldFish to disable one.
  • Template IDs differ between environments, so read them from the templates call rather than hardcoding them.
  • If registration succeeded and your jobs complete but nothing ever arrives, your API user may not be fully set up for delivery. Contact CrazyGoldFish.

Events

Every event is sent whether the job succeeded or failed. Check status: Completed or Failed, and also Partial for action plans.

Payloads

Payloads tell you which job finished. They don’t include the result, so fetch it with the endpoint in the table above.
Exam payloads include exam_id, plus model_answer_sheet_id or ans_sheet_id for those events. Assignment payloads use webhook_name instead of name. Action plan and ClassTrack payloads use the same shape as the Lesson Plan and Worksheet example above: for student_action_plan the id is the answer sheet ID, for teacher_action_plan it is the exam ID, and for class_track_analysis it is the analysis ID. secret_hash is null if you registered the webhook without a secret.
A webhook can only be registered for an event that exists in your account’s template list. If an event in this table is missing from List event templates, contact CrazyGoldFish to have it added.

Handle deliveries

  • Verify the sender. Compare secret_hash with the secret you registered, and reject the request if they don’t match.
  • Respond within 5 seconds with a 2xx status. Do slow work after you respond.
  • Keep polling as a fallback. Most events are sent once with no retry. exam_evaluation_student_answer_sheet_evaluation is retried once after 5 seconds if your endpoint doesn’t return 200 or 201.
  • Handle duplicates. Because of retries, the same event can arrive twice.