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

# Update an existing campaign item

> Finds a campaign item matching the provided filters (phoneNumber, runningStatus, and optionally itemId) and partially updates it. The first matching item is updated.



## OpenAPI

````yaml /api-reference/openapi.json patch /CampaignItem/{campaignId}
openapi: 3.0.1
info:
  title: Starleads public API documentation
  description: >
    Welcome to the Starleads Public API documentation. This API provides public
    access to Starleads services, allowing developers and growth-hackers to
    interact with campaign-related data.

    ***

    ### Base endpoint

    ```https://api.starleads.co```

    ***

    ### Errors

    The API uses standard HTTP status codes to indicate the success or failure
    of the API call. In case of failure, the body of the response will be JSON
    in the following format:

    ```

    {
      "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
      "title": "Bad Request",
      "status": 400,
      "detail": "No campaign exists with campaignId : 11111111"
    }

    ```

    The ```type``` property is a link to a general description of the error
    type.

    ***

    ### Authentification

    Authentication for the API is handled with an API key that must be provided
    as a ```X-Api-Key``` header for every request.<br>

    **API keys are supposed to be a secret that only the client and server know.
    Please remember to not share them with anyone.**<br>

    You can find your API keys when authenticated in your Starleads profile
    :<br> ![Api key menu option](../images/api-menu-option-screenshot.png)
  version: v1
  x-logo:
    url: https://api.starleads.co/images/starleads-logo.png
servers: []
security: []
tags:
  - name: Agent
    description: >-
      Manage your AI agent's prompt. These endpoints allow you to read and
      update the prompt that drives your agent's behavior during calls.
  - name: CampaignField
    description: >-
      CampaignFields enables users to specify customizable fields within their
      campaigns. These fields serve as placeholders (e.g., ```{lastname}```)
      that can be dynamically filled with corresponding data when creating
      prompts, providing flexibility in tailoring campaign content based on
      specific variables.<br>**Those are the keys of the ```databag``` field of
      the request payload to add a new ```CampaignItem``` to a campaign.**
  - name: CampaignItem
    description: Represents prospects entries related to a campaign
  - name: Consumption
    description: >-
      Track your company's credit consumption. These endpoints expose your
      current balance, usage and billing period so you can build budget
      monitoring on top of the API.
  - name: Subscription
    description: >-
      Inspect your subscription contract: the plan you are on, your subscription
      status, the features currently active and your effective limits. No
      pricing information is exposed.
