/v1/actions/{actionId}/definitionWhen to use
Save action code, contracts, permissions, and source bindings together.
For agents
Requires business_action.update_draft plus Read on each selected database, warehouse source, connector, and declared SDK resource. Saving does not execute or delegate capabilities. Publishing through client.revisions requires Publish and source Admin. Database bindings pin published schema revisions and declared readTables/writeTables; db.read supports equality-filtered server-side reads. Optional connectors maps names to connector IDs; handlers use connectors.<name>.request, query, or putObject according to the provider. Each external call needs a stable stepId. Handlers can also call llm({ prompt, system?, outputSchema? }) at most 10 times per run when the definition sets llm: true; without it, calls fail.
Example
import { PermuteClient } from '@permute/sdk';
const orgClient = new PermuteClient({
apiKey: process.env.PERMUTE_API_KEY!,
});
const client = orgClient.withWorkspace(process.env.PERMUTE_WORKSPACE_ID!);
const result = await client.actions.saveDefinition('actn_abcdefghijklmnopqrstuvwx', {
"expectedDraft": null,
"definition": {
"source": "exports.handler = ({ input, db }) => { db.insert('contacts', input); return input; };",
"inputSchema": {
"type": "object"
},
"outputSchema": {
"type": "object"
},
"invokePermission": "write",
"sources": [
{
"sourceId": "dbas_crm123",
"revisionId": "rvsn_schema123",
"readTables": [],
"writeTables": [
"contacts"
]
}
]
}
});Request body
{
"expectedDraft": null,
"definition": {
"source": "exports.handler = ({ input, db }) => { db.insert('contacts', input); return input; };",
"inputSchema": {
"type": "object"
},
"outputSchema": {
"type": "object"
},
"invokePermission": "write",
"sources": [
{
"sourceId": "dbas_crm123",
"revisionId": "rvsn_schema123",
"readTables": [],
"writeTables": [
"contacts"
]
}
]
}
}Response
{
"data": {
"revisionId": "rvsn_action123"
}
}