# Recommend sending time v2

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v2/ml/sending/recommend_time:
    post:
      summary: Recommend sending time v2
      deprecated: false
      description: >-
        Recommends sending date and time in a given time frame. Prediction is
        made for each hour in the given range, and the best one is also
        explicitly returned.


        **Warning:** combination of "sms" channel and "open_rate" KPI is not
        supported.


        Text should be as shown to the end user, without any HTML.


        ## Example


        ```shell

        curl -X POST \

        "https://api.mpc.placewise.com/v2/ml/sending/recommend_time  \

        -H 'Content-Type: application/json' \

        -H 'Authorization: Bearer B7t9U9tsoWsGhrv2ouUoSqpM' \

        -H 'x-product-name: default' \

        -H 'x-user-agent: CURL manual test' \

        -d '{
          "channel": "email",
          "kpi": "ctr",
          "text": "Great title! Great content".
          "start_time": "2025-01-01 01:00:00",
          "end_time": "2025-07-01 12:00:00"
        }'

        ```


        > When successful, returns:

        ```json

        {
          "predictions": [
            {
              "timestamp": "2025-01-01 01:00:00",
              "prediction": 0.01
            },
            {
              "timestamp": "2025-01-01 02:00:00",
              "prediction": 0.05
            },
            ...
          ],
          "best_prediction": {
            "timestamp": "2025-01-01 05:00:00",
            "prediction": 12,34
          }
        }

        ```
      tags:
        - API Reference/ML API/Sendings/Deprecated
      parameters:
        - name: Content-Type
          in: header
          description: '[Details](doc-341635)'
          required: true
          example: application/json
          schema:
            type: string
            default: application/json
            const: application/json
        - name: X-User-Agent
          in: header
          description: Arbitrary identifier of your client. [Details](doc-341635)
          required: true
          example: '{{X_USER_AGENT}}'
          schema:
            type: string
            default: '{{X_USER_AGENT}}'
        - name: X-Product-Name
          in: header
          description: API Product for API context. [Details](doc-341635)
          required: true
          example: '{{PRODUCT_NAME}}'
          schema:
            type: string
            default: '{{PRODUCT_NAME}}'
        - name: X-Loyalty-Club-Slug
          in: header
          description: LoyaltyClub for API context. [Details](doc-342138)
          required: false
          example: '{{LOYALTY_CLUB_SLUG}}'
          schema:
            type: string
            default: '{{LOYALTY_CLUB_SLUG}}'
        - name: X-Customer
          in: header
          description: Customer for API context.  [Details](doc-342139)
          required: false
          example: '{{CUSTOMER_ID}}'
          schema:
            type: string
            default: '{{CUSTOMER_ID}}'
        - name: Authorization
          in: header
          description: '[Member](doc-342129) or [User](doc-342130) Authorization.'
          required: false
          example: Bearer {{_OAUTH_TOKEN}}
          schema:
            type: string
            default: Bearer {{_OAUTH_TOKEN}}
        - name: X-Client-Authorization
          in: header
          description: '[Token](doc-342128) Authorization.'
          example: '{{API_TOKEN}}'
          schema:
            type: string
            default: '{{API_TOKEN}}'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                channel:
                  description: Channel of sending. One of ["email", "push", "sms"].
                  $ref: '#/components/schemas/Channel'
                kpi:
                  description: KPI to predict. One of ["ctr", "open_rate"].
                  $ref: '#/components/schemas/KPI'
                text:
                  description: >-
                    Sending text. For emails, it should contain both title and
                    content, separated with a space.
                  $ref: '#/components/schemas/text'
                start_time: &ref_0
                  description: Time range starting point, in format "YYYY-MM-DD HH:MM:SS"
                  $ref: '#/components/schemas/date_time'
                end_time: *ref_0
              x-apidog-orders:
                - channel
                - kpi
                - text
                - start_time
                - end_time
              required:
                - channel
                - kpi
                - text
                - start_time
                - end_time
              x-apidog-ignore-properties: []
            example:
              channel: sms
              kpi: open_rate
              sending_date: '2024-04-20'
              sending_hour: 16
              text: >-
                Canis acervus maxime trepide conculco strues. Calco placeat
                ipsam tibi.
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  predictions:
                    type: array
                    items: &ref_1
                      $ref: '#/components/schemas/sending%20time%20prediction'
                    description: List of predictions, one per hour
                  best_prediction: *ref_1
                x-apidog-orders:
                  - predictions
                  - best_prediction
                required:
                  - predictions
                  - best_prediction
                x-apidog-ignore-properties: []
          headers: {}
          x-apidog-name: Success
      security: []
      x-apidog-folder: API Reference/ML API/Sendings/Deprecated
      x-apidog-status: released
      x-run-in-apidog: https://app.eu.apidog.com/web/project/346351/apis/api-3738948-run
components:
  schemas:
    date_time:
      type: string
      format: date-time
      examples:
        - '2022-11-09T16:25:58.099512Z'
      x-apidog-folder: ''
    text:
      type: string
      description: Text of sending. If it has title and content, combine them as one text.
      x-apidog-folder: ''
    KPI:
      type: string
      title: kpi
      description: Channel of the sending
      enum:
        - ctr
        - open_rate
        - sms
      x-apidog-enum:
        - value: ctr
          name: kpi
          description: ''
        - value: open_rate
          name: channel
          description: ''
        - value: sms
          name: channel
          description: ''
      x-apidog-folder: ''
    Channel:
      type: string
      enum:
        - email
        - push
        - sms
      x-apidog-enum:
        - value: email
          name: channel
          description: ''
        - value: push
          name: channel
          description: ''
        - value: sms
          name: channel
          description: ''
      title: channel
      description: Channel of the sending
      x-apidog-folder: ''
    sending time prediction:
      type: object
      properties:
        timestamp: *ref_0
        prediction:
          type: number
          description: Predicted KPI, in range [0, 100]
      x-apidog-orders:
        - timestamp
        - prediction
      required:
        - timestamp
        - prediction
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes: {}
servers:
  - url: https://api.mpc.dev.placewise.com
    description: Staging
security: []

```