Create an Event
Following endpoint will help you create a event in Slotify using create endpoint:
Authentication
This endpoint needs app token for authentication.
Method | POST |
---|---|
Endpoint | v1/events |
Headers | Accept: application/json |
Authorization: Bearer <base64_encoded_token> | |
Token type | App |
Query Parameters
This endpoint supports query parameters:
Field | Value | Description |
---|---|---|
include | calendar | shows user calendar for this event |
search | start_at, end_at | search events by start and end dates |
Request Body:
This endpoint requires following parameters to be sent via post body:
Param Name | Required | Description |
---|---|---|
color | false | color for the event |
what | true | event name or purpose |
where | true | location of the event |
description | true | description of the event |
event.start_at | true | start date in iso date time format |
event.end_at | true | end date in iso date time format |
user_calendar_id | true | resource calendar id to add event |
Example Request:
Following code shows how to send request to create a resource in Slotify api.
- PHP
- BASH
- JSON
$apiEndpoint = 'https://api.slotify.ca/v1/events';
$apiToken = base64_encode("app-token");
$data = array(
'name' => 'John Doe',
'email' => '[email protected]',
'role' => 'member', // or 'asset' depending on the resource type
'timezone' => 'America/New_York'
);
$ch = curl_init($apiEndpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . $apiToken,
'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if(curl_errno($ch)){
echo 'Error: ' . curl_error($ch);
}
curl_close($ch);
echo $response;
curl -X POST \
-H "Authorization: Bearer <APP_TOKEN>" \
-H "Content-Type: application/json" \
-d '{"name":"John Doe","email":"[email protected]","role":"member","timezone":"America/Toronto"}' \
https://api.slotify.ca/v1/events
{
"role": "member",
"name": "John Doe",
"email": "[email protected]",
"timezone": "America/Toronto"
}
Example Response:
Following response will be provided by Slotify server when this endpoint is called:
- 201 Created
- 400 Bad Request
{
"success": true,
"data": {
"uuid": "cdd5c031-6203-407a-9977-34288370a398",
"what": "Appointment with Dr. John Doe",
"color": '#ffffff',
"end_at": "2024-09-20T17:00:00+00:00",
"location": {
"type": "address",
"value": "123 ABC Road"
},
"start_at": "2024-09-20T17:00:00+00:00",
"created_at": "2024-09-03T15:39:33+00:00",
"updated_at": "2024-09-03T15:39:33+00:00",
"description": "Appointment with Dr. John Doe"
}
}
{
"success": false,
"errors": {
"name": "This field is required",
"timezone": "This field is required",
"email": "This field is required",
"role": "This field is required",
"password": "This field is required",
"confirm_password": "This field is required"
}
}