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

# Replace sequence steps

> Replaces the editable step list for a draft or paused sequence. Omitted existing steps are deleted; steps without `id` are created. Use `client_key` to reference newly-created branch steps from `parent_step_id`. Pending paused tasks are synchronized before resume.



## OpenAPI

````yaml /openapi.yaml put /sequences/{id}/steps
openapi: 3.0.3
info:
  title: Leonar API
  description: >
    REST API for accessing and managing workspace data in Leonar CRM.


    ## Authentication


    All API requests require a Bearer token in the Authorization header:


    ```

    Authorization: Bearer leo_xxxxx

    ```


    API keys can be created and managed in Settings > API.


    ## Rate limiting


    - **2000 requests per hour by default**, configurable per workspace and
    shared by all API keys owned by the same user

    - Rate limit headers are included in all responses


    ## Pagination


    List endpoints support pagination via `limit` and `offset` query parameters.
  version: 1.0.0
  contact:
    name: Leonar Support
    url: https://leonar.ai
    email: support@leonar.ai
servers:
  - url: https://app.leonar.app/api/v1
    description: Production
security:
  - BearerAuth: []
tags:
  - name: Contacts
    description: Manage contacts in your workspace
  - name: Companies
    description: Manage companies and their relationships
  - name: Deals
    description: Track and manage sales deals
  - name: Deal Pipelines
    description: View deal pipeline configurations
  - name: Projects
    description: Organize recruiting projects
  - name: Pipeline Entries
    description: Manage candidates in project pipelines
  - name: Tasks
    description: Track to-dos and follow-ups
  - name: Tags
    description: Organize resources with tags
  - name: Notes
    description: Manage notes on contacts, companies, deals, and projects
  - name: Sequences
    description: Automate outreach campaigns
  - name: Conversations
    description: View conversations across channels
  - name: Messages
    description: Send messages via email, LinkedIn, or WhatsApp
  - name: Enrichment
    description: Find emails and phone numbers for contacts
  - name: Sourcing
    description: Search and import candidates
  - name: Connected Accounts
    description: View linked LinkedIn accounts
paths:
  /sequences/{id}/steps:
    put:
      tags:
        - Sequences
      summary: Replace sequence steps
      description: >-
        Replaces the editable step list for a draft or paused sequence. Omitted
        existing steps are deleted; steps without `id` are created. Use
        `client_key` to reference newly-created branch steps from
        `parent_step_id`. Pending paused tasks are synchronized before resume.
      operationId: replace-sequence-steps
      parameters:
        - $ref: '#/components/parameters/sequenceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SequenceStepsReplace'
      responses:
        '200':
          description: Updated sequence steps
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/SequenceStep'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: >-
            Sequence is active/archived, or a removed step still has pending
            tasks
