xPlantAPI
API referenceTasks and demand

Record a demand signal

Records how much demand there is for a genus — orders, sales velocity, a forecast — from any source you run. xPlant uses the latest signal per genus when it scores the task queue. Send one whenever your number changes; history is kept.

POST/api/v1/tasks/demand
Scope write:demandHonours Idempotency-Key

See also: Push demand signals.

Send an Idempotency-Key header to make retries safe: a repeat with the same key within 24 hours returns the first response instead of writing twice. See Idempotency.

Headers

NameTypeRequiredDescription
Idempotency-KeystringNoAny unique string you choose per logical write. A retry carrying the same key within 24 hours returns the first result instead of writing again. Scoped to your API key and this operation. 8–255 characters. Must match ^[A-Za-z0-9._:~-]+$.

Request body

FieldTypeRequiredDescription
genusstringYes1–100 characters.
source_typestringNoUp to 50 characters.
demand_scorenumberYesAt least 0.
sourcestringYes1–100 characters.
observed_atstring (date-time)No—

Example

curl -X POST https://app.xplantpro.com/api/v1/tasks/demand \
  -H "Authorization: Bearer $XPLANT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "genus": "Alocasia",
    "source_type": "tissue",
    "demand_score": 42,
    "source": "storefront",
    "observed_at": "2026-09-24T00:00:00.000Z"
  }'

Response

201 with { "ok": true, "data": … }. data holds the result.

FieldTypeRequiredDescription
idstringYesThe signal's id — or current on the reading current=true returns.
genusstringYes—
source_typestring | nullYes—
demand_scorenumberYes—
sourcestringYes—
observed_atstringYes—
created_atstringYes—
Response
{
  "ok": true,
  "data": {
    "id": "c41e8a07-93d2-4b6f-8e15-7a2d0f9b3c58",
    "genus": "Alocasia",
    "source_type": "tissue",
    "demand_score": 42,
    "source": "storefront",
    "observed_at": "2026-09-24T00:00:00.000Z",
    "created_at": "2026-09-24T00:05:11.000Z"
  }
}
Response headerMeaning
Idempotent-Replaytrue when this response is a replay of an earlier request with the same Idempotency-Key.
X-Request-IdIdentifies this request. Include it when you contact support.

Errors

StatusCodeWhen
400VALIDATION_ERRORThe request body is not valid JSON.
401UNAUTHORIZEDThe key is missing, malformed or revoked, or its owner is no longer a member of the workspace.
402PAID_PLAN_REQUIREDThe workspace's plan does not include the API. The full API is included with xPlant+ Teams and Enterprise; on Hobby and Pro Lab, keys can connect devices only.
403FORBIDDENThe key lacks a scope this operation requires, or its owner's current role in the workspace cannot use it — a key never does more than its owner can in xPlant. error names the scope, and for a role, the role it needs.
403DEVICE_TOKEN_NOT_ACCEPTEDA device token was sent; this operation needs a workspace API key.
409IDEMPOTENCY_IN_FLIGHTA request with this Idempotency-Key is still being processed; retry after Retry-After seconds.
422VALIDATION_ERRORThe Idempotency-Key header is malformed.
422VALIDATION_ERRORA field failed validation. error names the first one, for example title: title is required.
429RATE_LIMIT_EXCEEDEDToo many requests for this key, device token or workspace. Wait Retry-After seconds.
500DEMAND_CREATE_FAILEDThe signal could not be saved. Retry later.

Branch on code, never on the error text. See Errors.

On this page