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

await platic.tools.functions.test("fn_123", { input: { rfc: "XAXX010101000" } });

Path parameters

ParameterTypeDescriptionRequired
functionIdstringFunction ID✓

Request body

{
  "input": { "taxId": "XAXX010101000" }
}
FieldTypeDescriptionRequired
inputobjectSample input that meets the function's input schema. Up to 256 KB—
sourcestringTests 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

FieldTypeDescription
okbooleanWhether the execution finished well
outputanyWhat run returned, when ok is true. Up to 256 KB; the agent reads up to 16,000 characters
errorobjectWhen ok is false: code and message. See errors inside an execution
durationMsintegerDuration of the execution
logsstring[]What the code wrote with log
httpCallsarrayEach call with method, host, status and durationMs
runIdstringExecution ID, which stays in the executions with trigger: "test"
versionstring"draft" in a test
nextStepstringText in English that says what comes next. Do not program against its wording

Errors

Statusdetails.codeWhen
400INVALID_REQUESTThe body fails validation or has secrets. details.issues has the list of problems
403FORBIDDEN or INSUFFICIENT_SCOPEThe credential does not have write access to Integrations
404NOT_FOUNDThe function does not exist in this workspace
422VALIDATION_FAILEDThe code does not pass verification. details.issues has each problem
429LIMIT_REACHEDThe 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.hint says which secret is missing: bind it with Bind a secret and test again.
  • EGRESS_DENIED means the code called a domain that is not in allowedDomains. Add it with Update a function.
  • To check the published version instead of the draft, use Run a function.