Create a Resource

Following endpoint will help you create a resource in Slotify using resource create endpoint:

Authentication

This endpoint needs app token for authentication.

MethodPOST
Endpointv1/resources
HeadersAccept: application/json 
Authorization: Bearer <base64_encoded_token> 
Token typeApp

Query Parameters

This endpoint supports query parameters:

FieldValueDescription
includemeta,app,rulesshow user meta, constraints, app
searchname, emailname or email of the resource

Request Body:

This endpoint requires following parameters to be sent via post body:

Param NameRequiredDescription
nametruename of the resource
timezonetruetimezone of the resource
emailtrueemail of the resource
roletruerole of the user i.e. member/asset
passwordtruepassword for resource
confirm_passwordtrueconfirm password for resource
avatarfalseimage url for resource avatar

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/resources';
$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/resources
{
    "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": "609db778-6888-4d63-a57c-688ad7e4008e",
        "role": "member",
        "name": "John Doe",
        "email": "[email protected]",
        "avatar": null,
        "timezone": "America/Toronto",
        "created_at": "2024-04-30T20:24:43+00:00",
        "updated_at": "2024-04-30T20:24:43+00:00"
    }
}
{
    "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"
    }
}