Guides/How to create an automation via API

How to create an automation via API

HTTP trigger, respond step, test run, execution logs.

Updated March 2026

Sutrena automations are declarative pipelines with 14 step types. This guide walks through creating your first automation: an HTTP trigger that responds with JSON. You will create the automation, test it, trigger it via its public URL, and check the execution logs. No code to deploy, no infrastructure to manage.

1. Get an API key

POST to /api/trial for an instant key, or use an existing st_live_ key. The key authenticates all management operations. The automation's HTTP trigger URL is public and needs no key.

curl -X POST https://sutrena.com/api/trial

# Response:
# {
#   "data": {
#     "key": "st_trial_abc123...",
#     "subdomain": "site-a1b2c3d4",
#     "subdomainUrl": "https://site-a1b2c3d4.sutrena.com"
#   }
# }

2. Create the automation

POST to /api/automations with a name, slug, trigger, and steps array. The slug becomes the URL path for HTTP triggers. This example creates a simple endpoint that echoes back the request method.

curl -X POST https://sutrena.com/api/automations \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Hello API",
    "slug": "hello",
    "trigger": { "type": "http" },
    "steps": [
      {
        "type": "set",
        "name": "greeting",
        "value": "Hello from Sutrena automation"
      },
      {
        "type": "respond",
        "statusCode": 200,
        "body": {
          "message": "{{steps.greeting}}",
          "method": "{{trigger.method}}"
        }
      }
    ]
  }'

# Response:
# {
#   "data": {
#     "id": "aut_uuid",
#     "name": "Hello API",
#     "slug": "hello",
#     "trigger": { "type": "http" },
#     "enabled": true,
#     "triggerUrl": "https://site-a1b2c3d4.sutrena.com/fn/hello"
#   }
# }

3. Test the automation

POST to /api/automations/:id/test to execute the automation without incrementing run counters or writing logs. This lets you verify the pipeline works before real traffic hits it.

curl -X POST https://sutrena.com/api/automations/AUTOMATION_ID/test \
  -H "Authorization: Bearer $KEY"

# Response:
# {
#   "data": {
#     "status": "success",
#     "stepsExecuted": 2,
#     "durationMs": 12
#   }
# }

4. Trigger it via the public URL

The HTTP trigger exposes a public endpoint at subdomain.sutrena.com/fn/{slug}. No authentication required. Accepts any HTTP method. The trigger data includes method, headers, query params, and body.

# GET request
curl https://site-a1b2c3d4.sutrena.com/fn/hello

# POST request with body
curl -X POST https://site-a1b2c3d4.sutrena.com/fn/hello \
  -H "Content-Type: application/json" \
  -d '{"name": "world"}'

# Response:
# {
#   "message": "Hello from Sutrena automation",
#   "method": "POST"
# }

5. Check execution logs

GET /api/automations/:id/logs returns recent execution history. Each log entry includes the trigger source, status, steps executed, duration, and any errors.

curl https://sutrena.com/api/automations/AUTOMATION_ID/logs \
  -H "Authorization: Bearer $KEY"

# Response:
# {
#   "data": [
#     {
#       "id": "1",
#       "triggeredBy": "http",
#       "status": "success",
#       "stepsExecuted": 2,
#       "durationMs": 15,
#       "error": null,
#       "createdAt": "2026-03-13T..."
#     }
#   ]
# }

FAQ

Can I use environment variables in automations?

Yes. Add an env object to the automation with key-value pairs. Reference them in steps with {{env.KEY}}. Values are encrypted at rest using AES-256-GCM and decrypted only during execution. Use them for API keys, tokens, and secrets.

What happens if a step fails?

Execution stops at the failing step. The log entry records status as 'error' with the error message and the number of steps that completed before the failure. No rollback -- completed steps are not undone.

Can I branch based on conditions?

Yes. Use a condition step with an if expression and then/else step arrays. Example: { "type": "condition", "if": "{{trigger.body.plan}} == pro", "then": [...steps], "else": [...steps] }.

How many automations can I create?

Free: 3 automations, 500 runs/month. Pro: 25 automations, 10,000 runs/month. Scale: unlimited automations, runs scale to 100K/month.

Can I update an automation without downtime?

Yes. PUT /api/automations/:id updates the automation in place. The next trigger invocation uses the new definition. There is no deploy step and no downtime.

What is Sutrena?

Sutrena is the web runtime for AI agents. Forms, Pages, Dashboards, Analytics, Webhooks, Automations, Emails — all through 75 MCP tools and one REST API. Your agent creates web artifacts, humans interact with them, and your agent gets the data back. Use any one feature or all of them together.

Pages

Deploy HTML instantly

Forms

Collect structured data

Dashboards

Visualize with 7 widget types

Analytics

Privacy-first, no cookies

Webhooks

Slack, Discord, Telegram

Get started in two API calls

1. Get a trial key (no auth, no signup)

curl -X POST https://sutrena.com/api/trial

2. Create anything — a page, form, dashboard, or analytics site

# Create a form with a dashboard
curl -X POST https://sutrena.com/api/forms \
  -H "Authorization: Bearer st_trial_xxx" \
  -H "Content-Type: application/json" \
  -d '{"workflowId": "waitlist", "createDashboard": true}'

# Or deploy a page
curl -X POST https://sutrena.com/api/pages \
  -H "Authorization: Bearer st_trial_xxx" \
  -H "Content-Type: application/json" \
  -d '{"slug": "index", "title": "My Site", "html": "<h1>Live</h1>"}'

Ready to build?

Get a trial API key instantly with no signup, or create an account for the full experience.

Create an automation via API -- HTTP trigger, respond step, logs | Sutrena | Sutrena