Verify a function

SDK platic.tools.functions.verify()

Compile and review the code without running it. Check size, syntax, types, allowed packages, forbidden APIs, bundling, input schema, and declared domains. The result is saved in lastVerify.

Example

await platic.tools.functions.verify("fn_123");

Path parameters

ParameterTypeDescriptionRequired
functionIdstringFunction ID✓

Request body

Optional.

{
  "source": "import { z } from \"zod\";\nimport { defineFunction } from \"@platica/functions\";\n\nexport default defineFunction({ … });\n"
}
FieldTypeDescriptionRequired
sourcestringVerifies this code instead of the saved draft, without saving it—

Response

Check ok: a failed verification returns HTTP 200 with ok: false.

{
  "status": "success",
  "data": {
    "ok": false,
    "issues": [
      {
        "stage": "deny",
        "code": "FORBIDDEN_GLOBAL",
        "message": "No se permite usar process",
        "line": 7
      }
    ],
    "nextStep": "Fix each issue (stage, line, message) in source with PATCH /v1/tools/functions/Hk2s9QmXc1, or send the fixed source to POST /v1/tools/functions/Hk2s9QmXc1/verify first, and verify again."
  }
}

When it passes:

{
  "status": "success",
  "data": {
    "ok": true,
    "issues": [],
    "inputSchema": {
      "type": "object",
      "properties": {
        "taxId": { "type": "string", "description": "Customer tax ID, 12 or 13 characters" }
      },
      "required": ["taxId"]
    },
    "checksum": "sha256-3f1c9a…",
    "nextStep": "Verified. Try it with POST /v1/tools/functions/Hk2s9QmXc1/test and a sample input, then publish it with POST /v1/tools/functions/Hk2s9QmXc1/publish."
  }
}

Response fields

FieldTypeDescription
okbooleanWhether the code passed
issuesarrayEach problem with stage, code, message (in Spanish) and, when it applies, line and column
inputSchemaobjectThe JSON Schema the agent will see, taken from the input schema
checksumstringFingerprint of the verified code
nextStepstringText in English that says what comes next. Do not program against its wording

Stages

Stages run in this order; stage says which one found the problem.

stageWhat it reviews
sizeThat the code is not over 100 KB
parseThat the syntax is valid
typecheckThe TypeScript types
importsThat it only imports allowed packages
denyThat it does not use forbidden APIs, such as process, eval or the global fetch
bundleThat it can be bundled in 1 MB or less
schemaThat input is a zod schema that can be converted to JSON Schema
domainsThat the domains and the secrets' origins are valid

Errors

Statusdetails.codeWhen
400INVALID_REQUESTThe body fails validation. 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

Notes

  • Verifying does not run anything or call any domain, and does not count against calls or deployments.
  • Test and publish verify again before deploying.