# Schedule object

- Operation ID: `schedule-object`
- HTTP method: `POST`
- Path: `/schema-service/scheduler/entry`
- [Human-readable API reference](https://hub.synerise.com/api-reference/campaigns#operation/schedule-object)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /schema-service/scheduler/entry:
    post:
      tags:
        - Screen views
      summary: Schedule object
      description: |
        Add a schedule to a document or screen view.

        ---

        **API consumers:** <a href="/api-reference/authorization?tag=Authorization&amp;operationId=profileLogin" target="_blank" rel="noopener">Workspace (Business Profile)</a>, <a href="/api-reference/authorization?tag=Authorization&amp;operationId=userLogin" target="_blank" rel="noopener">Synerise User</a>

        **API key permission required:** `SCHEMA_SERVICE_SCHEMA_CREATE`

        **User role permission required:** `assets_docs: create`
      operationId: schedule-object
      security:
        - JWT: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              description: Schedule object
              properties:
                externalId:
                  type: string
                  format: uuid
                  description: UUID of the screen view or document that the schedule applies to
                type:
                  type: string
                  description: Type of the scheduled object
                  enum:
                    - SCREENVIEW
                    - DOCUMENT
                schedule:
                  type: object
                  description: Configuration of the schedule
                  properties:
                    enabled:
                      type: boolean
                      description: Defines if the schedule configuration is enabled. A schedule must be enabled in order to become active at the selected time.
                    endDate:
                      type: string
                      format: date-time
                      description: Time when the schedule stops being active. If `endType` is NEVER, this field is null.
                      nullable: true
                    endType:
                      type: string
                      description: |
                        - NEVER: schedule never becomes inactive.

                        - DATE: schedule becomes inactive at the time set by `endDate`.
                      enum:
                        - NEVER
                        - DATE
                    parts:
                      type: array
                      description: |
                        
                        An array of time rules that allow more granularity. All objects must match the period type set in `periodType` (for example, you **cannot mix** weekly and monthly conditions). 

                        If `periodType` is ENTIRE, this array is empty.
                      items:
                        type: object
                        properties:
                          startDay:
                            type: integer
                            format: int32
                            example: 1
                            description: |
                              If `periodType` is:


                              - WEEKLY, the values are 1-7 (1 is Monday).

                              - MONTHLY, the values are 1-31 (days of the month).

                              **Note:**<br/>
                              If you want to define two time rules for a day (for example, the schedule is active on Monday at 06:00-07:00 and 15:00-16:00), create a separate object for each time period in the `parts` array.
                          startTime:
                            type: string
                            example: 08:18:03
                            description: The hour when the schedule becomes active.
                          endDay:
                            type: integer
                            format: int32
                            example: 1
                            description: Must be identical to `startDay`.
                          endTime:
                            type: string
                            example: 44283
                            description: The hour when the schedule becomes inactive.
                    periodType:
                      type: string
                      description: |
                        Defines when the schedule applies within its activity period.

                        - ENTIRE: schedule is applied at all time since it becomes active until it becomes inactive.


                        - WEEKLY: schedule is applied at specified days of the week (and optionally at specific times during those days)

                        - MONTHLY: schedule is applied at specified days of the month (and optionally at specific times during those days)
                      enum:
                        - ENTIRE
                        - WEEKLY
                        - MONTHLY
                    startDate:
                      type: string
                      format: date-time
                      description: Time when the schedule becomes active. If `startType` is NOW, this field is null.
                    startType:
                      type: string
                      enum:
                        - NOW
                        - SCHEDULED
                    timezone:
                      type: string
                      example: Europe/Warsaw
                      description: Time zone according to the [tz database](https://en.wikipedia.org/wiki/Tz_database)
      responses:
        "200":
          description: Schedule added
          content:
            application/json:
              schema:
                type: object
                description: Details of the schedule
                properties:
                  active:
                    type: boolean
                    description: "`true` if the conditions of the schedule match the current time. This is not related to document/screen view status."
                  externalId:
                    type: string
                    format: uuid
                    description: UUID of the screen view or document that the schedule applies to
                  type:
                    type: string
                    description: Type of the scheduled object
                    enum:
                      - SCREENVIEW
                      - DOCUMENT
                  finished:
                    type: boolean
                    description: "`true` if the conditions of the schedule mean it ended in the past. This is not related to document/screen view status."
                  schedule:
                    type: object
                    description: Configuration of the schedule
                    properties:
                      enabled:
                        type: boolean
                        description: Defines if the schedule configuration is enabled. A schedule must be enabled in order to become active at the selected time.
                      endDate:
                        type: string
                        format: date-time
                        description: Time when the schedule stops being active. If `endType` is NEVER, this field is null.
                        nullable: true
                      endType:
                        type: string
                        description: |
                          - NEVER: schedule never becomes inactive.

                          - DATE: schedule becomes inactive at the time set by `endDate`.
                        enum:
                          - NEVER
                          - DATE
                      parts:
                        type: array
                        description: |
                          
                          An array of time rules that allow more granularity. All objects must match the period type set in `periodType` (for example, you **cannot mix** weekly and monthly conditions). 

                          If `periodType` is ENTIRE, this array is empty.
                        items:
                          type: object
                          properties:
                            startDay:
                              type: integer
                              format: int32
                              example: 1
                              description: |
                                If `periodType` is:


                                - WEEKLY, the values are 1-7 (1 is Monday).

                                - MONTHLY, the values are 1-31 (days of the month).

                                **Note:**<br/>
                                If you want to define two time rules for a day (for example, the schedule is active on Monday at 06:00-07:00 and 15:00-16:00), create a separate object for each time period in the `parts` array.
                            startTime:
                              type: string
                              example: 08:18:03
                              description: The hour when the schedule becomes active.
                            endDay:
                              type: integer
                              format: int32
                              example: 1
                              description: Must be identical to `startDay`.
                            endTime:
                              type: string
                              example: 44283
                              description: The hour when the schedule becomes inactive.
                      periodType:
                        type: string
                        description: |
                          Defines when the schedule applies within its activity period.

                          - ENTIRE: schedule is applied at all time since it becomes active until it becomes inactive.


                          - WEEKLY: schedule is applied at specified days of the week (and optionally at specific times during those days)

                          - MONTHLY: schedule is applied at specified days of the month (and optionally at specific times during those days)
                        enum:
                          - ENTIRE
                          - WEEKLY
                          - MONTHLY
                      startDate:
                        type: string
                        format: date-time
                        description: Time when the schedule becomes active. If `startType` is NOW, this field is null.
                      startType:
                        type: string
                        enum:
                          - NOW
                          - SCHEDULED
                      timezone:
                        type: string
                        example: Europe/Warsaw
                        description: Time zone according to the [tz database](https://en.wikipedia.org/wiki/Tz_database)
        "400":
          description: See error message for details
          content:
            application/json:
              schema:
                type: object
                properties:
                  timestamp:
                    type: string
                    format: date-time
                    description: Time when the error occurred
                  errorCode:
                    type: string
                    description: |
                      Code of the error, needed for troubleshooting

                      See error reference: [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html)
                  status:
                    type: integer
                    description: Error's HTTP status code
                  message:
                    type: string
                    description: Description of the problem
        "401":
          description: "Unauthorized: wrong consumer scope; token missing/expired/invalid; invalid API key; etc."
          content:
            application/json:
              schema:
                type: object
                properties:
                  timestamp:
                    type: string
                    description: Time when the error occurred
                  error:
                    type: string
                    description: Summary of the error
                  message:
                    type: string
                    description: Description of the problem
                  status:
                    type: integer
                    format: int32
                    description: HTTP status code
        "403":
          description: Forbidden; insufficient permissions
          content:
            application/json:
              schema:
                type: object
                properties:
                  timestamp:
                    type: string
                    description: Time when the error occurred
                  error:
                    type: string
                    description: Summary of the error
                  message:
                    type: string
                    description: Description of the problem
                  status:
                    type: integer
                    format: int32
                    description: HTTP status code
        "404":
          description: Resource not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  timestamp:
                    type: string
                    format: date-time
                    description: Time when the error occurred
                  errorCode:
                    type: string
                    description: |
                      Code of the error, needed for troubleshooting

                      See error reference: [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html)
                  status:
                    type: integer
                    description: Error's HTTP status code
                  message:
                    type: string
                    description: Description of the problem
        "500":
          description: See error message for details
          content:
            application/json:
              schema:
                type: object
                properties:
                  timestamp:
                    type: string
                    format: date-time
                    description: Time when the error occurred
                  errorCode:
                    type: string
                    description: |
                      Code of the error, needed for troubleshooting

                      See error reference: [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html)
                  status:
                    type: integer
                    description: Error's HTTP status code
                  message:
                    type: string
                    description: Description of the problem
      x-snr-doc-urls:
        - /api-reference/loyalty-and-engagement#tag/Screen-views/operation/schedule-object
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/schema-service/scheduler/entry \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: application/json' \
              --data '{"externalId":"3200d382-adfe-4314-ab30-798cdd0fcdb5","type":"SCREENVIEW","schedule":{"enabled":true,"endDate":"2019-08-24T14:15:22Z","endType":"NEVER","parts":[{"startDay":1,"startTime":"08:18:03","endDay":1,"endTime":44283}],"periodType":"ENTIRE","startDate":"2019-08-24T14:15:22Z","startType":"NOW","timezone":"Europe/Warsaw"}}'
        - lang: Python
          label: Python
          source: |-
            import http.client

            conn = http.client.HTTPSConnection("api.synerise.com")

            payload = "{\"externalId\":\"3200d382-adfe-4314-ab30-798cdd0fcdb5\",\"type\":\"SCREENVIEW\",\"schedule\":{\"enabled\":true,\"endDate\":\"2019-08-24T14:15:22Z\",\"endType\":\"NEVER\",\"parts\":[{\"startDay\":1,\"startTime\":\"08:18:03\",\"endDay\":1,\"endTime\":44283}],\"periodType\":\"ENTIRE\",\"startDate\":\"2019-08-24T14:15:22Z\",\"startType\":\"NOW\",\"timezone\":\"Europe/Warsaw\"}}"

            headers = {
                'Authorization': "Bearer REPLACE_BEARER_TOKEN",
                'content-type': "application/json"
                }

            conn.request("POST", "/schema-service/scheduler/entry", payload, headers)

            res = conn.getresponse()
            data = res.read()

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = JSON.stringify({
              "externalId": "3200d382-adfe-4314-ab30-798cdd0fcdb5",
              "type": "SCREENVIEW",
              "schedule": {
                "enabled": true,
                "endDate": "2019-08-24T14:15:22Z",
                "endType": "NEVER",
                "parts": [
                  {
                    "startDay": 1,
                    "startTime": "08:18:03",
                    "endDay": 1,
                    "endTime": 44283
                  }
                ],
                "periodType": "ENTIRE",
                "startDate": "2019-08-24T14:15:22Z",
                "startType": "NOW",
                "timezone": "Europe/Warsaw"
              }
            });

            const xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
              if (this.readyState === this.DONE) {
                console.log(this.responseText);
              }
            });

            xhr.open("POST", "https://api.synerise.com/schema-service/scheduler/entry");
            xhr.setRequestHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
            xhr.setRequestHeader("content-type", "application/json");

            xhr.send(data);
        - lang: Node.js
          label: Node.js
          source: |-
            const http = require("https");

            const options = {
              "method": "POST",
              "hostname": "api.synerise.com",
              "port": null,
              "path": "/schema-service/scheduler/entry",
              "headers": {
                "Authorization": "Bearer REPLACE_BEARER_TOKEN",
                "content-type": "application/json"
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on("data", function (chunk) {
                chunks.push(chunk);
              });

              res.on("end", function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.write(JSON.stringify({
              externalId: '3200d382-adfe-4314-ab30-798cdd0fcdb5',
              type: 'SCREENVIEW',
              schedule: {
                enabled: true,
                endDate: '2019-08-24T14:15:22Z',
                endType: 'NEVER',
                parts: [{startDay: 1, startTime: '08:18:03', endDay: 1, endTime: 44283}],
                periodType: 'ENTIRE',
                startDate: '2019-08-24T14:15:22Z',
                startType: 'NOW',
                timezone: 'Europe/Warsaw'
              }
            }));
            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/schema-service/scheduler/entry');
            $request->setMethod(HTTP_METH_POST);

            $request->setHeaders([
              'Authorization' => 'Bearer REPLACE_BEARER_TOKEN',
              'content-type' => 'application/json'
            ]);

            $request->setBody('{"externalId":"3200d382-adfe-4314-ab30-798cdd0fcdb5","type":"SCREENVIEW","schedule":{"enabled":true,"endDate":"2019-08-24T14:15:22Z","endType":"NEVER","parts":[{"startDay":1,"startTime":"08:18:03","endDay":1,"endTime":44283}],"periodType":"ENTIRE","startDate":"2019-08-24T14:15:22Z","startType":"NOW","timezone":"Europe/Warsaw"}}');

            try {
              $response = $request->send();

              echo $response->getBody();
            } catch (HttpException $ex) {
              echo $ex;
            }
        - lang: Java
          label: Java
          source: |-
            HttpResponse<String> response = Unirest.post("https://api.synerise.com/schema-service/scheduler/entry")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .header("content-type", "application/json")
              .body("{\"externalId\":\"3200d382-adfe-4314-ab30-798cdd0fcdb5\",\"type\":\"SCREENVIEW\",\"schedule\":{\"enabled\":true,\"endDate\":\"2019-08-24T14:15:22Z\",\"endType\":\"NEVER\",\"parts\":[{\"startDay\":1,\"startTime\":\"08:18:03\",\"endDay\":1,\"endTime\":44283}],\"periodType\":\"ENTIRE\",\"startDate\":\"2019-08-24T14:15:22Z\",\"startType\":\"NOW\",\"timezone\":\"Europe/Warsaw\"}}")
              .asString();
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: Screen views
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      description: |-
        JWT Bearer token. The header looks like this: `Bearer {JWT}`

        Remember to include the space between 'Bearer' and the token.

        Generate a token via the **Authorization** endpoints.
```
