Skip to main content
POST
/
v1
/
account
/
{accountSlug}
/
project
/
{projectSlug}
/
actions
/
publishFile
cURL
# Block Web3 Action
curl 'https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/actions/publishFile' \
  -H 'X-Access-Key: ${TENDERLY_ACCESS_KEY}' \
  -H 'content-type: application/json' \
  --data-raw $'{"action":{"name":"block-action","description":"Triggers on every 10th block on ETH Mainnet and Polygon.","source":"// Do not change function name.\\nconst actionFn = async (context, blockEvent) => {\\n    console.log(blockEvent)\\n\\n    // To access project\'s secret\\n    // let secret = await context.secrets.get(\'MY-SECRET\')\\n\\n    // To access project\'s storage\\n    // let value = await context.storage.getStr(\'MY-KEY\')\\n    // await context.storage.putStr(\'MY-KEY\', \'MY-VALUE\')\\n\\n    // Your logic goes here :)\\n}\\n// Do not change this.\\nmodule.exports = { actionFn }","triggerType":"BLOCK","runtime":"V2","function":"actionFn","invocationType":"ASYNC","trigger":{"type":"block","block":{"network":["1","137"],"blocks":10}}},"deploy":true}' \
  --compressed

# Periodic Web3 Action
curl 'https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/actions/publishFile' \
  -H 'X-Access-Key: ${TENDERLY_ACCESS_KEY}' \
  -H 'content-type: application/json' \
  --data-raw $'{"action":{"name":"periodic-1hour","description":"CRON job triggered every 1 hour","source":"// Do not change function name.\\nconst actionFn = async (context, periodicEvent) => {\\n    console.log(periodicEvent)\\n\\n    // To access project\'s secret\\n    // let secret = await context.secrets.get(\'MY-SECRET\')\\n\\n    // To access project\'s storage\\n    // let value = await context.storage.getStr(\'MY-KEY\')\\n    // await context.storage.putStr(\'MY-KEY\', \'MY-VALUE\')\\n\\n    // Your logic goes here :)\\n}\\n// Do not change this.\\nmodule.exports = { actionFn }","triggerType":"PERIODIC","runtime":"V2","function":"actionFn","invocationType":"ASYNC","trigger":{"type":"periodic","periodic":{"cron":"0 * * * *","interval":"1h"}}},"deploy":true}' \
  --compressed

# Webhook Web3 Action
curl 'https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/actions/publishFile' \
  -H 'X-Access-Key: ${TENDERLY_ACCESS_KEY}' \
  -H 'content-type: application/json' \
  --data-raw $'{"action":{"name":"webhook-action","description":"Non-authenticated webhook action. You will be able to make a request without using a valid Tenderly token.","source":"// Do not change function name.\\nconst actionFn = async (context, webhookEvent) => {\\n    console.log(webhookEvent)\\n\\n    // To access project\'s secret\\n    // let secret = await context.secrets.get(\'MY-SECRET\')\\n\\n    // To access project\'s storage\\n    // let value = await context.storage.getStr(\'MY-KEY\')\\n    // await context.storage.putStr(\'MY-KEY\', \'MY-VALUE\')\\n\\n    // Your logic goes here :)\\n}\\n// Do not change this.\\nmodule.exports = { actionFn }","triggerType":"WEBHOOK","runtime":"V2","function":"actionFn","invocationType":"ASYNC","trigger":{"type":"webhook","webhook":{"authenticated":false}}},"deploy":true}' \
  --compressed
{
  "actions": {
    "block-action": {
      "id": "349cbb00-64ad-47ec-bbcb-40bffa28559f",
      "index": 1,
      "actionId": "53712e55-eb77-4ce3-9140-685fd230396a",
      "parentActionId": "",
      "runtime": "V2",
      "function": "implementation:actionFn",
      "triggerType": "BLOCK",
      "trigger": {
        "type": "block",
        "block": {
          "network": [
            "1",
            "137"
          ],
          "blocks": 10
        }
      },
      "commitish": null,
      "source": "// Do not change function name.\nconst actionFn = async (context, blockEvent) => {\n    console.log(blockEvent)\n\n    // To access project's secret\n    // let secret = await context.secrets.get('MY-SECRET')\n\n    // To access project's storage\n    // let value = await context.storage.getStr('MY-KEY')\n    // await context.storage.putStr('MY-KEY', 'MY-VALUE')\n\n    // Your logic goes here :)\n}\n// Do not change this.\nmodule.exports = { actionFn }",
      "createdAt": "2023-12-14T18:47:19.26565Z",
      "deployRequested": true,
      "deployError": null,
      "invocationType": "ASYNC"
    }
  }
}

Authorizations

X-Access-Key
string
header
required

An API key is a token that a client provides when making API calls. The key can be sent as a request header:

curl 'https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/simulate' \
  -H 'X-Access-Key: ${TENDERLY_ACCESS_KEY}' \
  ...

Learn how to generate API access tokens at Tenderly Docs.

Path Parameters

accountSlug
string
required

Account slug of the user

projectSlug
string
required

Project slug of the account

Body

application/json

Create web3 action payload

action
action · object
required

A Web3 Action creation payload.

Example:
{
  "name": "block-action",
  "description": "Triggers on every 10th block on ETH Mainnet and Polygon.",
  "source": "// Do not change function name.\nconst actionFn = async (context, blockEvent) => {\n    console.log(blockEvent)\n\n    // To access project's secret\n    // let secret = await context.secrets.get('MY-SECRET')\n\n    // To access project's storage\n    // let value = await context.storage.getStr('MY-KEY')\n    // await context.storage.putStr('MY-KEY', 'MY-VALUE')\n\n    // Your logic goes here :)\n}\n// Do not change this.\nmodule.exports = { actionFn }",
  "triggerType": "BLOCK",
  "runtime": "V2",
  "function": "actionFn",
  "invocationType": "ASYNC",
  "trigger": {
    "type": "block",
    "block": { "network": ["1", "137"], "blocks": 10 }
  }
}
deploy
boolean
required

Should Web3 Action be immediately deployed.

Example:

true

Response

A successful response.

An object with details about created Web3 Action of Block type.