Creation

This endpoint is used to create new room for a given host. When creating new room, we just need to provide basic information of the room such as name, property type, room type, standard number of guests and maximum number of guests. Your can also specify the the locale of the room by using Accept-Language header, refer to this section of the documentation for more information.

Endpoint

Method URI Headers
POST /api/rooms Authorization: Bearer <token>
Accept: application/json
Accept-Language: <language>

Data Params

Param Description Type Required
name The name of the room. String Yes
room_type The type of the room. Integer Yes
property The property type associated with the room. Integer Yes
accommodates The maximum number of guests. Integer Yes
standard_guests The number of standard guests. Integer Yes

Request & Response Examples

Successful Response

201

Example request

curl \
  --request POST \
  --url https://api.luxstay.com/api/rooms \
  --header 'Accept: application/json' \
  --header 'Accept-Language: vi' \
  --header 'Authorization: Bearer <token>' \
  --form 'name=Test Apartment' \
  --form room_type=1 \
  --form property_type=1 \
  --form accommodates=5 \
  --form standard_guests=4
1
2
3
4
5
6
7
8
9
10
11

Example response

{
    "data": {
        "id": 10775,
        "host": 10130,
        "name": "Test Apartment",
        "num_bedrooms": null,
        "num_bathrooms": null,
        "num_beds": null,
        "standard_guests": 4,
        "maximum_guests": 5,
        "booking_type": null,
        "status": null,
        "submit_status": null,
        "cancellation_policy": "Flexible",
        "roomType": {
            "data": {
                "id": 1,
                "name": "Entire home/apt",
                "description": "Entire home/apt"
            }
        },
        "propertyType": {
            "data": {
                "id": 1,
                "name": "Apartment",
                "description": "Apartment"
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

Error Response

401

Reason invalid access token

Example response

{
    "message": "Unauthenticated."
}
1
2
3

422

Reason validation errors

Example response

{
    "message": "The given data was invalid.",
    "errors": {
        "name": [
            "The name field is required."
        ]
    }
}
1
2
3
4
5
6
7
8
{
    "message": "The given data was invalid.",
    "errors": {
        "room_type": [
            "The room type must be an integer."
        ]
    }
}
1
2
3
4
5
6
7
8
{
    "message": "The given data was invalid.",
    "errors": {
        "room_type": [
            "The selected room type is invalid."
        ]
    }
}
1
2
3
4
5
6
7
8
{
    "message": "The given data was invalid.",
    "errors": {
        "standard_guests": [
            "The standard guests must be less than or equal 5."
        ]
    }
}
1
2
3
4
5
6
7
8
Last Updated: 11/18/2018, 9:11:26 AM