Skip to main content
POST
/
class.json
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: c95dbdc9c72cc8e7f2367d7ef2c6d99c5e013233" \
-d '{  
  "name":"UserCustomProfile",
  "fields":{  
    "name":"String",
    "last_name":"String",
    "age":"Integer",
    "tags":"String_a"
  },
  "permissions":{  
    "create":{  
      "access":"open"
    },
    "read":{  
      "access":"not_allowed"
    },
    "update":{  
      "access":"open_for_users_ids",
      "ids":"1,2"
    }
  }
}' \
https://api.quickblox.com/class.json
{
  "_id": "5ddfb849a0eb4725dfc9b0ad",
  "acl": {
    "read": {
      "access": "not_allowed"
    },
    "update": {
      "access": "open_for_users_ids",
      "users_ids": [
        "1",
        "2"
      ]
    },
    "delete": {
      "access": "owner"
    },
    "create": {
      "access": "open",
      "primary": true
    }
  },
  "application_id": 78387,
  "custom_fields": [
    {
      "name": "name",
      "type": "String"
    },
    {
      "name": "last_name",
      "type": "String"
    },
    {
      "name": "age",
      "type": "Integer"
    },
    {
      "is_array": "1",
      "name": "tags",
      "type": "String"
    }
  ],
  "name": "UserCustomProfile",
  "user_id": 91103344
}

Recipes

1

1. Set a name of the classs

Use a name parameter to set the name of the class.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: c95dbdc9c72cc8e7f2367d7ef2c6d99c5e013233" \
-d '{  
  "name":"UserCustomProfile",
}' \
"https://api.quickblox.com/class.json"
2

2. Use a `fields` parameter to set custom fields

The fields stores a set of unique keys each having an associated value parameter.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: c95dbdc9c72cc8e7f2367d7ef2c6d99c5e013233" \
-d '{  
  "name":"UserCustomProfile",
  "fields":{},
}' \
"https://api.quickblox.com/class.json"
3

3. Set fields of the custom class

Set as many fields for a new class as you need.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: c95dbdc9c72cc8e7f2367d7ef2c6d99c5e013233" \
-d '{  
  "name":"UserCustomProfile",
  "fields":{  
    "name":"String",
    "last_name":"String",
    "age":"Integer",
    "tags":"String_a"
  },
}' \
"https://api.quickblox.com/class.json"
4

4. Use a `permissions` parameter to set operations allowed and access levels

curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: c95dbdc9c72cc8e7f2367d7ef2c6d99c5e013233" \
-d '{  
  "name":"UserCustomProfile",
  "fields":{  
    "name":"String",
    "last_name":"String",
    "age":"Integer",
    "tags":"String_a"
  },
  "permissions":{},
}' \
"https://api.quickblox.com/class.json"
5

5. Set CRUD operations

Set the operations that can be performed on a record.Here, the create, read, and update operations are set.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: c95dbdc9c72cc8e7f2367d7ef2c6d99c5e013233" \
-d '{  
  "name":"UserCustomProfile",
  "fields":{  
    "name":"String",
    "last_name":"String",
    "age":"Integer",
    "tags":"String_a"
  },
  "permissions":{
    "create":{},
    "read":{},
    "update":{},
  },
}' \
"https://api.quickblox.com/class.json"
6

6. Set access levels

Set an access level for a record.Here, the open, not_allowed, and open_for_users_ids access levels are set.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: c95dbdc9c72cc8e7f2367d7ef2c6d99c5e013233" \
-d '{  
  "name":"UserCustomProfile",
  "fields":{  
    "name":"String",
    "last_name":"String",
    "age":"Integer",
    "tags":"String_a"
  },
  "permissions":{
    "create":{
      "access":"open"
    },
    "read":{
      "access":"not_allowed"
    },
    "update":{
      "access":"open_for_users_ids"
    },
  },
}' \
"https://api.quickblox.com/class.json"
7

7. Set IDs of users

Set IDs of users who can make a required operation.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: c95dbdc9c72cc8e7f2367d7ef2c6d99c5e013233" \
-d '{  
  "name":"UserCustomProfile",
  "fields":{  
    "name":"String",
    "last_name":"String",
    "age":"Integer",
    "tags":"String_a"
  },
  "permissions":{
    "create":{
      "access":"open"
    },
    "read":{
      "access":"not_allowed"
    },
    "update":{
      "access":"open_for_users_ids",
      "ids":"1,2"
    },
  },
}' \
"https://api.quickblox.com/class.json"
8

8. As a result, the API returns a newly created class.

{
  "_id": "5ddfb849a0eb4725dfc9b0ad",
  "acl": {
    "read": {
      "access": "not_allowed"
    },
    "update": {
      "access": "open_for_users_ids",
      "users_ids": [
        "1",
        "2"
      ]
    },
    "delete": {
      "access": "owner"
    },
    "create": {
      "access": "open",
      "primary": true
    }
  },
  "application_id": 78387,
  "custom_fields": [
    {
      "name": "name",
      "type": "String"
    },
    {
      "name": "last_name",
      "type": "String"
    },
    {
      "name": "age",
      "type": "Integer"
    },
    {
      "is_array": "1",
      "name": "tags",
      "type": "String"
    }
  ],
  "name": "UserCustomProfile",
  "user_id": 91103344
}

Body Parameters

name
string
required
Custom class name.
fields
object
Custom class fields with types.
Format: fields.{custom_field}=<field_type>.

Headers

QB-Token
string
required
A user or application session token. See Authentication page to learn more about session tokens. Must be used either QB-Token or Authorization.

Responses

A successful response
_id
string
acl
object
application_id
integer
The ID of the associated application
custom_fields
array
name
string
Name of the resource
user_id
integer
The ID of the associated user
An error response
errors
array of strings
An error response
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: c95dbdc9c72cc8e7f2367d7ef2c6d99c5e013233" \
-d '{  
  "name":"UserCustomProfile",
  "fields":{  
    "name":"String",
    "last_name":"String",
    "age":"Integer",
    "tags":"String_a"
  },
  "permissions":{  
    "create":{  
      "access":"open"
    },
    "read":{  
      "access":"not_allowed"
    },
    "update":{  
      "access":"open_for_users_ids",
      "ids":"1,2"
    }
  }
}' \
https://api.quickblox.com/class.json
{
  "_id": "5ddfb849a0eb4725dfc9b0ad",
  "acl": {
    "read": {
      "access": "not_allowed"
    },
    "update": {
      "access": "open_for_users_ids",
      "users_ids": [
        "1",
        "2"
      ]
    },
    "delete": {
      "access": "owner"
    },
    "create": {
      "access": "open",
      "primary": true
    }
  },
  "application_id": 78387,
  "custom_fields": [
    {
      "name": "name",
      "type": "String"
    },
    {
      "name": "last_name",
      "type": "String"
    },
    {
      "name": "age",
      "type": "Integer"
    },
    {
      "is_array": "1",
      "name": "tags",
      "type": "String"
    }
  ],
  "name": "UserCustomProfile",
  "user_id": 91103344
}
I