# Update document

- Operation ID: `updateDocumentPost`
- HTTP method: `POST`
- Path: `/schema-service/v2/documents/{documentId}`
- [Human-readable API reference](https://hub.synerise.com/api-reference/asset-management#tag/Documents/operation/updateDocumentPost)

## 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.5
paths:
  /schema-service/v2/documents/{documentId}:
    post:
      tags:
        - Documents
      summary: Update document
      description: |
        Update a document.

        ---

        **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: updateDocumentPost
      security:
        - JWT: []
        - BasicAuth: []
      parameters:
        - name: documentId
          in: path
          required: true
          description: UUID of the document
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Name of the document
                priority:
                  type: integer
                  format: int32
                  maximum: 100
                  description: Priority of the document
                content:
                  description: Content of the document. It can contain inserts.
                  anyOf:
                    - type: object
                      example:
                        someBoolean: true
                        someString: Lorem ipsum
                        aNestedDocument: "{% document exampleslug %}"
                      additionalProperties: true
                    - type: string
                      example: "{% document exampleslug %}"
                schema:
                  type: string
                  description: Schema of the document (called "Type" in the Synerise Web Application)
                  example: containers
                groupId:
                  type: string
                  format: uuid
                  example: 43c97b25-4a10-45d0-99b7-d472eea2bb24
                  description: UUID of the group
                audience:
                  type: object
                  description: The profiles (clients) which have access to this resource
                  required:
                    - targetType
                  properties:
                    targetType:
                      type: string
                      description: |
                        The method of defining the audience:
                        - SEGMENT sets the audience to segmentations whose UUIDs are provided in `segments`
                        - QUERY sets the audience to an analytics query provided in `query`
                        - ALL sets the audience to all profiles in the database
                      enum:
                        - SEGMENT
                        - QUERY
                        - ALL
                    segments:
                      type: array
                      description: "An array of segmentation IDs. Used with `targetType: SEGMENT`"
                      items:
                        type: string
                    query:
                      type: string
                      description: "Stringified `analysis` object for the segmentation analytics engine. Used with `targetType: QUERY`. Refer to the [Analytics API Reference](https://developers.synerise.com/#operation/addSegmentationPOST_v2)."
                      example: '{"analysis":{"title":"Unnamed segmentation","description":"","unique":true,"segments":[{"title":"Segmentation A","description":"","filter":{"matching":true,"expressions":[{"_id":"a9b76c8e-34bd-4ac3-be8f-f37041d126bd","name":"","type":"FUNNEL","matching":true,"funnel":{"_id":"5c759d73-49c6-409f-96a3-b569dff8f8ff","title":"Unnamed","completedWithin":null,"dateFilter":{"type":"RELATIVE","offset":{"type":"DAYS","value":0},"duration":{"type":"DAYS","value":30}},"steps":[{"_id":"78b97ae0-1bc5-45fb-82a4-4f1280cfbdff","title":"","action":{"id":944,"name":"page.visit"},"eventName":"page.visit","expressions":[]}],"exact":false}}]}}]}}'
                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)
                directoryId:
                  type: string
                  format: uuid
                  description: |
                    UUID of a directory. Directories can be used to organize documents and screen views for display in the Synerise Web Application.
                    - If you want to organize documents for screen view campaigns, use document groups instead.
                    - If you want to organize screen views for display, use screen view feeds instead.
      responses:
        "200":
          description: Updated document
          content:
            application/json:
              schema:
                type: object
                title: Documents
                required:
                  - id
                  - name
                  - priority
                  - status
                  - scheduled
                  - createdAt
                  - updatedAt
                  - author
                  - content
                  - audience
                properties:
                  id:
                    type: string
                    format: uuid
                    description: UUID of the document
                  name:
                    type: string
                    description: Name of the document
                  priority:
                    type: integer
                    format: int32
                    maximum: 100
                    description: Priority of the document
                  content:
                    description: Content of the document. It can contain inserts.
                    anyOf:
                      - type: object
                        example:
                          someBoolean: true
                          someString: Lorem ipsum
                          aNestedDocument: "{% document exampleslug %}"
                        additionalProperties: true
                      - type: string
                        example: "{% document exampleslug %}"
                  slug:
                    type: string
                    description: Slug of the document
                    example: basket
                    pattern: "[a-z0-9]+(?:-[a-z0-9]+)*"
                  schema:
                    type: string
                    description: Schema of the document (called "Type" in the Synerise Web Application)
                    example: containers
                  scheduled:
                    type: boolean
                    description: Informs if the document has a defined schedule. Documents scheduled to be published immediately after activation are considered to be scheduled, so only a draft document can have this property at `false`. Copied documents inherit the schedule of their source document.
                  status:
                    type: string
                    enum:
                      - DRAFT
                      - ACTIVE
                      - SCHEDULED
                      - PAUSED
                      - FINISHED
                    description: Filter by status
                  audience:
                    type: object
                    description: The profiles (clients) which have access to this resource
                    required:
                      - targetType
                    properties:
                      targetType:
                        type: string
                        description: |
                          The method of defining the audience:
                          - SEGMENT sets the audience to segmentations whose UUIDs are provided in `segments`
                          - QUERY sets the audience to an analytics query provided in `query`
                          - ALL sets the audience to all profiles in the database
                        enum:
                          - SEGMENT
                          - QUERY
                          - ALL
                      segments:
                        type: array
                        description: "An array of segmentation IDs. Used with `targetType: SEGMENT`"
                        items:
                          type: string
                      query:
                        type: string
                        description: "Stringified `analysis` object for the segmentation analytics engine. Used with `targetType: QUERY`. Refer to the [Analytics API Reference](https://developers.synerise.com/#operation/addSegmentationPOST_v2)."
                        example: '{"analysis":{"title":"Unnamed segmentation","description":"","unique":true,"segments":[{"title":"Segmentation A","description":"","filter":{"matching":true,"expressions":[{"_id":"a9b76c8e-34bd-4ac3-be8f-f37041d126bd","name":"","type":"FUNNEL","matching":true,"funnel":{"_id":"5c759d73-49c6-409f-96a3-b569dff8f8ff","title":"Unnamed","completedWithin":null,"dateFilter":{"type":"RELATIVE","offset":{"type":"DAYS","value":0},"duration":{"type":"DAYS","value":30}},"steps":[{"_id":"78b97ae0-1bc5-45fb-82a4-4f1280cfbdff","title":"","action":{"id":944,"name":"page.visit"},"eventName":"page.visit","expressions":[]}],"exact":false}}]}}]}}'
                  author:
                    type: object
                    description: Author of the resource
                    required:
                      - id
                      - name
                    properties:
                      id:
                        type: integer
                        format: int32
                        description: ID of the author
                      name:
                        type: string
                        description: Name of the author
                      avatar:
                        type: string
                        description: URL of the author's avatar
                  directory:
                    type: object
                    description: Details of the directory where the resource is assigned
                    required:
                      - id
                      - name
                      - createdAt
                      - default
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: |
                          UUID of a directory. Directories can be used to organize documents and screen views for display in the Synerise Web Application.
                          - If you want to organize documents for screen view campaigns, use document groups instead.
                          - If you want to organize screen views for display, use screen view feeds instead.
                      name:
                        type: string
                        description: Name of the directory
                      createdAt:
                        type: string
                        format: date-time
                        description: Date and time when the directory was created
                      default:
                        type: boolean
                        description: "`true` if this is the default directory"
                  group:
                    type: object
                    description: Details of the document group
                    required:
                      - id
                      - bpId
                      - name
                      - createdAt
                    properties:
                      id:
                        type: string
                        format: uuid
                        example: 43c97b25-4a10-45d0-99b7-d472eea2bb24
                        description: UUID of the group
                      name:
                        type: string
                        description: Name of the group
                      createdAt:
                        type: string
                        format: date-time
                        description: Date and time when the group was created
                      deletedAt:
                        type: string
                        format: date-time
                        description: Date and time when the group was deleted, if applicable
                        nullable: true
                      nr:
                        description: The number of documents in this group with status other than FINISHED
                        type: integer
                        format: int32
                  createdAt:
                    type: string
                    description: Creation date
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
                    description: Last update time
                  deletedAt:
                    type: string
                    format: date-time
                    description: Deletion time, if applicable
                    nullable: true
        "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/asset-management#tag/Documents/operation/updateDocumentPost
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/schema-service/v2/documents/%7BdocumentId%7D \
              --header 'Authorization: Basic REPLACE_BASIC_AUTH' \
              --header 'content-type: application/json' \
              --data '{"name":"string","priority":100,"content":{"someBoolean":true,"someString":"Lorem ipsum","aNestedDocument":"{% document exampleslug %}"},"schema":"containers","groupId":"43c97b25-4a10-45d0-99b7-d472eea2bb24","audience":{"targetType":"SEGMENT","segments":["string"],"query":"{\"analysis\":{\"title\":\"Unnamed segmentation\",\"description\":\"\",\"unique\":true,\"segments\":[{\"title\":\"Segmentation A\",\"description\":\"\",\"filter\":{\"matching\":true,\"expressions\":[{\"_id\":\"a9b76c8e-34bd-4ac3-be8f-f37041d126bd\",\"name\":\"\",\"type\":\"FUNNEL\",\"matching\":true,\"funnel\":{\"_id\":\"5c759d73-49c6-409f-96a3-b569dff8f8ff\",\"title\":\"Unnamed\",\"completedWithin\":null,\"dateFilter\":{\"type\":\"RELATIVE\",\"offset\":{\"type\":\"DAYS\",\"value\":0},\"duration\":{\"type\":\"DAYS\",\"value\":30}},\"steps\":[{\"_id\":\"78b97ae0-1bc5-45fb-82a4-4f1280cfbdff\",\"title\":\"\",\"action\":{\"id\":944,\"name\":\"page.visit\"},\"eventName\":\"page.visit\",\"expressions\":[]}],\"exact\":false}}]}}]}}"},"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"},"directoryId":"786c2ec1-fb9a-4593-b705-005b34c18c18"}'
        - lang: Python
          label: Python
          source: |-
            import http.client

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

            payload = "{\"name\":\"string\",\"priority\":100,\"content\":{\"someBoolean\":true,\"someString\":\"Lorem ipsum\",\"aNestedDocument\":\"{% document exampleslug %}\"},\"schema\":\"containers\",\"groupId\":\"43c97b25-4a10-45d0-99b7-d472eea2bb24\",\"audience\":{\"targetType\":\"SEGMENT\",\"segments\":[\"string\"],\"query\":\"{\\\"analysis\\\":{\\\"title\\\":\\\"Unnamed segmentation\\\",\\\"description\\\":\\\"\\\",\\\"unique\\\":true,\\\"segments\\\":[{\\\"title\\\":\\\"Segmentation A\\\",\\\"description\\\":\\\"\\\",\\\"filter\\\":{\\\"matching\\\":true,\\\"expressions\\\":[{\\\"_id\\\":\\\"a9b76c8e-34bd-4ac3-be8f-f37041d126bd\\\",\\\"name\\\":\\\"\\\",\\\"type\\\":\\\"FUNNEL\\\",\\\"matching\\\":true,\\\"funnel\\\":{\\\"_id\\\":\\\"5c759d73-49c6-409f-96a3-b569dff8f8ff\\\",\\\"title\\\":\\\"Unnamed\\\",\\\"completedWithin\\\":null,\\\"dateFilter\\\":{\\\"type\\\":\\\"RELATIVE\\\",\\\"offset\\\":{\\\"type\\\":\\\"DAYS\\\",\\\"value\\\":0},\\\"duration\\\":{\\\"type\\\":\\\"DAYS\\\",\\\"value\\\":30}},\\\"steps\\\":[{\\\"_id\\\":\\\"78b97ae0-1bc5-45fb-82a4-4f1280cfbdff\\\",\\\"title\\\":\\\"\\\",\\\"action\\\":{\\\"id\\\":944,\\\"name\\\":\\\"page.visit\\\"},\\\"eventName\\\":\\\"page.visit\\\",\\\"expressions\\\":[]}],\\\"exact\\\":false}}]}}]}}\"},\"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\"},\"directoryId\":\"786c2ec1-fb9a-4593-b705-005b34c18c18\"}"

            headers = {
                'Authorization': "Basic REPLACE_BASIC_AUTH",
                'content-type': "application/json"
                }

            conn.request("POST", "/schema-service/v2/documents/%7BdocumentId%7D", payload, headers)

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

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = JSON.stringify({
              "name": "string",
              "priority": 100,
              "content": {
                "someBoolean": true,
                "someString": "Lorem ipsum",
                "aNestedDocument": "{% document exampleslug %}"
              },
              "schema": "containers",
              "groupId": "43c97b25-4a10-45d0-99b7-d472eea2bb24",
              "audience": {
                "targetType": "SEGMENT",
                "segments": [
                  "string"
                ],
                "query": "{\"analysis\":{\"title\":\"Unnamed segmentation\",\"description\":\"\",\"unique\":true,\"segments\":[{\"title\":\"Segmentation A\",\"description\":\"\",\"filter\":{\"matching\":true,\"expressions\":[{\"_id\":\"a9b76c8e-34bd-4ac3-be8f-f37041d126bd\",\"name\":\"\",\"type\":\"FUNNEL\",\"matching\":true,\"funnel\":{\"_id\":\"5c759d73-49c6-409f-96a3-b569dff8f8ff\",\"title\":\"Unnamed\",\"completedWithin\":null,\"dateFilter\":{\"type\":\"RELATIVE\",\"offset\":{\"type\":\"DAYS\",\"value\":0},\"duration\":{\"type\":\"DAYS\",\"value\":30}},\"steps\":[{\"_id\":\"78b97ae0-1bc5-45fb-82a4-4f1280cfbdff\",\"title\":\"\",\"action\":{\"id\":944,\"name\":\"page.visit\"},\"eventName\":\"page.visit\",\"expressions\":[]}],\"exact\":false}}]}}]}}"
              },
              "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"
              },
              "directoryId": "786c2ec1-fb9a-4593-b705-005b34c18c18"
            });

            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/v2/documents/%7BdocumentId%7D");
            xhr.setRequestHeader("Authorization", "Basic REPLACE_BASIC_AUTH");
            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/v2/documents/%7BdocumentId%7D",
              "headers": {
                "Authorization": "Basic REPLACE_BASIC_AUTH",
                "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({
              name: 'string',
              priority: 100,
              content: {
                someBoolean: true,
                someString: 'Lorem ipsum',
                aNestedDocument: '{% document exampleslug %}'
              },
              schema: 'containers',
              groupId: '43c97b25-4a10-45d0-99b7-d472eea2bb24',
              audience: {
                targetType: 'SEGMENT',
                segments: ['string'],
                query: '{"analysis":{"title":"Unnamed segmentation","description":"","unique":true,"segments":[{"title":"Segmentation A","description":"","filter":{"matching":true,"expressions":[{"_id":"a9b76c8e-34bd-4ac3-be8f-f37041d126bd","name":"","type":"FUNNEL","matching":true,"funnel":{"_id":"5c759d73-49c6-409f-96a3-b569dff8f8ff","title":"Unnamed","completedWithin":null,"dateFilter":{"type":"RELATIVE","offset":{"type":"DAYS","value":0},"duration":{"type":"DAYS","value":30}},"steps":[{"_id":"78b97ae0-1bc5-45fb-82a4-4f1280cfbdff","title":"","action":{"id":944,"name":"page.visit"},"eventName":"page.visit","expressions":[]}],"exact":false}}]}}]}}'
              },
              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'
              },
              directoryId: '786c2ec1-fb9a-4593-b705-005b34c18c18'
            }));
            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/schema-service/v2/documents/%7BdocumentId%7D');
            $request->setMethod(HTTP_METH_POST);

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

            $request->setBody('{"name":"string","priority":100,"content":{"someBoolean":true,"someString":"Lorem ipsum","aNestedDocument":"{% document exampleslug %}"},"schema":"containers","groupId":"43c97b25-4a10-45d0-99b7-d472eea2bb24","audience":{"targetType":"SEGMENT","segments":["string"],"query":"{\\"analysis\\":{\\"title\\":\\"Unnamed segmentation\\",\\"description\\":\\"\\",\\"unique\\":true,\\"segments\\":[{\\"title\\":\\"Segmentation A\\",\\"description\\":\\"\\",\\"filter\\":{\\"matching\\":true,\\"expressions\\":[{\\"_id\\":\\"a9b76c8e-34bd-4ac3-be8f-f37041d126bd\\",\\"name\\":\\"\\",\\"type\\":\\"FUNNEL\\",\\"matching\\":true,\\"funnel\\":{\\"_id\\":\\"5c759d73-49c6-409f-96a3-b569dff8f8ff\\",\\"title\\":\\"Unnamed\\",\\"completedWithin\\":null,\\"dateFilter\\":{\\"type\\":\\"RELATIVE\\",\\"offset\\":{\\"type\\":\\"DAYS\\",\\"value\\":0},\\"duration\\":{\\"type\\":\\"DAYS\\",\\"value\\":30}},\\"steps\\":[{\\"_id\\":\\"78b97ae0-1bc5-45fb-82a4-4f1280cfbdff\\",\\"title\\":\\"\\",\\"action\\":{\\"id\\":944,\\"name\\":\\"page.visit\\"},\\"eventName\\":\\"page.visit\\",\\"expressions\\":[]}],\\"exact\\":false}}]}}]}}"},"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"},"directoryId":"786c2ec1-fb9a-4593-b705-005b34c18c18"}');

            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/v2/documents/%7BdocumentId%7D")
              .header("Authorization", "Basic REPLACE_BASIC_AUTH")
              .header("content-type", "application/json")
              .body("{\"name\":\"string\",\"priority\":100,\"content\":{\"someBoolean\":true,\"someString\":\"Lorem ipsum\",\"aNestedDocument\":\"{% document exampleslug %}\"},\"schema\":\"containers\",\"groupId\":\"43c97b25-4a10-45d0-99b7-d472eea2bb24\",\"audience\":{\"targetType\":\"SEGMENT\",\"segments\":[\"string\"],\"query\":\"{\\\"analysis\\\":{\\\"title\\\":\\\"Unnamed segmentation\\\",\\\"description\\\":\\\"\\\",\\\"unique\\\":true,\\\"segments\\\":[{\\\"title\\\":\\\"Segmentation A\\\",\\\"description\\\":\\\"\\\",\\\"filter\\\":{\\\"matching\\\":true,\\\"expressions\\\":[{\\\"_id\\\":\\\"a9b76c8e-34bd-4ac3-be8f-f37041d126bd\\\",\\\"name\\\":\\\"\\\",\\\"type\\\":\\\"FUNNEL\\\",\\\"matching\\\":true,\\\"funnel\\\":{\\\"_id\\\":\\\"5c759d73-49c6-409f-96a3-b569dff8f8ff\\\",\\\"title\\\":\\\"Unnamed\\\",\\\"completedWithin\\\":null,\\\"dateFilter\\\":{\\\"type\\\":\\\"RELATIVE\\\",\\\"offset\\\":{\\\"type\\\":\\\"DAYS\\\",\\\"value\\\":0},\\\"duration\\\":{\\\"type\\\":\\\"DAYS\\\",\\\"value\\\":30}},\\\"steps\\\":[{\\\"_id\\\":\\\"78b97ae0-1bc5-45fb-82a4-4f1280cfbdff\\\",\\\"title\\\":\\\"\\\",\\\"action\\\":{\\\"id\\\":944,\\\"name\\\":\\\"page.visit\\\"},\\\"eventName\\\":\\\"page.visit\\\",\\\"expressions\\\":[]}],\\\"exact\\\":false}}]}}]}}\"},\"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\"},\"directoryId\":\"786c2ec1-fb9a-4593-b705-005b34c18c18\"}")
              .asString();
