Test a function
SDK platic.tools.functions.test()
Verify the draft, deploy it separately, and run it once with input. Agents keep using the published version.
Example
curl -X POST "https://api.platic.ai/v1/tools/functions/$FUNCTION_ID/test" \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": { "taxId": "XAXX010101000" }
}' await platic.tools.functions.test("fn_123", { input: { rfc: "XAXX010101000" } }); Important
HTTP calls really go out to the allowed domains. If the code creates or changes something in another system, the test does too.
Path parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
functionId | string | Function ID | ✓ |
Request body
{
"input": { "taxId": "XAXX010101000" }
} | Field | Type | Description | Required |
|---|---|---|---|
input | object | Sample input that meets the function's input schema. Up to 256 KB | — |
source | string | Tests this code instead of the saved draft, without saving it | — |
Do not send secrets: the test uses the secrets bound to the function and answers 400 if the body has them.
Response
An execution that fails inside the code is also a 200, with ok: false and error.
{
"status": "success",
"data": {
"ok": true,
"output": { "found": true, "name": "EXAMPLE COMPANY INC" },
"durationMs": 412,
"logs": ["info response {\"status\":200}"],
"httpCalls": [
{ "method": "POST", "host": "api.example.com", "status": 200, "durationMs": 380 }
],
"runId": "run_8d1f",
"version": "draft",
"nextStep": "It ran. The run is in the function's runs."
}
} Response fields
| Field | Type | Description |
|---|---|---|
ok | boolean | Whether the execution finished well |
output | any | What run returned, when ok is true. Up to 256 KB; the agent reads up to 16,000 characters |
error | object | When ok is false: code and message. See errors inside an execution |
durationMs | integer | Duration of the execution |
logs | string[] | What the code wrote with log |
httpCalls | array | Each call with method, host, status and durationMs |
runId | string | Execution ID, which stays in the executions with trigger: "test" |
version | string | "draft" in a test |
nextStep | string | Text in English that says what comes next. Do not program against its wording |
Errors
| Status | details.code | When |
|---|---|---|
400 | INVALID_REQUEST | The body fails validation or has secrets. details.issues has the list of problems |
403 | FORBIDDEN or INSUFFICIENT_SCOPE | The credential does not have write access to Integrations |
404 | NOT_FOUND | The function does not exist in this workspace |
422 | VALIDATION_FAILED | The code does not pass verification. details.issues has each problem |
429 | LIMIT_REACHED | The day's call or deployment limit was exceeded. details.resetAt says when it frees up |
Notes
- Each test counts against the day's calls and deployments (50 deployments per day per workspace).
- If the response is
SECRET_MISSING,details.hintsays which secret is missing: bind it with Bind a secret and test again. EGRESS_DENIEDmeans the code called a domain that is not inallowedDomains. Add it with Update a function.- To check the published version instead of the draft, use Run a function.