Skip to content
Anlyon
Esc
↑↓navigate↵open⌘Jpreview

Create a function

A named function in the key’s environment. It runs nothing until a version is published.

POST/api/v2/functions
Authorization
AuthorizationBearer token (Anlyon API key) · headerrequired

Workspace API key sent as Authorization: Bearer <key>.

or
better-auth.session_tokenAPI key · cookierequired

Browser session used by dashboard-only operations.

Header parameters
X-Request-Idstring

Optional caller correlation ID. Unsafe or oversized values are replaced.

max length 128
Request body
requiredapplication/json
namestringrequired
min length 1 · max length 100 · matches ^[a-zA-Z0-9_-]+$
descriptionstring
max length 1000
Responses
201

The function.

successbooleanrequired
Allowed:true
dataFunctionrequired
Show properties
idstringrequired
namestringrequired
descriptionstring | nullrequired
environmentIdstring<uuid>required
currentVersionFunctionVersion | nullrequired

Null until the first publish.

Show properties
Any of:
FunctionVersion
idstringrequired

The version id.

versionintegerrequired
min 1
languagestringrequired
Allowed:javascriptpython
digeststringrequired

SHA-256 of the source.

allowedActionsstring[]required
inputSchemaobjectrequired
budgetsobjectrequired
Show properties
maxActionCallsintegerrequired
maxCpuMsintegerrequired
maxSubrequestsintegerrequired
timeoutMsintegerrequired
straightThroughFunctionStraightThroughPolicy | nullrequired
Show properties
Any of:
FunctionStraightThroughPolicy
actionsstring[]required

Allowed actions a straight-through run may write to. Each must be in allowedActions.

min items 1 · max items 100
maxWritesintegerrequired

Writes in one straight-through run.

min 1 · max 500
null
null
reviewFunctionVersionReview | nullrequired
Show properties
Any of:
FunctionVersionReview
astFunctionSourceFindingsrequired

What the source says it calls and uses, read from its syntax tree. Advice for people; what a run may call is the version's allowedActions.

Show properties
languagestringrequired
Allowed:javascriptpython
parsedbooleanrequired
parseErrorstring | nullrequired
callsobject[]required
Show properties
Array of object
kindstringrequired
Allowed:invokeread
actionstringrequired
lineintegerrequired
proposedAllowedActionsstring[]required
computedActionNamesobject[]required
Show properties
Array of object
kindstringrequired
Allowed:invokeread
lineintegerrequired
riskyobject[]required

Network, file, process, environment and eval APIs. They fail inside a function anyway.

Show properties
Array of object
apistringrequired
categorystringrequired
Allowed:networkfileprocessenvironmenteval
lineintegerrequired
writesInLoopobject[]required
Show properties
Array of object
actionstring | nullrequired
lineintegerrequired
aiobject | nullrequired

The AI review, for a workspace with Anlyon Vigil on. Null until it is done.

Show properties
statusstringrequired
Allowed:reviewedskippedfailed
reasonstring | nullrequired
modelstring | nullrequired
summarystring | nullrequired
purposestring | nullrequired
Allowed:refundspaymentsmessagesrecordsaccountslookupsother
riskyPatternsobject[]required
Show properties
Array of object
patternstringrequired
Allowed:writes_in_loopmoney_per_itemamount_from_inputunchecked_write
descriptionstringrequired
probabilitynumberrequired
min 0 · max 1
suggestedRiskTierstring | nullrequired
Allowed:routinelowmoderatehighcritical
confidencenumber | nullrequired
min 0 · max 1
truncatedbooleanrequired
reviewedAtstring<date-time>required
null
null
createdAtstring<date-time>required
null
null
createdAtstring<date-time>required
updatedAtstring<date-time>required
400

Bad Request - Invalid input data

successbooleanrequired
requestIdstringrequired

Correlation ID matching the X-Request-Id response header.

errorobjectrequired
Show properties
codestring
messagestring
detailsobject
fixErrorFix

How to get past this error, for a person or an agent. Present on refusals with a known next step, such as a missing scope or role, a plan or billing limit, a halted environment, or a missing secret, connected account, OAuth app or end-user header. Absent when there is no fix to give. Kept in production responses, unlike details.

Show properties
summarystringrequired

One sentence that says what to do.

commandstring

An exact anlyon CLI command that fixes it. Absent when no command does.

urlstring<uri>

An absolute console link where a person fixes it.

docsstring<uri>

A docs page that explains it.

401

Unauthorized - Invalid or missing API key

successbooleanrequired
requestIdstringrequired

Correlation ID matching the X-Request-Id response header.

errorobjectrequired
Show properties
codestring
messagestring
detailsobject
fixErrorFix

How to get past this error, for a person or an agent. Present on refusals with a known next step, such as a missing scope or role, a plan or billing limit, a halted environment, or a missing secret, connected account, OAuth app or end-user header. Absent when there is no fix to give. Kept in production responses, unlike details.

Show properties
summarystringrequired

One sentence that says what to do.

commandstring

An exact anlyon CLI command that fixes it. Absent when no command does.

urlstring<uri>

An absolute console link where a person fixes it.

docsstring<uri>

A docs page that explains it.

403

Authenticated credential lacks the required scope or workspace access.

successbooleanrequired
requestIdstringrequired

Correlation ID matching the X-Request-Id response header.