servers:
  - url: https://api.synerise.com
    description: Microsoft Azure EU
  - url: https://api.azu.synerise.com
    description: Microsoft Azure USA
  - url: https://api.geb.synerise.com
    description: Google Cloud Platform
tags:
  - name: Documents
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      description: |
        Synerise uses [JSON Web Token (JWT)](https://jwt.io/) as the authorization method.

        The token is generated by the *auth/login* endpoints.

        You need to include it in the `Authorization` header of your requests, with a `Bearer` prefix.


        By default, the token is valid for **one week** (see [workspace settings](https://hub.synerise.com/docs/settings/tool/iam-for-apps/general/#jwt-lifetime)).  
        You can request a refreshed key for the session by using the *auth/refresh* endpoint **before** the current token expires.


        You can verify your JWT signature by using the [public key](https://api.synerise.com/v4/public.pem).


        See Developer Guides on JWT API authentication for:
        - [profiles](https://hub.synerise.com/developers/api/api-authorization/client-login/);
        - [workspaces](https://hub.synerise.com/developers/api/api-authorization/workspace-login/#api-authentication-with-jwt);
        - [users](https://hub.synerise.com/developers/api/api-authorization/user-login/).
    BasicAuth:
      type: http
      scheme: basic
      description: |
        Basic authentication with login (workspace GUID) and password (workspace API key) encoded with Base64 and sent in the `Authorization` header. **Must be enabled in the settings of the API key**.

        <span style="color:red">This is less secure than JWTs.</span> Limit the API key permissions to only those that you need. Consider API key rotation and other security measures.

        You can still use JWTs from the same API key when basic authentication is enabled.

        For details, see ["Workspace authentication"](https://hub.synerise.com/jwt-or-basic/#basic-api-authentication-with-api-keys).
```