components:
  parameters:
    sequenceId:
      name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Sequence ID
  schemas:
    SequenceStepsReplace:
      type: object
      required:
        - steps
      properties:
        steps:
          type: array
          maxItems: 100
          items:
            $ref: '#/components/schemas/SequenceStepInput'
    SequenceStep:
      type: object
      properties:
        id:
          type: string
          format: uuid
        sequence_id:
          type: string
          format: uuid
        step_order:
          type: integer
        step_type:
          type: string
          enum:
            - linkedin_invitation
            - linkedin_message
            - linkedin_inmail
            - linkedin_voice
            - linkedin_profile_view
            - email
            - whatsapp
            - sms
            - call
            - email_enrichment
            - phone_enrichment
            - manual_step
        type:
          type: string
          description: Alias of `step_type`.
        delay_days:
          type: integer
        delay_hours:
          type: integer
        name:
          type: string
          nullable: true
        subject:
          type: string
          nullable: true
        body:
          type: string
          nullable: true
        content_template:
          type: object
          additionalProperties: true
          description: >-
            For `linkedin_voice`, must contain exactly one audio attachment with
            `kind: voice_note`.
        sender_config:
          type: object
          additionalProperties: true
          nullable: true
        parent_step_id:
          type: string
          format: uuid
          nullable: true
        branch_condition:
          type: object
          additionalProperties: true
          nullable: true
        entry_conditions:
          type: object
          additionalProperties: true
          nullable: true
        execution_mode:
          type: string
          enum:
            - automatic
            - manual
          nullable: true
        ab_variant_of:
          type: string
          format: uuid
          nullable: true
        created_at:
          type: string
          format: date-time
          nullable: true
    SequenceStepInput:
      type: object
      required:
        - type
      properties:
        id:
          type: string
          format: uuid
          description: Existing step ID. Omit to create a new step.
        client_key:
          type: string
          description: >-
            Temporary key for referencing new steps from `parent_step_id` or
            `ab_variant_of`.
        step_order:
          type: integer
          minimum: 1
        type:
          type: string
          enum:
            - linkedin_invitation
            - linkedin_message
            - linkedin_inmail
            - linkedin_voice
            - linkedin_profile_view
            - email
            - whatsapp
            - sms
            - call
            - email_enrichment
            - phone_enrichment
            - manual_step
        name:
          type: string
          nullable: true
        subject:
          type: string
          nullable: true
        body:
          type: string
          nullable: true
        content_template:
          type: object
          additionalProperties: true
          description: >-
            For `linkedin_voice`, must contain exactly one audio attachment with
            `kind: voice_note`.
          properties:
            name:
              type: string
            subject:
              type: string
            body:
              type: string
            attachments:
              type: array
              maxItems: 5
              items:
                $ref: '#/components/schemas/SequenceAttachment'
        delay_days:
          type: integer
          minimum: 0
          maximum: 365
          default: 0
        delay_hours:
          type: integer
          minimum: 0
          maximum: 8760
          default: 0
          description: >-
            Hours to wait before this step. Values up to one year are accepted
            for legacy sequence compatibility.
        execution_mode:
          type: string
          enum:
            - automatic
            - manual
          nullable: true
          default: automatic
        sender_ids:
          type: array
          items:
            type: string
            format: uuid
        sender_config:
          type: object
          additionalProperties: true
          nullable: true
        parent_step_id:
          type: string
          description: Existing step ID or a `client_key` from this request.
          nullable: true
        branch_condition:
          type: object
          additionalProperties: true
          nullable: true
        entry_conditions:
          type: object
          additionalProperties: true
          nullable: true
        ab_variant_of:
          type: string
          description: Existing step ID or a `client_key` from this request.
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - invalid_api_key
                - insufficient_scope
                - rate_limit_exceeded
                - validation_error
                - not_found
                - internal_error
                - billing_required
                - plan_upgrade_required
              description: >
                Error codes:

                - `invalid_api_key` — API key is missing, malformed, or revoked

                - `insufficient_scope` — API key lacks the required scope for
                this endpoint

                - `rate_limit_exceeded` — Too many requests (2000/hour)

                - `validation_error` — Request body or parameters failed
                validation

                - `not_found` — The requested resource does not exist

                - `internal_error` — Unexpected server error

                - `billing_required` — Workspace has no active subscription

                - `plan_upgrade_required` — Current plan does not include this
                feature
            message:
              type: string
              description: Human-readable error description
    SequenceAttachment:
      type: object
      required:
        - id
        - filename
        - url
        - contentType
        - size
      properties:
        id:
          type: string
          format: uuid
        filename:
          type: string
        url:
          type: string
          description: Workspace-scoped path returned by the attachment upload endpoint.
        contentType:
          type: string
        size:
          type: integer
          maximum: 15728640
        kind:
          type: string
          enum:
            - file
  responses:
    ValidationError:
      description: Invalid request data
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: validation_error
              message: Invalid input
    Unauthorized:
      description: Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: invalid_api_key
              message: Invalid API key
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: not_found
              message: Resource not found
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key starting with `leo_`

````