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

# Upsert prompt

> This endpoint accepts a request payload containing the prompt details.  
If the prompt already exists, it will be updated; otherwise, a new prompt will be created.



## OpenAPI

````yaml openapi/prompt-v1.json POST /s2s/v1/prompt
openapi: 3.0.1
info:
  title: Prompt.Api
  version: v1
servers:
  - url: https://{host}/prompt
    description: Your Lobyco environment
    variables:
      host:
        default: your-environment.lobyco.net
        description: >-
          The API host for your Lobyco environment. Replace it with the host you
          were given — this placeholder does not resolve.
security:
  - Bearer: []
paths:
  /s2s/v1/prompt:
    post:
      tags:
        - ServiceToService
      summary: Upsert prompt
      description: "This endpoint accepts a request payload containing the prompt details.  \r\nIf the prompt already exists, it will be updated; otherwise, a new prompt will be created."
      requestBody:
        description: The payload containing the details of the prompt to upsert.
        content:
          application/json-patch+json:
            schema:
              $ref: >-
                #/components/schemas/Prompt.Api.DTO.Requests.S2S.UpsertPromptExternalRequest
          application/json:
            schema:
              $ref: >-
                #/components/schemas/Prompt.Api.DTO.Requests.S2S.UpsertPromptExternalRequest
          text/json:
            schema:
              $ref: >-
                #/components/schemas/Prompt.Api.DTO.Requests.S2S.UpsertPromptExternalRequest
          application/*+json:
            schema:
              $ref: >-
                #/components/schemas/Prompt.Api.DTO.Requests.S2S.UpsertPromptExternalRequest
      responses:
        '200':
          description: Success
          content:
            text/plain:
              schema:
                $ref: >-
                  #/components/schemas/Prompt.Api.DTO.Responses.UpsertPromptResponse
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Prompt.Api.DTO.Responses.UpsertPromptResponse
            text/json:
              schema:
                $ref: >-
                  #/components/schemas/Prompt.Api.DTO.Responses.UpsertPromptResponse
        '400':
          description: Bad Request
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
            application/json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
            text/json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
components:
  schemas:
    Prompt.Api.DTO.Requests.S2S.UpsertPromptExternalRequest:
      required:
        - startDate
        - title
        - type
      type: object
      properties:
        id:
          type: integer
          description: >-
            Internal identifier of the prompt (optional for creation, required
            for update).
          format: int32
          nullable: true
        title:
          maxLength: 100
          minLength: 0
          type: string
          description: Title of the prompt.
        type:
          $ref: '#/components/schemas/Prompt.Persistence.Models.PromptType'
        headline:
          maxLength: 255
          minLength: 0
          type: string
          description: Optional headline displayed for the prompt.
          nullable: true
        body:
          maxLength: 5000
          minLength: 0
          type: string
          description: Optional detailed body content of the prompt.
          nullable: true
        imageId:
          type: integer
          description: Optional identifier of an image associated with the prompt.
          format: int32
          nullable: true
        imageUrl:
          type: string
          description: Optional URL of an image to be displayed inside the the prompt.
          nullable: true
        approveButtonText:
          maxLength: 255
          minLength: 0
          type: string
          description: Text displayed on the approve button for the prompt.
          nullable: true
        declineButtonText:
          maxLength: 255
          minLength: 0
          type: string
          description: Text displayed on the decline button for the prompt.
          nullable: true
        segmentationType:
          $ref: >-
            #/components/schemas/Prompt.ApplicationService.Infrastructure.Enums.SegmentationType
        segmentationFileIds:
          type: array
          items:
            type: integer
            format: int32
          description: Optional list of file IDs used for segmentation.
          nullable: true
        startDate:
          type: string
          description: >-
            Start date and time when the prompt becomes active. Required if
            Prompt.Api.DTO.Requests.Admin.UpsertPromptRequest.IsReadyToDistribute
            is true.
          format: date-time
        endDate:
          type: string
          description: Optional end date and time when the prompt expires.
          format: date-time
          nullable: true
        validForDays:
          type: integer
          description: >-
            Optional number of days a member-specific prompt remains valid after
            allocation.
          format: int32
          nullable: true
        isReadyToDistribute:
          type: boolean
          description: Indicates whether the prompt is ready to be distributed.
        metadata:
          $ref: >-
            #/components/schemas/Prompt.Api.DTO.Requests.Admin.UpsertPromptRequest.PromptMetadata
        source:
          maxLength: 300
          minLength: 0
          type: string
          description: Optional source information for the prompt.
          nullable: true
        analyticsIdentifier:
          maxLength: 300
          minLength: 0
          type: string
          description: Tracking identifier used for analytics.
          nullable: true
        unifiedCampaignId:
          maxLength: 64
          minLength: 0
          type: string
          description: Optional unified campaign identifier.
          nullable: true
        segmentationFileUrls:
          type: array
          items:
            type: string
          description: >-
            Collection of URLs pointing to segmentation files associated with
            the prompt.
          nullable: true
        authorId:
          maxLength: 255
          minLength: 0
          type: string
          description: Unique identifier of the author.
          nullable: true
        authorName:
          maxLength: 255
          minLength: 0
          type: string
          description: Name of the author.
          nullable: true
      additionalProperties: false
    Prompt.Api.DTO.Responses.UpsertPromptResponse:
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier of the upserted prompt
          format: int32
      additionalProperties: false
    Microsoft.AspNetCore.Mvc.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: {}
    Prompt.Persistence.Models.PromptType:
      enum:
        - ThirdPartyConsent
        - Regular
        - PreferredStore
        - PushConsent
      type: string
    Prompt.ApplicationService.Infrastructure.Enums.SegmentationType:
      enum:
        - All
        - File
        - ExternalSource
        - Audience
        - Customer
      type: string
    Prompt.Api.DTO.Requests.Admin.UpsertPromptRequest.PromptMetadata:
      type: object
      properties:
        externalConsentIds:
          type: array
          items:
            type: string
          description: Array of external consent identifiers associated with the prompt.
          nullable: true
        addLinkToTermsAndConditions:
          type: boolean
          description: >-
            Indicates whether a link to the terms and conditions should be added
            to the prompt.
          nullable: true
        suggestedStoreSourceIdentifier:
          type: string
          description: Suggested store source identifier for preferred store prompt
          nullable: true
        acceptDeepLink:
          $ref: >-
            #/components/schemas/Prompt.Api.DTO.Requests.Admin.UpsertPromptRequest.DeepLink
        acceptActionExternalUrl:
          type: string
          description: Optional external URL to navigate to when the prompt is accepted.
          nullable: true
        acceptActionNavigationType:
          $ref: '#/components/schemas/Prompt.Persistence.Models.ActionNavigationType'
        declineDeepLink:
          $ref: >-
            #/components/schemas/Prompt.Api.DTO.Requests.Admin.UpsertPromptRequest.DeepLink
        declineActionExternalUrl:
          type: string
          description: Optional external URL to navigate to when the prompt is declined.
          nullable: true
        declineActionNavigationType:
          $ref: '#/components/schemas/Prompt.Persistence.Models.ActionNavigationType'
        audienceIds:
          type: array
          items:
            type: string
          description: Optional list of audience identifiers targeted by the prompt.
          nullable: true
        color:
          type: string
          description: Optional color to be displayed
          nullable: true
        useWebWrapper:
          type: boolean
          description: >-
            Indicates whether the prompt’s action external URLs should be opened
            in a web wrapper.
          nullable: true
      additionalProperties: false
    Prompt.Api.DTO.Requests.Admin.UpsertPromptRequest.DeepLink:
      type: object
      properties:
        id:
          maxLength: 64
          minLength: 0
          type: string
          description: >-
            Deep link identifier. Used to open a specific page from the
            application.
          nullable: true
        parameters:
          type: object
          additionalProperties:
            type: string
          description: >-
            Additional parameters for deep link. (e.g. redirect user to a
            specific entity from the section configured with Id)
          nullable: true
      additionalProperties: false
    Prompt.Persistence.Models.ActionNavigationType:
      enum:
        - External
        - DeepLink
      type: string
  securitySchemes:
    Bearer:
      type: apiKey
      description: >-
        Opaque Authorization header using the Bearer scheme. Example:
        "Authorization: Bearer {token}"
      name: Authorization
      in: header

````