> ## 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 Record

> Create a new record of particular class.

#### Recipes

<AccordionGroup>
  <Accordion title="Create record">
    <Steps>
      <Step title="1. Set record fields.">
        You can set as many fields as you need.

        ```curl {5-15} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 199b1d9ec0dedeb19d81283b3b2a32b80f012bba" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ]
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="2. Set a class.">
        Set a class for a new record.

        Here, the `ScoreTable` class is specified.

        ```curl {17} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 199b1d9ec0dedeb19d81283b3b2a32b80f012bba" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ]
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="3. As a result, the API returns a new record.">
        ```json theme={null}
        {
          "_id": "5d866b53a28f9a5ad51cb562",
          "_parent_id": null,
          "completed_levels": [
            1,
            2,
            3
          ],
          "created_at": 1569090387,
          "date": "2019-09-21T21:21:00Z",
          "expert_mode": false,
          "game_mode_name": "deathmatch",
          "progress": 0.12,
          "score_value": 665,
          "updated_at": 1569090387,
          "user_avatar": null,
          "user_id": 96753878,
          "user_location": [
            11.13,
            45.52
          ],
          "permissions": {
            "read": {
              "access": "open"
            },
            "update": {
              "access": "owner"
            },
            "delete": {
              "access": "owner"
            }
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create record with permissions">
    <Steps>
      <Step title="1. Set record fields">
        You can set as many fields as you need for a new record

        ```curl {5-15} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 199b1d9ec0dedeb19d81283b3b2a32b80f012bba" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ],
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="2. Use a `permissions` parameter to set operations allowed and access levels">
        ```curl {16} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 199b1d9ec0dedeb19d81283b3b2a32b80f012bba" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ],
          "permissions": {}
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="3. Set CRUD operations">
        Set CRUD operations that can be performed on a record.

        Here, the `read`, and `update` operations are set.

        ```curl {17-18} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 199b1d9ec0dedeb19d81283b3b2a32b80f012bba" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ],
          "permissions": {
            "read": {},
            "update": {}
          }
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="4. Set access levels">
        Set an access level for a record.

        Here, the `owner`, and `open_for_groups` access levels are set.

        ```curl {18,21} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 199b1d9ec0dedeb19d81283b3b2a32b80f012bba" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ],
          "permissions": {
            "read": {
              "access":"owner",
            },
            "update": {
              "access":"open_for_groups"
            }
          }
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="5. Set a user group">
        Set a user group to determine who can make a required operation.

        Here, users with the `world` tag can make a required operation.

        ```curl {22-24} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 199b1d9ec0dedeb19d81283b3b2a32b80f012bba" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ],
          "permissions": {
            "read": {
              "access":"owner",
            },
            "update": {
              "access":"open_for_groups",
              "user_groups":[
                "world"
              ]
            }
          }
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="6. As a result, the API returns a new record.">
        ```json theme={null}
        {
          "_id": "5d866b53a28f9a5ad51cb562",
          "_parent_id": null,
          "completed_levels": [
            1,
            2,
            3
          ],
          "created_at": 1569090387,
          "date": "2019-09-21T21:21:00Z",
          "expert_mode": false,
          "game_mode_name": "deathmatch",
          "progress": 0.12,
          "score_value": 665,
          "updated_at": 1569090387,
          "user_avatar": null,
          "user_id": 96753878,
          "user_location": [
            11.13,
            45.52
          ],
          "permissions": {
            "read": {
              "access": "owner"
            },
            "update": {
              "access": "open_for_groups",
              "user_groups": [
                "world"
              ]
            },
            "delete": {
              "access": "owner"
            }
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create record with API key">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ]
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="2. Set record fields.">
        You can set as many fields as you need.

        ```curl {5-15} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ]
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="3. Set a class.">
        Set a class for a new record.

        Here, the `ScoreTable` class is specified.

        ```curl {17} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ]
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="4. As a result, the API returns a new record.">
        ```json theme={null}
        {
          "_id": "5d866b53a28f9a5ad51cb562",
          "_parent_id": null,
          "completed_levels": [
            1,
            2,
            3
          ],
          "created_at": 1569090387,
          "date": "2019-09-21T21:21:00Z",
          "expert_mode": false,
          "game_mode_name": "deathmatch",
          "progress": 0.12,
          "score_value": 665,
          "updated_at": 1569090387,
          "user_avatar": null,
          "user_id": 96753878,
          "user_location": [
            11.13,
            45.52
          ],
          "permissions": {
            "read": {
              "access": "open"
            },
            "update": {
              "access": "owner"
            },
            "delete": {
              "access": "owner"
            }
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create record with permissions with API key">
    <Steps>
      <Step title="1. Use 'Authorization' header to pass API key">
        ```curl {3} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ],
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="2. Set record fields">
        You can set as many fields as you need for a new record

        ```curl {5-15} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ],
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="3. Use a `permissions` parameter to set operations allowed and access levels">
        ```curl {16} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ],
          "permissions": {}
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="4. Set CRUD operations">
        Set CRUD operations that can be performed on a record.

        Here, the `read`, and `update` operations are set.

        ```curl {17-18} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ],
          "permissions": {
            "read": {},
            "update": {}
          }
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="5. Set access levels">
        Set an access level for a record.

        Here, the `owner`, and `open_for_groups` access levels are set.

        ```curl {18,21} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ],
          "permissions": {
            "read": {
              "access":"owner",
            },
            "update": {
              "access":"open_for_groups"
            }
          }
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="6. Set a user group">
        Set a user group to determine who can make a required operation.

        Here, users with the `world` tag can make a required operation.

        ```curl {22-24} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
        -d '{
          "score_value":665,
          "progress":"0.12",
          "expert_mode":false,
          "game_mode_name":"deathmatch",
          "user_location":"11.13, 45.52",
          "date":"2019-09-21 21:21:00",
          "completed_levels":[
            1,
            2,
            3
          ],
          "permissions": {
            "read": {
              "access":"owner",
            },
            "update": {
              "access":"open_for_groups",
              "user_groups":[
                "world"
              ]
            }
          }
        }' \
        "https://api.quickblox.com/data/ScoreTable.json"
        ```
      </Step>

      <Step title="7. As a result, the API returns a new record.">
        ```json theme={null}
        {
          "_id": "5d866b53a28f9a5ad51cb562",
          "_parent_id": null,
          "completed_levels": [
            1,
            2,
            3
          ],
          "created_at": 1569090387,
          "date": "2019-09-21T21:21:00Z",
          "expert_mode": false,
          "game_mode_name": "deathmatch",
          "progress": 0.12,
          "score_value": 665,
          "updated_at": 1569090387,
          "user_avatar": null,
          "user_id": 96753878,
          "user_location": [
            11.13,
            45.52
          ],
          "permissions": {
            "read": {
              "access": "owner"
            },
            "update": {
              "access": "open_for_groups",
              "user_groups": [
                "world"
              ]
            },
            "delete": {
              "access": "owner"
            }
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

To create a new record use a `POST` request with `application/json` or `application/x-www-form-urlencoded` content
type of the POST body. Received values will be cast according to the class defined in QuickBlox Dashboard.
The field that is present in the class but **not** specified in the POST request will have a `null` value.

**Allowed permissions**

| Permission         | Syntax                                                                                                                      | Example                                                                               |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| Open               | permissions.\<CRUD\_operation>.access                                                                                       | permissions.read.access=open                                                          |
| Owner              | permissions.\<CRUD\_operation>.access                                                                                       | permissions.read.access=owner                                                         |
| Open for users IDs | permissions.\<CRUD\_operation>.access=open\_for\_users\_ids permissions.\<CRUD\_operation>.ids=id\_1,id\_2,id\_3,…          | permissions.update.access=open\_for\_users\_ids permissions.update.ids=3,12           |
| Open for groups    | permissions.\<CRUD\_operation>.access=open\_for\_groups permissions.\<CRUD\_operation>.groups=group\_name\_1,group\_name\_2 | permissions.delete.access=open\_for\_groups permissions.delete.groups=experience,rate |

#### Path Parameters

<ParamField path="class_name" type="string" required> Custom object class name.</ParamField>

#### Body Parameters

<ParamField body="{custom_field_N}" type="string">
  Set value to the field defined in Custom Object class. Can be many 1..N.
</ParamField>

<ParamField body="permissions" type="string">
  Record permissions. Format: <br />
  `permission.<CRUD_operation>.access=<value>` <br />
  `permission.<CRUD_operation>.<option>=<value>`

  CRUD operations: `create`, `read`, `update`, `delete`. <br />
  CRUD access values: `open`, `owner`, `open_for_users_ids`, `open_for_groups`. <br />
  CRUD options: `ids`, `groups`.
</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>

<ParamField header="Authorization" type="string" default="ApiKey {your_api_key}">
  API key from Dashboard. Expected format: `ApiKey {your_api_key}`. Must be used
  either QB-Token or Authorization.
</ParamField>

<ParamField header="On-Behalf-Of" type="string">
  User ID. The user ID of the user on whose behalf the request is being made.
</ParamField>

#### Responses

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

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

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

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

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

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

    <ResponseField name="permissions" type="object">
      <Expandable title="properties">
        <ResponseField name="read" type="object">
          <Expandable title="properties">
            <ResponseField name="access" type="string" />
          </Expandable>
        </ResponseField>

        <ResponseField name="update" type="object">
          <Expandable title="properties">
            <ResponseField name="access" type="string" />
          </Expandable>
        </ResponseField>

        <ResponseField name="delete" type="object">
          <Expandable title="properties">
            <ResponseField name="access" type="string" />
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Accordion>

  <Accordion title="400">
    An error response
  </Accordion>
</AccordionGroup>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "QB-Token: 199b1d9ec0dedeb19d81283b3b2a32b80f012bba" \
  -d '{
    "score_value":665,
    "progress":"0.12",
    "expert_mode":false,
    "game_mode_name":"deathmatch",
    "user_location":"11.13, 45.52",
    "date":"2019-09-21 21:21:00",
    "completed_levels":[
      1,
      2,
      3
    ]
  }' \
  https://api.quickblox.com/data/ScoreTable.json
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "_id": "5d866b53a28f9a5ad51cb562",
    "_parent_id": null,
    "completed_levels": [
      1,
      2,
      3
    ],
    "created_at": 1569090387,
    "date": "2019-09-21T21:21:00Z",
    "expert_mode": false,
    "game_mode_name": "deathmatch",
    "progress": 0.12,
    "score_value": 665,
    "updated_at": 1569090387,
    "user_avatar": null,
    "user_id": 96753878,
    "user_location": [
      11.13,
      45.52
    ],
    "permissions": {
      "read": {
        "access": "open"
      },
      "update": {
        "access": "owner"
      },
      "delete": {
        "access": "owner"
      }
    }
  }
  ```

  ```json 400 theme={null}
  {}
  ```
</ResponseExample>
