Skip to content

Sync tasks

Run a prompt and get the AI answer, its sources and the brand analysis back in a single HTTP call that stays open for up to 290 seconds.

View as Markdown

POST /v1/sync/task takes the same body as POST /v1/tasks and waits for the result inside the request.

When to use it

  • Use sync for one prompt at a time, in a script or an interactive tool.
  • Use async tasks or batches for many prompts, or for anything in a job queue.

Request

Shell
curl -X POST https://promptgale.com/v1/sync/task \
  -H "Authorization: Bearer $PROMPTGALE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Prefer: wait=120" \
  -d '{"taskType":"CHATGPT","payload":{"prompt":"best crm for agencies","country":"US"}}'

Responses

StatusMeaningWhat to do
200The task finished: COMPLETED or FAILED.Read data.result or data.error.
202Still running when the wait ended.Poll the URL in Location (GET /v1/tasks/{id}).

How long it waits

  • By default, up to 290 seconds.
  • Prefer: wait=N sets a shorter wait in seconds. The response confirms it in Preference-Applied.
  • Set your HTTP client's timeout above the wait, for example 300 seconds.

A task that outlives the wait is not lost and is not charged twice: it keeps running, and you read it with the same id.

Last updated