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

# Move a lead card on the board

> Places the lead between two cards of a stage (`after_lead_id` above it, `before_lead_id` below it), next to a
single given neighbour, or at the bottom of the stage without neighbours. Note the naming is the reverse of
Flowforge's `moveCard` payload, whose `afterCardId` is the card below. A stage change follows the same rules as an update: a lost stage that
mandates a reason answers 422 `LEAD_LOST_REASON_REQUIRED`, and a converted lead cannot change stage
(`LEAD_ALREADY_CONVERTED`). List the board order with `GET /leads?sort_by=position`.



## OpenAPI

````yaml /api-referansi/openapi.json post /v1/leads/{id}/move
openapi: 3.1.0
info:
  title: Flextell API
  version: 0.0.1
  description: >-
    Flextell REST API referansı. Kimlik doğrulama, scope ve istek kuralları için
    API sekmesindeki rehberlere bakın.
servers:
  - url: https://app.flextell.ai/api
    description: Üretim
security:
  - oauth2: []
  - bearer: []
paths:
  /v1/leads/{id}/move:
    post:
      tags:
        - Lead
      summary: Move a lead card on the board
      description: >-
        Places the lead between two cards of a stage (`after_lead_id` above it,
        `before_lead_id` below it), next to a

        single given neighbour, or at the bottom of the stage without
        neighbours. Note the naming is the reverse of

        Flowforge's `moveCard` payload, whose `afterCardId` is the card below. A
        stage change follows the same rules as an update: a lost stage that

        mandates a reason answers 422 `LEAD_LOST_REASON_REQUIRED`, and a
        converted lead cannot change stage

        (`LEAD_ALREADY_CONVERTED`). List the board order with `GET
        /leads?sort_by=position`.
      operationId: lead.move
      parameters:
        - name: id
          in: path
          required: true
          description: The lead identifier
          schema:
            type: integer
        - name: X-Tenant
          in: header
          required: true
          description: >-
            Tenant identifier. Send the Tenant ID in the `X-Tenant` header to
            scope API requests to a specific tenant.
          schema:
            type: number
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LeadMoveRequest'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: string
                  data:
                    $ref: '#/components/schemas/LeadResource'
                required:
                  - success
                  - data
        '401':
          $ref: '#/components/responses/AuthenticationException'
        '403':
          $ref: '#/components/responses/AuthorizationException'
        '404':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  error_code:
                    type: string
                    const: RESOURCE_NOT_FOUND
                  message:
                    type: string
                  errors:
                    type: 'null'
                  data:
                    type: 'null'
                required:
                  - success
                  - error_code
                  - message
                  - errors
                  - data
        '409':
          $ref: '#/components/responses/CustomerErasedException'
        '422':
          $ref: '#/components/responses/ValidationException'
        '428':
          description: >-
            Mandatory setup is incomplete. Finish the setup wizard first;
            `data.next_step` names the step to continue with.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    examples:
                      - false
                  error_code:
                    type: string
                    enum:
                      - SETUP_REQUIRED
                    examples:
                      - SETUP_REQUIRED
                  message:
                    type: string
                    examples:
                      - Complete the required setup steps to continue.
                  data:
                    type: object
                    properties:
                      next_step:
                        type:
                          - string
                          - 'null'
                        examples:
                          - clinic_info
                    required:
                      - next_step
                required:
                  - success
                  - error_code
                  - message
                  - data
