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

# Create Event

> Create notification event.

#### Recipe

<AccordionGroup>
  <Accordion title="Create event">
    <Steps>
      <Step title="1. Use an `event` parameter to set data associated with the event">
        ```curl {5-6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="2. Set a notification type">
        Use a `notication_type` parameter to set the type of notification.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="3. Set a push notification environment">
        Use an `environment` parameter to set the notification environment.

        Here, the production environment is set which means the pushes will work for a production environment only.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="4. Use a `user` parameter to set the ID of push notification recipient.">
        ```curl {8-9} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "user":{  
              },  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="5. Set the ID of push notification recipient">
        You can specify as many IDs as you need via comma.

        ```curl {9} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "user":{
              "ids":"96831397"  
              },  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="6. Set a push message">
        A push message text should be Base64-encoded.

        Here, the iOS push message is set. For iOS push, you should add a payload before a message.

        ```curl {11} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "user":{
              "ids":"96831397"  
            },
            "message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="7. Set a push notification platform">
        Use a `push_type` parameter to set the push notification platform.

        Here, the `push_type` is set to `apns`. This means that the push will be delivered to iOS devices.

        ```curl {12} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "user":{
              "ids":"96831397"  
            },
            "message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
            "push_type":"apns"
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="8. As a result, the API returns a newly created event.">
        ```json theme={null}
        {
          "event": {
            "id": 30961913,
            "event_type": "one_shot",
            "message": "payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
            "date": null,
            "period": null,
            "name": null,
            "occured_count": 0,
            "created_at": "2019-11-09T19:40:25Z",
            "updated_at": "2019-11-09T19:40:25Z",
            "end_date": null,
            "active": true,
            "application_id": 76730,
            "user_id": 91142495,
            "kind": "API",
            "environment": "production",
            "tag_query": null,
            "notification_channel": {
              "name": "apns"
            }
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create event with period date">
    <Steps>
      <Step title="1. Use an `event` parameter to set data associated with the event">
        ```curl {5-6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="2. Set a notification type">
        Use a `notication_type` parameter to set the type of notification.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="3. Set a push notification environment">
        Use an `environment` parameter to set the notification environment.

        Here, the production environment is set which means the pushes will work for a production environment only.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="4. Set an event type">
        Use an `event_type` method to set the event type.

        Here, the `period_date` event type is set. This event occurs within a given period from the initial date. Valid only if the `period` is specified.

        ```curl {8} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "event_type":"period_date",  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="5. Set a date of the event">
        Use a `date` parameter to set the date for the event to be sent on.

        ```curl {9} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "event_type":"period_date",
            "date":"1567556125",  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="6. Set a period of the event">
        Use a `period` parameter to set the period of the event.

        ```curl {10} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "event_type":"period_date",
            "date":"1567556125",
            "period":"86400",  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="7. Set an end date of the event">
        Use an `end_date` parameter to set the date for the event to end.

        ```curl {11} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "event_type":"period_date",
            "date":"1567556125",
            "period":"86400",
            "end_date":"1568556125",  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="8. Set a push message">
        A push message text should be Base64-encoded.

        Here, the iOS push message is set. For iOS push, you should add a payload before a message.

        ```curl {12} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "event_type":"period_date",
            "date":"1567556125",
            "period":"86400",
            "end_date":"1568556125",
            "message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19", 
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="9. Set a push notification platform">
        Use a `push_type` parameter to set the push notification platform.

        Here, the `push_type` is set to `apns`. This means that the push will be delivered to iOS devices.

        ```curl {13} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 1c3c3584d472a4416eca65df9474ed2cee012bba" \
        -d '{  
          "event":{  
            "notification_type":"push",
            "environment":"production",
            "event_type":"period_date",
            "date":"1567556125",
            "period":"86400",
            "end_date":"1568556125",
            "message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
            "push_type":"apns"
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="10. As a result, the API returns a newly created event.">
        ```json theme={null}
        {
          "event": {
            "id": 30534811,
            "event_type": "period_date",
            "message": "payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
            "date": 1567556125,
            "period": 86400,
            "name": null,
            "occured_count": 1,
            "created_at": "2019-09-02T20:29:55Z",
            "updated_at": "2019-09-02T20:29:55Z",
            "end_date": 1568556125,
            "active": true,
            "application_id": 76730,
            "user_id": 91141808,
            "kind": "API",
            "environment": "production",
            "tag_query": null,
            "notification_channel": {
              "name": "apns"
            }
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create event for users with tags">
    <Steps>
      <Step title="1. Use an `event` parameter to set data associated with the event">
        ```curl {5-6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="2. Set a notification type">
        Use a `notication_type` parameter to set the type of notification.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="3. Set a push notification environment">
        Use an `environment` parameter to set the notification environment.

        Here, the production environment is set which means the pushes will work for a production environment only.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",  
          }
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="4. Use a `user` parameter to set user tags.">
        ```curl {8-9} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "user":{  
            }
          },
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="5. Use a `tags` parameter to set user tags">
        ```curl {9-10} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "user":{
              "tags":{  
              }  
            }
          },
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="6. Set user tags">
        Specify as many tags as you need via comma.

        ```curl {10} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "user":{
              "tags":{
                "any":"web,android"  
              }  
            }
          },
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="7. Set a push message">
        A push message text should be Base64-encoded.

        Here, the iOS push message is set. For iOS push, you should add a payload before a message.

        ```curl {13} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "user":{
              "tags":{
                "any":"web,android"  
              }  
            },
            "message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
          },
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="8. Set a push notification platform">
        Use a `push_type` parameter to set the push notification platform.

        Here, the `push_type` is set to `apns`. This means that the push will be delivered to iOS devices.

        ```curl {14} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
        -d '{  
          "event":{
            "notification_type":"push",
            "environment":"production",
            "user":{
              "tags":{
                "any":"web,android"  
              }  
            },
            "message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
            "push_type":"apns"
          },
        }' \
        https://api.quickblox.com/events.json
        ```
      </Step>

      <Step title="9. As a result, the API returns a newly created event for users with the specified tags.">
        ```json theme={null}
        {
          "event": {
            "id": 30962142,
            "event_type": "one_shot",
            "message": "payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
            "date": null,
            "period": null,
            "name": null,
            "occured_count": 0,
            "created_at": "2019-11-09T20:40:25Z",
            "updated_at": "2019-11-09T20:40:25Z",
            "end_date": null,
            "active": true,
            "application_id": 76730,
            "user_id": 91142495,
            "kind": "API",
            "environment": "production",
            "tag_query": "{\"any\":\"web,android\"}",
            "notification_channel": {
              "name": "apns"
            }
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

<Warning>
  Only one of **(Optional)** parameters is required.
</Warning>

#### Body Parameters

<ParamField body="notification_type" type="string" required>
  Type of notification. Possible values are: `push` and `email.`
</ParamField>

<ParamField body="push_type" type="string">
  Used only if `notification_type=push`, otherwise ignored. If not set, the notification will be delivered to all possible devices for specified users. Possible values are: `apns`, `apns_voip`, `gcm`.
</ParamField>

<ParamField body="environment" type="string" required>
  An environment of the notification. Possible values are: `development` and `production`.
</ParamField>

<ParamField body="event_type" type="string">
  Event type. Possible values are:

  * `one_shot` - a one-time event caused by an external object (valid only if the `date` is **not** specified).
  * `fixed_date` - a one-time event that occurs at a specified date (valid only if the `date` is specified).
  * `period_date` - is a reusable event that occurs within a given period from the initial date (valid only if the `period` is specified).\
    Default:
  * `one_shot` - if `date` is **not** specified.
  * `period_date` - if `period` is specified.
  * `fixed_date` - if `date` is specified.
</ParamField>

<ParamField body="message" type="string" required>
  Encoded message payload. Possible values are: Base64 encoded plain text or
  push notification payload ([Push notifications formats](#push-notification-formats)).
</ParamField>

<ParamField body="user" type="object">
  <Expandable title="properties">
    <ParamField body="ids" type="string">
      **(Optional)** Notification's recipients should contain a string of users' IDs divided by commas.
    </ParamField>

    <ParamField body="tags" type="object">
      <Expandable title="properties">
        <ParamField body="any" type="string">
          **(Optional)** Notification recipients should contain a string of tags divided by commas.
          Recipients must have at least one tag specified in the list.
        </ParamField>

        <ParamField body="all" type="string">
          **(Optional)** Notification recipients should contain a string of tags divided by commas.
          Recipients must have ALL tags specified in the list.
        </ParamField>

        <ParamField body="exclude" type="string">
          **(Optional)** Notification recipients should contain a string of tags divided by commas.
          Recipients must not have tags specified in the list.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="external_user" type="object">
  <Expandable title="external_user object">
    <ParamField body="ids" type="string">
      **(Optional)** Notification recipients should contain a string of external users' IDs divided by commas.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="date" type="date-time">
  The date of the event to send on. If the `event_type=fixed_date`, the `date` can not be in the past.
</ParamField>

<ParamField body="end_date" type="date-time">
  The date when the event is completed. Must be not less than the `date`.
</ParamField>

<ParamField body="period" type="date-time"> The period of the event in seconds. </ParamField>

<ParamField body="name" type="string">
  The name of the event. Service information. Only for your own usage.
</ParamField>

#### Headers

<ParamField header="QB-Token" type="string" required> A user or application session token. See [Authentication](/reference/authentication) page to learn more about session tokens. Must be used either QB-Token or Authorization. </ParamField>

#### Responses

<AccordionGroup>
  <Accordion title="201">
    A successful response.

    <ResponseField name="event" type="object">
      <Expandable title="properties">
        <ResponseField name="id" type="integer" />

        <ResponseField name="event_type" type="string" />

        <ResponseField name="message" type="string" />

        <ResponseField name="date" type="string" />

        <ResponseField name="period" type="string" />

        <ResponseField name="name" type="string" />

        <ResponseField name="occured_count" type="integer" />

        <ResponseField name="created_at" type="string" />

        <ResponseField name="updated_at" type="string" />

        <ResponseField name="end_date" type="string" />

        <ResponseField name="active" type="boolean" />

        <ResponseField name="application_id" type="integer" />

        <ResponseField name="user_id" type="integer" />

        <ResponseField name="kind" type="string" />

        <ResponseField name="environment" type="string" />

        <ResponseField name="tag_query" type="string" />

        <ResponseField name="notification_channel" type="object">
          <Expandable title="properties">
            <ResponseField name="name" type="string" />
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Accordion>
</AccordionGroup>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
  -d '{  
    "event":{  
      "notification_type":"push",
      "environment":"production",
      "user":{  
        "ids":"96831397"
      },
      "message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
      "push_type":"apns"
    }
  }' \
  https://api.quickblox.com/events.json
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "event": {
      "id": 30961913,
      "event_type": "one_shot",
      "message": "payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
      "date": null,
      "period": null,
      "name": null,
      "occured_count": 0,
      "created_at": "2019-11-09T19:40:25Z",
      "updated_at": "2019-11-09T19:40:25Z",
      "end_date": null,
      "active": true,
      "application_id": 76730,
      "user_id": 91142495,
      "kind": "API",
      "environment": "production",
      "tag_query": null,
      "notification_channel": {
        "name": "apns"
      }
    }
  }
  ```
</ResponseExample>
