Create a Resource
The following endpoint will help you create a resource in Slotify using resource create endpoint.
Authentication
This endpoint needs an app token for authentication:
| Method | POST | 
|---|---|
| Endpoint | v1/resources | 
| Headers | Accept: application/json | 
| Authorization: Bearer <base64_encoded_token> | |
| Token type | App | 
Query Parameters
This endpoint supports query parameters:
| Field | Value | Description | 
|---|---|---|
| include | meta,app,rules | show user meta, constraints, app | 
| search | name, email | name or email of the resource | 
Request Body:
This endpoint requires the following parameters to be sent via post body:
| Param Name | Required | Description | 
|---|---|---|
| name | true | name of the resource | 
| timezone | true | timezone of the resource | 
| true | email of the resource | |
| role | true | role of the user i.e. member/asset | 
| password | true | password for resource | 
| confirm_password | true | confirm password for resource | 
| avatar | false | image url for resource avatar | 
| verify_email | false | turn-off verification email | 
Example Request:
The 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:
The following response will be provided by the 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"
    }
}