paths:
  /CampaignItem/{campaignId}:
    patch:
      tags:
        - CampaignItem
      summary: Update an existing campaign item
      description: >-
        Finds a campaign item matching the provided filters (phoneNumber,
        runningStatus, and optionally itemId) and partially updates it. The
        first matching item is updated.
      operationId: PatchCampaignItem
      parameters:
        - name: X-Api-Key
          in: header
          description: >-
            Api key to pass as a ```X-Api-Key``` request header. You can get
            yours in your profile when authenticated in
            [Starleads](https://app.starleads.co/)
          required: true
          schema:
            type: string
        - name: campaignId
          in: path
          description: ID of the campaign.
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchCampaignItemRequest'
          text/json:
            schema:
              $ref: '#/components/schemas/PatchCampaignItemRequest'
          application/*+json:
            schema:
              $ref: '#/components/schemas/PatchCampaignItemRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignItem'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
components:
  schemas:
    PatchCampaignItemRequest:
      type: object
      properties:
        phoneNumber:
          type: string
          description: >-
            Phone number of the item to update. Required if itemId is not
            provided.
          nullable: true
        itemId:
          type: string
          description: >-
            Item ID of the item to update. Required if phoneNumber is not
            provided.
          nullable: true
        runningStatus:
          $ref: '#/components/schemas/RunningStatus'
        dataBag:
          type: object
          additionalProperties:
            type: string
          description: >-
            The databag refer to the campaign fields. Only the provided keys
            will be updated.
          nullable: true
        nextTryDate:
          type: string
          description: The next date when the number will be called again by Starleads.
          format: 'DateTime format eg : 2023-11-17T12:44:50.809Z'
          nullable: true
      additionalProperties: false
    CampaignItem:
      type: object
      properties:
        id:
          type: string
          nullable: true
        campaignId:
          type: string
          nullable: true
        createdAt:
          type: string
          format: date-time
          nullable: true
        processedAt:
          type: string
          format: date-time
          nullable: true
        lastCallDate:
          type: string
          format: date-time
          nullable: true
        runningStatus:
          $ref: '#/components/schemas/RunningStatus'
        attemptCount:
          type: integer
          format: int32
        channel:
          $ref: '#/components/schemas/LiveConversationChannel'
        phoneNumber:
          type: string
          nullable: true
        businessId:
          type: string
          nullable: true
        nextTryDate:
          type: string
          format: date-time
        dataBag:
          type: object
          additionalProperties:
            type: string
          nullable: true
        result:
          $ref: '#/components/schemas/Result'
        isArchived:
          type: boolean
        eventList:
          type: array
          items:
            $ref: '#/components/schemas/TaskEvent'
          nullable: true
        delivery:
          $ref: '#/components/schemas/Delivery'
      additionalProperties: false
    ProblemDetails:
      type: object
      properties:
        type:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        status:
          type: integer
          format: int32
          nullable: true
        detail:
          type: string
          nullable: true
        instance:
          type: string
          nullable: true
      additionalProperties: {}
    RunningStatus:
      enum:
        - Pending
        - Calling
        - Processed
        - ProcessingResult
        - Error
      type: string
    LiveConversationChannel:
      enum:
        - 0
        - 1
        - 2
        - 3
        - 4
      type: integer
      format: int32
    Result:
      type: object
      properties:
        tag:
          $ref: '#/components/schemas/Tag'
        conversation:
          $ref: '#/components/schemas/Conversation'
        summary:
          type: string
          nullable: true
        isSystem:
          type: boolean
        metadata:
          type: object
          additionalProperties:
            type: string
          nullable: true
      additionalProperties: false
    TaskEvent:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/Event'
        date:
          type: string
          format: date-time
        description:
          type: string
          nullable: true
      additionalProperties: false
    Delivery:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/DeliveryStatus'
        externalMessageId:
          type: string
          nullable: true
        provider:
          type: string
          nullable: true
        sentAt:
          type: string
          format: date-time
          nullable: true
        deliveredAt:
          type: string
          format: date-time
          nullable: true
        readAt:
          type: string
          format: date-time
          nullable: true
        failedAt:
          type: string
          format: date-time
          nullable: true
        errorCode:
          type: string
          nullable: true
        errorTitle:
          type: string
          nullable: true
        lastMessageIndex:
          type: integer
          format: int32
          nullable: true
        lastOrigin:
          $ref: '#/components/schemas/DeliveryOrigin'
        history:
          type: array
          items:
            $ref: '#/components/schemas/DeliveryHistoryEntry'
          nullable: true
      additionalProperties: false
    Tag:
      type: object
      properties:
        id:
          type: string
          nullable: true
          readOnly: true
        name:
          type: string
          nullable: true
        color:
          type: string
          nullable: true
      additionalProperties: false
    Conversation:
      type: object
      properties:
        id:
          type: string
          nullable: true
        messages:
          type: array
          items:
            $ref: '#/components/schemas/Message'
          nullable: true
      additionalProperties: false
    Event:
      enum:
        - LaunchCall
        - InboundCall
        - ResetCall
        - EndCall
        - ProcessingResult
        - Error
        - PickUp
      type: string
    DeliveryStatus:
      enum:
        - 1
        - 2
        - 3
        - 99
      type: integer
      format: int32
    DeliveryOrigin:
      enum:
        - 0
        - 1
        - 2
        - 3
      type: integer
      format: int32
    DeliveryHistoryEntry:
      type: object
      properties:
        origin:
          $ref: '#/components/schemas/DeliveryOrigin'
        messageIndex:
          type: integer
          format: int32
          nullable: true
        externalMessageId:
          type: string
          nullable: true
        status:
          $ref: '#/components/schemas/DeliveryStatus'
        sentAt:
          type: string
          format: date-time
          nullable: true
        deliveredAt:
          type: string
          format: date-time
          nullable: true
        readAt:
          type: string
          format: date-time
          nullable: true
        failedAt:
          type: string
          format: date-time
          nullable: true
        errorCode:
          type: string
          nullable: true
        errorTitle:
          type: string
          nullable: true
      additionalProperties: false
    Message:
      type: object
      properties:
        timestamp:
          type: string
          format: date-time
          nullable: true
        role:
          type: string
          nullable: true
        text:
          type: string
          nullable: true
        rawText:
          type: string
          nullable: true
        intent:
          type: string
          nullable: true
        commands:
          type: array
          items:
            type: string
          nullable: true
        isConversationEnded:
          type: boolean
          nullable: true
        endReason:
          type: string
          nullable: true
      additionalProperties: false

````