components:
  schemas:
    LeadMoveRequest:
      type: object
      properties:
        pipeline_stage_id:
          type:
            - integer
            - 'null'
          description: >-
            The stage to move the card to; defaults to the lead's current stage
            (a reorder within the stage).
        after_lead_id:
          type:
            - integer
            - 'null'
          description: >-
            The lead the card goes right below (its new upper neighbour on the
            board). Must be in the target stage.
        before_lead_id:
          type:
            - integer
            - 'null'
          description: >-
            The lead the card goes right above (its new lower neighbour on the
            board). Must be in the target stage.

            Without either neighbour the card goes to the bottom of the stage.
        lost_reason:
          type:
            - string
            - 'null'
          description: >-
            The reason the lead was lost. Required when moving into a lost stage
            that mandates a reason.
        lost_reason_id:
          type:
            - integer
            - 'null'
          description: >-
            The clinic's lost reason (from GET /leads/lost-reasons) the lead was
            lost with.
      title: LeadMoveRequest
    LeadResource:
      type: object
      properties:
        id:
          type: integer
        record_state:
          $ref: '#/components/schemas/RecordStateResource'
        can_start_conversation:
          type: boolean
          description: >-
            Whether the current user can open a conversation with this lead's
            person (or see the one they already have); `false` for a deleted
            lead, an erased person and a lead the user may not work on. The
            channel is not part of it.
        is_masked:
          type: boolean
          description: >-
            Whether the caller may only see this lead with its personal fields
            masked: a salesperson's view of a colleague's or an unassigned lead
            that has not converted. Such a lead is read-only
            (`record_state.reason_code` = `LEAD_NOT_ASSIGNED`); a colleague's
            converted lead is read-only too, but unmasked, as its patient is
            shared with the team.
        first_name:
          anyOf:
            - type: string
            - type: 'null'
        last_name:
          anyOf:
            - type: string
            - type: 'null'
        full_name:
          type: string
        phone_number:
          anyOf:
            - type: string
            - type: 'null'
        email:
          anyOf:
            - type: string
            - type: 'null'
        description:
          type:
            - string
            - 'null'
        message:
          type:
            - string
            - 'null'
        preferred_contact:
          type:
            - string
            - 'null'
        source_page_url:
          type:
            - string
            - 'null'
        avatar_url:
          type:
            - string
            - 'null'
        latest_conversation_id:
          type:
            - integer
            - 'null'
        stage:
          $ref: '#/components/schemas/RelatedPipelineStageResource'
        reference_source:
          $ref: '#/components/schemas/RelatedLeadReferenceSourceResource'
        expected_value:
          type:
            - string
            - 'null'
        treatments:
          type: array
          items:
            type: string
        currency_id:
          type:
            - integer
            - 'null'
        currency_code:
          type:
            - string
            - 'null'
        exchange_rate:
          type: string
        position:
          type:
            - string
            - 'null'
          description: >-
            The card's rank within its stage on the board (lexicographic); null
            until the card is placed.
        base_currency_expected_value:
          type:
            - number
            - 'null'
          description: >-
            The expected value in the tenant's base currency (expected_value ×
            exchange_rate); null without an expected value.
        assigned_user:
          $ref: '#/components/schemas/RelatedUserResource'
        country_id:
          type:
            - integer
            - 'null'
        country_name:
          type: string
        is_converted:
          type: string
        converted_at:
          type:
            - string
            - 'null'
          format: date-time
        won_at:
          type:
            - string
            - 'null'
          format: date-time
        lost_reason:
          type:
            - string
            - 'null'
          description: >-
            The free-text description of the loss; for a clinic-defined reason
            see `lost_reason_item`.
        lost_reason_id:
          type:
            - integer
            - 'null'
        lost_reason_item:
          $ref: '#/components/schemas/RelatedLeadLostReasonResource'
          description: >-
            The clinic-defined reason the lead was lost with (soft-deleted
            reasons are still returned), or `null`.
        lost_at:
          type:
            - string
            - 'null'
          format: date-time
        lost_by_user_id:
          type:
            - integer
            - 'null'
        customer_id:
          type:
            - integer
            - 'null'
        notification_channels:
          $ref: '#/components/schemas/CustomerNotificationChannelsResource'
        marketing_attribution:
          type:
            - array
            - 'null'
          items: {}
        external_id:
          type:
            - string
            - 'null'
        external_branch_id:
          type:
            - string
            - 'null'
        external_created_at:
          type:
            - string
            - 'null'
          format: date-time
        last_synced_at:
          type:
            - string
            - 'null'
          format: date-time
        import_source_id:
          type:
            - integer
            - 'null'
        import_source:
          anyOf:
            - $ref: '#/components/schemas/RelatedImportSourceResource'
              description: >-
                The external system the record was imported from, or `null` when
                it was created in Flextell. Only present on detail responses.
            - type: 'null'
        integration_source:
          anyOf:
            - $ref: '#/components/schemas/RelatedIntegrationConnectionResource'
              description: >-
                The integration connection (e.g. Zapier) that wrote the lead, or
                `null` when none did. Only present on detail responses.
            - type: 'null'
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - record_state
        - can_start_conversation
        - is_masked
        - first_name
        - last_name
        - full_name
        - phone_number
        - email
        - description
        - message
        - preferred_contact
        - source_page_url
        - avatar_url
        - latest_conversation_id
        - expected_value
        - currency_id
        - exchange_rate
        - position
        - base_currency_expected_value
        - country_id
        - is_converted
        - converted_at
        - won_at
        - lost_reason
        - lost_reason_id
        - lost_at
        - lost_by_user_id
        - customer_id
        - marketing_attribution
        - external_id
        - external_branch_id
        - external_created_at
        - last_synced_at
        - import_source_id
        - created_at
        - updated_at
        - deleted_at
      title: LeadResource
    RecordStateResource:
      type: object
      properties:
        is_read_only:
          type: boolean
          description: >-
            True when every write on this record is refused; false does not
            imply the caller may write.
        reason_code:
          type:
            - string
            - 'null'
          description: >-
            Why the record is read-only (`CUSTOMER_ERASED`, or
            `LEAD_NOT_ASSIGNED` for a salesperson on another rep's lead), or
            null when it is not.
      required:
        - is_read_only
        - reason_code
      title: RecordStateResource
    RelatedPipelineStageResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        color:
          type: string
        is_won:
          type: boolean
        is_lost:
          type: boolean
      required:
        - id
        - name
        - color
        - is_won
        - is_lost
      title: RelatedPipelineStageResource
    RelatedLeadReferenceSourceResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        external_id:
          type:
            - string
            - 'null'
      required:
        - id
        - name
        - external_id
      title: RelatedLeadReferenceSourceResource
    RelatedUserResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        avatar_url:
          type:
            - string
            - 'null'
          description: >-
            A signed profile photo URL valid for a few hours, or `null` without
            a photo. Only on responses that opt in.
      required:
        - id
        - name
      title: RelatedUserResource
    RelatedLeadLostReasonResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        color:
          type:
            - string
            - 'null'
        is_other:
          type: boolean
      required:
        - id
        - name
        - color
        - is_other
      title: RelatedLeadLostReasonResource
    CustomerNotificationChannelsResource:
      type: object
      properties:
        default_channel_id:
          type:
            - string
            - 'null'
        source:
          type:
            - string
            - 'null'
        channels:
          type: array
          items: {}
      required:
        - default_channel_id
        - source
        - channels
      title: CustomerNotificationChannelsResource
    RelatedImportSourceResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        company_logo:
          type: 'null'
      required:
        - id
        - name
        - company_logo
      title: RelatedImportSourceResource
    RelatedIntegrationConnectionResource:
      type: object
      properties:
        connection_id:
          type: integer
          description: The integration connection identifier.
        connection_name:
          type: string
        integration:
          $ref: '#/components/schemas/RelatedIntegrationResource'
        external_id:
          type: string
          description: >-
            The record's own id at the provider (e.g. the Zapier Tables record
            id).
      required:
        - connection_id
        - connection_name
        - integration
        - external_id
      title: RelatedIntegrationConnectionResource
    RelatedIntegrationResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        system_name:
          type:
            - string
            - 'null'
        company_logo:
          type: 'null'
          description: >-
            Short-lived (5 minute) signed URL of the integrator logo; `null`
            when none is set.
      required:
        - id
        - name
        - system_name
        - company_logo
      title: RelatedIntegrationResource
  responses:
    AuthenticationException:
      description: Unauthenticated
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    AuthorizationException:
      description: Authorization error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    CustomerErasedException:
      description: The patient record has been erased and is read-only
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                description: Always false for an error.
                examples:
                  - false
              error_code:
                type: string
                description: Machine-readable error code.
                examples:
                  - CUSTOMER_ERASED
              message:
                type: string
                description: Localized error message.
            required:
              - success
              - error_code
              - message
    ValidationException:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Errors overview.
              errors:
                type: object
                description: A detailed description of each field that failed validation.
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://app.flextell.ai/oauth/authorize
          tokenUrl: https://app.flextell.ai/oauth/token
          scopes:
            '*': all
    bearer:
      type: http
      scheme: bearer

````

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