errorobjectrequired
Show properties
codestring
messagestring
detailsobject
fixErrorFix

How to get past this error, for a person or an agent. Present on refusals with a known next step, such as a missing scope or role, a plan or billing limit, a halted environment, or a missing secret, connected account, OAuth app or end-user header. Absent when there is no fix to give. Kept in production responses, unlike details.

Show properties
summarystringrequired

One sentence that says what to do.

commandstring

An exact anlyon CLI command that fixes it. Absent when no command does.

urlstring<uri>

An absolute console link where a person fixes it.

docsstring<uri>

A docs page that explains it.

404

Not Found - Resource does not exist

successbooleanrequired
requestIdstringrequired

Correlation ID matching the X-Request-Id response header.

errorobjectrequired
Show properties
codestring
messagestring
detailsobject
fixErrorFix

How to get past this error, for a person or an agent. Present on refusals with a known next step, such as a missing scope or role, a plan or billing limit, a halted environment, or a missing secret, connected account, OAuth app or end-user header. Absent when there is no fix to give. Kept in production responses, unlike details.

Show properties
summarystringrequired

One sentence that says what to do.

commandstring

An exact anlyon CLI command that fixes it. Absent when no command does.

urlstring<uri>

An absolute console link where a person fixes it.

docsstring<uri>

A docs page that explains it.

409

The request conflicts with current resource state or a concurrent decision.

successbooleanrequired
requestIdstringrequired

Correlation ID matching the X-Request-Id response header.

errorobjectrequired
Show properties
codestring
messagestring
detailsobject
fixErrorFix

How to get past this error, for a person or an agent. Present on refusals with a known next step, such as a missing scope or role, a plan or billing limit, a halted environment, or a missing secret, connected account, OAuth app or end-user header. Absent when there is no fix to give. Kept in production responses, unlike details.

Show properties
summarystringrequired

One sentence that says what to do.

commandstring

An exact anlyon CLI command that fixes it. Absent when no command does.

urlstring<uri>

An absolute console link where a person fixes it.

docsstring<uri>

A docs page that explains it.

429

Too Many Requests - Rate limit exceeded. A workspace's API requests are limited per minute and per UTC clock hour by plan; Retry-After says when to try again, and an hourly refusal names the limit and when the count resets. Successful responses carry the same limits in X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset (the minute) and X-RateLimit-Limit-Hour, X-RateLimit-Remaining-Hour, X-RateLimit-Reset-Hour (the hour).

successbooleanrequired
requestIdstringrequired

Correlation ID matching the X-Request-Id response header.

errorobjectrequired
Show properties
codestring
messagestring
detailsobject
fixErrorFix

How to get past this error, for a person or an agent. Present on refusals with a known next step, such as a missing scope or role, a plan or billing limit, a halted environment, or a missing secret, connected account, OAuth app or end-user header. Absent when there is no fix to give. Kept in production responses, unlike details.

Show properties
summarystringrequired

One sentence that says what to do.

commandstring

An exact anlyon CLI command that fixes it. Absent when no command does.

urlstring<uri>

An absolute console link where a person fixes it.

docsstring<uri>

A docs page that explains it.

Try it
Server
Authorization
Parameters
Bodyapplication/json
Request
curl -X POST 'https://api.anlyon.com/api/v2/functions' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "refund-with-checks",
  "description": "Refund an order after checking it was paid."
}'
Response
{
  "success": true,
  "data": {
    "id": "fn_V1StGXR8_Z5jdHi6B-myT",
    "name": "refund-with-checks",
    "description": "string",
    "environmentId": "19f5cc2e-7657-437a-9268-83cd3d563563",
    "currentVersion": {
      "id": "fnv_V1StGXR8_Z5jdHi6B-myT",
      "version": 1,
      "language": "javascript",
      "digest": "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
      "allowedActions": [
        "lookup-order",
        "refund"
      ],
      "inputSchema": {},
      "budgets": {
        "maxActionCalls": 50,
        "maxCpuMs": 1000,
        "maxSubrequests": 100,
        "timeoutMs": 30000
      },
      "straightThrough": {
        "actions": [
          "send-receipt"
        ],
        "maxWrites": 1
      },
      "review": {
        "ast": {
          "language": "javascript",
          "parsed": true,
          "parseError": "string",
          "calls": [
            {
              "kind": "invoke",
              "action": "refund",
              "line": 5
            }
          ],
          "proposedAllowedActions": [
            "lookup-order",
            "refund"
          ],
          "computedActionNames": [
            {
              "kind": "invoke",
              "line": 0
            }
          ],
          "risky": [
            {
              "api": "fetch",
              "category": "network",
              "line": 0
            }
          ],
          "writesInLoop": [
            {
              "action": "string",
              "line": 0
            }
          ]
        },
        "ai": {
          "status": "reviewed",
          "reason": "assistant_disabled",
          "model": "vigil-1",
          "summary": "string",
          "purpose": "refunds",
          "riskyPatterns": [
            {
              "pattern": "writes_in_loop",
              "description": "string",
              "probability": 0
            }
          ],
          "suggestedRiskTier": "routine",
          "confidence": 0,
          "truncated": true,
          "reviewedAt": "2019-08-24T14:15:22Z"
        }
      },
      "createdAt": "2019-08-24T14:15:22Z"
    },
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z"
  }
}