> ## Documentation Index
> Fetch the complete documentation index at: https://docs.posttu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upsert workflow step

> Add a new action step or update an existing step in a workflow draft.

Adds a new step node or updates an existing step node within a workflow draft canvas. Settings fields can use Mustache dynamic expressions (e.g. `{{trigger.body.text}}`, `{{steps.step_1.data}}`) to reference outputs from previous nodes.

### Path Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | **Yes** | Unique identifier of the workflow (`wkf_...`). |

### Request Body

| Field | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | **Yes** | Action piece type (e.g. `ai_ask_ai`, `x_create_post`, `http_request`, `condition`, `loop`, `delay`, `code`). |
| `displayName` | `string` | **Yes** | Human-readable label displayed on canvas node. |
| `stepId` | `string` | No | Target step ID to update. Omit to add a new step node. |
| `settings` | `object` | No | Action configuration properties and `{{...}}` expressions. |
| `parentStepId` | `string` | No | ID of parent container step (e.g. `condition` or `loop`). |
| `branchId` | `string` | No | Target branch ID if placing step inside a conditional router branch (e.g. `branch_1`, `otherwise`). |
| `afterStepId` | `string` | No | ID of preceding step in the linked list graph sequence to insert after. Downstream steps are automatically relinked. |
| `previousStepId` | `string` | No | Explicit previous step pointer in the sequence. |
| `canvasPosition` | `object` | No | Optional `{ "x": 100, "y": 200 }` canvas coordinates for UI rendering. |

### cURL Example (Add AI Summarizer Step)

```bash theme={null}
curl -X POST "https://posttu.com/api/v1/workflow/wkf_abc123/step" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "ai_ask_ai",
    "displayName": "Generate Tweet Summary",
    "settings": {
      "prompt": "Summarize this article into a compelling 280-character post: {{trigger.item.description}}",
      "model": "gpt-4o"
    }
  }'
```

### Response Example

```json theme={null}
{
  "data": {
    "id": "step_789xyz",
    "versionId": "ver_draft_101",
    "name": "ai_ask_ai",
    "displayName": "Generate Tweet Summary",
    "settings": {
      "prompt": "Summarize this article into a compelling 280-character post: {{trigger.item.description}}",
      "model": "gpt-4o"
    },
    "parentStepId": null,
    "branchId": null,
    "previousStepId": null,
    "createdAt": "2026-07-29T22:19:00.000Z"
  },
  "success": true
}
```


## OpenAPI

````yaml openapi.json POST /api/v1/workflow/{id}/step
openapi: 3.1.0
info:
  title: Posttu API
  version: 1.0.0
  description: >-
    Posttu V1 REST API — Workflow automation, social-media post management,
    inbox, tags, and calendar.
servers:
  - url: https://posttu.com
    description: Production
security: []
paths:
  /api/v1/workflow/{id}/step:
    post:
      tags:
        - Workflow
      summary: Upsert a workflow step
      parameters:
        - schema:
            type: string
            description: Workflow ID
            example: wkf_123abc
          required: true
          description: Workflow ID
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpsertWorkflowStep'
      responses:
        '200':
          description: Step details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowStepResponse'
        '401':
          description: Error response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
      security:
        - ApiKeyAuth: []
components:
  schemas:
    UpsertWorkflowStep:
      type: object
      properties:
        workflowId:
          type: string
          description: Workflow ID
          example: wkf_123abc
        stepId:
          type: string
          description: Step ID (for update)
          example: step_456xyz
        name:
          type: string
          description: Step name
          example: sendNotification
        displayName:
          type: string
          description: Step display name
          example: Send Notification
        settings:
          type: object
          additionalProperties: {}
          default: {}
          description: Step settings
        parentStepId:
          type:
            - string
            - 'null'
          description: Parent step ID
        branchId:
          type:
            - string
            - 'null'
          description: Branch ID if placing step inside a conditional branch
          example: branch_1
        afterStepId:
          type:
            - string
            - 'null'
          description: Preceding step ID in the linked list graph sequence
          example: step_123
        previousStepId:
          type:
            - string
            - 'null'
          description: Previous step ID in the linked list
          example: step_123
        canvasPosition:
          type:
            - object
            - 'null'
          properties:
            x:
              type: number
              example: 100
            'y':
              type: number
              example: 200
          required:
            - x
            - 'y'
          description: Canvas position for UI
      required:
        - workflowId
        - name
        - displayName
    WorkflowStepResponse:
      allOf:
        - $ref: '#/components/schemas/WorkflowStep'
        - type: object
          properties:
            workflowId:
              type: string
              description: Workflow ID
          required:
            - workflowId
    WorkflowStep:
      type: object
      properties:
        id:
          type: string
          description: Step ID
          example: step_xyz789
        name:
          type: string
          description: Step name
          example: sendMessage
        displayName:
          type: string
          description: Step display name
          example: Send Message
        settings:
          type: object
          additionalProperties: {}
          description: Step settings
        parentStepId:
          type:
            - string
            - 'null'
          description: Parent step ID
        branchId:
          type:
            - string
            - 'null'
          description: Branch ID
        previousStepId:
          type:
            - string
            - 'null'
          description: Previous step ID
        isSkipped:
          type: boolean
          description: Skip during execution
          example: false
        canvasPosition:
          type:
            - object
            - 'null'
          properties:
            x:
              type: number
              example: 100
            'y':
              type: number
              example: 200
          required:
            - x
            - 'y'
          description: Canvas position
      required:
        - id
        - name
        - displayName
        - settings
        - isSkipped
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      description: 'Pass your API key via the Authorization header: `Bearer <api-key>`'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.