---
title: "Write a script for a step"
method: POST
path: "/v1/processes/{id}/steps/{stepId}/script/draft"
tags: ["Processes"]
---

# Write a script for a step

`POST /v1/processes/{id}/steps/{stepId}/script/draft`

## Request

- Base URL: `https://api.talonic.com`
- URL: `https://api.talonic.com/v1/processes/{id}/steps/{stepId}/script/draft`
- Auth: HTTP bearer

A script for what the step should do, with its `hash`. Saves nothing: put it on the step with `PUT /v1/processes/{id}/draft`, then test it. The step must name the fields it writes. Uses credits. Needs process_build and the `processes:write` scope.

## Path parameters

- `id` string, uuid, required
- `stepId` string, required

## Request body

- object
  - `purpose` string, required

## Response `201`

`{ lua, hash, explanation }`.

## Other responses

- `403`: The key has no person, the person lacks the Process Plane permission, or the key lacks the scope.
- `404`: The requested resource was not found.
- `422`: The step writes no fields yet, or no script could be written.
- `503`: Script writing is unavailable for the moment; try again.

## Changes

- **2026-11-26** `622d429de7ea`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/talonic/apis/talonic-api/changes/v1/processes/:id/steps/:stepId/script/draft/post.md)

---

[API](https://skmtc.dev/talonic/apis/talonic-api.md) - [All operations](https://skmtc.dev/talonic/apis/talonic-api/llms.txt) - [OpenAPI document](https://skmtc.dev/talonic/apis/talonic-api/revisions/9f6d53e2ab5e?raw)
